Actualizacion maquina principal
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-tsserver / node_modules / typescript / lib / tsc.js
1 /*! *****************************************************************************
2 Copyright (c) Microsoft Corporation. All rights reserved.
3 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 this file except in compliance with the License. You may obtain a copy of the
5 License at http://www.apache.org/licenses/LICENSE-2.0
6
7 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10 MERCHANTABLITY OR NON-INFRINGEMENT.
11
12 See the Apache Version 2.0 License for specific language governing permissions
13 and limitations under the License.
14 ***************************************************************************** */
15
16
17 "use strict";
18 var __spreadArrays = (this && this.__spreadArrays) || function () {
19     for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
20     for (var r = Array(s), k = 0, i = 0; i < il; i++)
21         for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
22             r[k] = a[j];
23     return r;
24 };
25 var __assign = (this && this.__assign) || function () {
26     __assign = Object.assign || function(t) {
27         for (var s, i = 1, n = arguments.length; i < n; i++) {
28             s = arguments[i];
29             for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
30                 t[p] = s[p];
31         }
32         return t;
33     };
34     return __assign.apply(this, arguments);
35 };
36 var __generator = (this && this.__generator) || function (thisArg, body) {
37     var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
38     return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
39     function verb(n) { return function (v) { return step([n, v]); }; }
40     function step(op) {
41         if (f) throw new TypeError("Generator is already executing.");
42         while (_) try {
43             if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
44             if (y = 0, t) op = [op[0] & 2, t.value];
45             switch (op[0]) {
46                 case 0: case 1: t = op; break;
47                 case 4: _.label++; return { value: op[1], done: false };
48                 case 5: _.label++; y = op[1]; op = [0]; continue;
49                 case 7: op = _.ops.pop(); _.trys.pop(); continue;
50                 default:
51                     if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
52                     if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
53                     if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
54                     if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
55                     if (t[2]) _.ops.pop();
56                     _.trys.pop(); continue;
57             }
58             op = body.call(thisArg, _);
59         } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
60         if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
61     }
62 };
63 var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
64     if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
65     return cooked;
66 };
67 var ts;
68 (function (ts) {
69     ts.versionMajorMinor = "3.9";
70     ts.version = "3.9.5";
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         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."),
5026         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."),
5027         Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."),
5028         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."),
5029         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."),
5030         Watch_input_files: diag(6005, ts.DiagnosticCategory.Message, "Watch_input_files_6005", "Watch input files."),
5031         Redirect_output_structure_to_the_directory: diag(6006, ts.DiagnosticCategory.Message, "Redirect_output_structure_to_the_directory_6006", "Redirect output structure to the directory."),
5032         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."),
5033         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."),
5034         Do_not_emit_comments_to_output: diag(6009, ts.DiagnosticCategory.Message, "Do_not_emit_comments_to_output_6009", "Do not emit comments to output."),
5035         Do_not_emit_outputs: diag(6010, ts.DiagnosticCategory.Message, "Do_not_emit_outputs_6010", "Do not emit outputs."),
5036         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."),
5037         Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."),
5038         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."),
5039         Only_emit_d_ts_declaration_files: diag(6014, ts.DiagnosticCategory.Message, "Only_emit_d_ts_declaration_files_6014", "Only emit '.d.ts' declaration files."),
5040         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'."),
5041         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'."),
5042         Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."),
5043         Print_the_compiler_s_version: diag(6019, ts.DiagnosticCategory.Message, "Print_the_compiler_s_version_6019", "Print the compiler's version."),
5044         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'."),
5045         Syntax_Colon_0: diag(6023, ts.DiagnosticCategory.Message, "Syntax_Colon_0_6023", "Syntax: {0}"),
5046         options: diag(6024, ts.DiagnosticCategory.Message, "options_6024", "options"),
5047         file: diag(6025, ts.DiagnosticCategory.Message, "file_6025", "file"),
5048         Examples_Colon_0: diag(6026, ts.DiagnosticCategory.Message, "Examples_Colon_0_6026", "Examples: {0}"),
5049         Options_Colon: diag(6027, ts.DiagnosticCategory.Message, "Options_Colon_6027", "Options:"),
5050         Version_0: diag(6029, ts.DiagnosticCategory.Message, "Version_0_6029", "Version {0}"),
5051         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."),
5052         Starting_compilation_in_watch_mode: diag(6031, ts.DiagnosticCategory.Message, "Starting_compilation_in_watch_mode_6031", "Starting compilation in watch mode..."),
5053         File_change_detected_Starting_incremental_compilation: diag(6032, ts.DiagnosticCategory.Message, "File_change_detected_Starting_incremental_compilation_6032", "File change detected. Starting incremental compilation..."),
5054         KIND: diag(6034, ts.DiagnosticCategory.Message, "KIND_6034", "KIND"),
5055         FILE: diag(6035, ts.DiagnosticCategory.Message, "FILE_6035", "FILE"),
5056         VERSION: diag(6036, ts.DiagnosticCategory.Message, "VERSION_6036", "VERSION"),
5057         LOCATION: diag(6037, ts.DiagnosticCategory.Message, "LOCATION_6037", "LOCATION"),
5058         DIRECTORY: diag(6038, ts.DiagnosticCategory.Message, "DIRECTORY_6038", "DIRECTORY"),
5059         STRATEGY: diag(6039, ts.DiagnosticCategory.Message, "STRATEGY_6039", "STRATEGY"),
5060         FILE_OR_DIRECTORY: diag(6040, ts.DiagnosticCategory.Message, "FILE_OR_DIRECTORY_6040", "FILE OR DIRECTORY"),
5061         Generates_corresponding_map_file: diag(6043, ts.DiagnosticCategory.Message, "Generates_corresponding_map_file_6043", "Generates corresponding '.map' file."),
5062         Compiler_option_0_expects_an_argument: diag(6044, ts.DiagnosticCategory.Error, "Compiler_option_0_expects_an_argument_6044", "Compiler option '{0}' expects an argument."),
5063         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}'."),
5064         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}."),
5065         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}'."),
5066         Unsupported_locale_0: diag(6049, ts.DiagnosticCategory.Error, "Unsupported_locale_0_6049", "Unsupported locale '{0}'."),
5067         Unable_to_open_file_0: diag(6050, ts.DiagnosticCategory.Error, "Unable_to_open_file_0_6050", "Unable to open file '{0}'."),
5068         Corrupted_locale_file_0: diag(6051, ts.DiagnosticCategory.Error, "Corrupted_locale_file_0_6051", "Corrupted locale file {0}."),
5069         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."),
5070         File_0_not_found: diag(6053, ts.DiagnosticCategory.Error, "File_0_not_found_6053", "File '{0}' not found."),
5071         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}."),
5072         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."),
5073         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."),
5074         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."),
5075         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."),
5076         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)."),
5077         NEWLINE: diag(6061, ts.DiagnosticCategory.Message, "NEWLINE_6061", "NEWLINE"),
5078         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."),
5079         Enables_experimental_support_for_ES7_decorators: diag(6065, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_decorators_6065", "Enables experimental support for ES7 decorators."),
5080         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."),
5081         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."),
5082         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)."),
5083         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."),
5084         Successfully_created_a_tsconfig_json_file: diag(6071, ts.DiagnosticCategory.Message, "Successfully_created_a_tsconfig_json_file_6071", "Successfully created a tsconfig.json file."),
5085         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."),
5086         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)."),
5087         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."),
5088         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."),
5089         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."),
5090         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."),
5091         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."),
5092         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."),
5093         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'."),
5094         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."),
5095         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}."),
5096         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."),
5097         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"),
5098         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."),
5099         Resolving_module_0_from_1: diag(6086, ts.DiagnosticCategory.Message, "Resolving_module_0_from_1_6086", "======== Resolving module '{0}' from '{1}'. ========"),
5100         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}'."),
5101         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}'."),
5102         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}'. ========"),
5103         Module_name_0_was_not_resolved: diag(6090, ts.DiagnosticCategory.Message, "Module_name_0_was_not_resolved_6090", "======== Module name '{0}' was not resolved. ========"),
5104         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}'."),
5105         Module_name_0_matched_pattern_1: diag(6092, ts.DiagnosticCategory.Message, "Module_name_0_matched_pattern_1_6092", "Module name '{0}', matched pattern '{1}'."),
5106         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}'."),
5107         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}'."),
5108         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}'."),
5109         File_0_does_not_exist: diag(6096, ts.DiagnosticCategory.Message, "File_0_does_not_exist_6096", "File '{0}' does not exist."),
5110         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."),
5111         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}'."),
5112         Found_package_json_at_0: diag(6099, ts.DiagnosticCategory.Message, "Found_package_json_at_0_6099", "Found 'package.json' at '{0}'."),
5113         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."),
5114         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}'."),
5115         Allow_javascript_files_to_be_compiled: diag(6102, ts.DiagnosticCategory.Message, "Allow_javascript_files_to_be_compiled_6102", "Allow javascript files to be compiled."),
5116         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."),
5117         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}'."),
5118         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}'."),
5119         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}'."),
5120         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}'."),
5121         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}'."),
5122         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}'."),
5123         Trying_other_entries_in_rootDirs: diag(6110, ts.DiagnosticCategory.Message, "Trying_other_entries_in_rootDirs_6110", "Trying other entries in 'rootDirs'."),
5124         Module_resolution_using_rootDirs_has_failed: diag(6111, ts.DiagnosticCategory.Message, "Module_resolution_using_rootDirs_has_failed_6111", "Module resolution using 'rootDirs' has failed."),
5125         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."),
5126         Enable_strict_null_checks: diag(6113, ts.DiagnosticCategory.Message, "Enable_strict_null_checks_6113", "Enable strict null checks."),
5127         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'?"),
5128         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."),
5129         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}'. ========"),
5130         Resolving_using_primary_search_paths: diag(6117, ts.DiagnosticCategory.Message, "Resolving_using_primary_search_paths_6117", "Resolving using primary search paths..."),
5131         Resolving_from_node_modules_folder: diag(6118, ts.DiagnosticCategory.Message, "Resolving_from_node_modules_folder_6118", "Resolving from node_modules folder..."),
5132         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}. ========"),
5133         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. ========"),
5134         Resolving_with_primary_search_path_0: diag(6121, ts.DiagnosticCategory.Message, "Resolving_with_primary_search_path_0_6121", "Resolving with primary search path '{0}'."),
5135         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."),
5136         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. ========"),
5137         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."),
5138         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}'."),
5139         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."),
5140         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}'. ========"),
5141         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. ========"),
5142         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}'."),
5143         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'."),
5144         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."),
5145         _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),
5146         Report_errors_on_unused_locals: diag(6134, ts.DiagnosticCategory.Message, "Report_errors_on_unused_locals_6134", "Report errors on unused locals."),
5147         Report_errors_on_unused_parameters: diag(6135, ts.DiagnosticCategory.Message, "Report_errors_on_unused_parameters_6135", "Report errors on unused parameters."),
5148         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."),
5149         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}'."),
5150         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),
5151         Import_emit_helpers_from_tslib: diag(6139, ts.DiagnosticCategory.Message, "Import_emit_helpers_from_tslib_6139", "Import emit helpers from 'tslib'."),
5152         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}'."),
5153         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."),
5154         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."),
5155         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}'."),
5156         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."),
5157         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'."),
5158         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}'."),
5159         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."),
5160         Show_diagnostic_information: diag(6149, ts.DiagnosticCategory.Message, "Show_diagnostic_information_6149", "Show diagnostic information."),
5161         Show_verbose_diagnostic_information: diag(6150, ts.DiagnosticCategory.Message, "Show_verbose_diagnostic_information_6150", "Show verbose diagnostic information."),
5162         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."),
5163         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."),
5164         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')."),
5165         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."),
5166         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."),
5167         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')"),
5168         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."),
5169         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)."),
5170         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."),
5171         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."),
5172         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."),
5173         Disable_size_limitations_on_JavaScript_projects: diag(6162, ts.DiagnosticCategory.Message, "Disable_size_limitations_on_JavaScript_projects_6162", "Disable size limitations on JavaScript projects."),
5174         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."),
5175         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."),
5176         Do_not_truncate_error_messages: diag(6165, ts.DiagnosticCategory.Message, "Do_not_truncate_error_messages_6165", "Do not truncate error messages."),
5177         Output_directory_for_generated_declaration_files: diag(6166, ts.DiagnosticCategory.Message, "Output_directory_for_generated_declaration_files_6166", "Output directory for generated declaration files."),
5178         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'."),
5179         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."),
5180         Show_all_compiler_options: diag(6169, ts.DiagnosticCategory.Message, "Show_all_compiler_options_6169", "Show all compiler options."),
5181         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"),
5182         Command_line_Options: diag(6171, ts.DiagnosticCategory.Message, "Command_line_Options_6171", "Command-line Options"),
5183         Basic_Options: diag(6172, ts.DiagnosticCategory.Message, "Basic_Options_6172", "Basic Options"),
5184         Strict_Type_Checking_Options: diag(6173, ts.DiagnosticCategory.Message, "Strict_Type_Checking_Options_6173", "Strict Type-Checking Options"),
5185         Module_Resolution_Options: diag(6174, ts.DiagnosticCategory.Message, "Module_Resolution_Options_6174", "Module Resolution Options"),
5186         Source_Map_Options: diag(6175, ts.DiagnosticCategory.Message, "Source_Map_Options_6175", "Source Map Options"),
5187         Additional_Checks: diag(6176, ts.DiagnosticCategory.Message, "Additional_Checks_6176", "Additional Checks"),
5188         Experimental_Options: diag(6177, ts.DiagnosticCategory.Message, "Experimental_Options_6177", "Experimental Options"),
5189         Advanced_Options: diag(6178, ts.DiagnosticCategory.Message, "Advanced_Options_6178", "Advanced Options"),
5190         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'."),
5191         Enable_all_strict_type_checking_options: diag(6180, ts.DiagnosticCategory.Message, "Enable_all_strict_type_checking_options_6180", "Enable all strict type-checking options."),
5192         List_of_language_service_plugins: diag(6181, ts.DiagnosticCategory.Message, "List_of_language_service_plugins_6181", "List of language service plugins."),
5193         Scoped_package_detected_looking_in_0: diag(6182, ts.DiagnosticCategory.Message, "Scoped_package_detected_looking_in_0_6182", "Scoped package detected, looking in '{0}'"),
5194         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."),
5195         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."),
5196         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."),
5197         Enable_strict_checking_of_function_types: diag(6186, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_function_types_6186", "Enable strict checking of function types."),
5198         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."),
5199         Numeric_separators_are_not_allowed_here: diag(6188, ts.DiagnosticCategory.Error, "Numeric_separators_are_not_allowed_here_6188", "Numeric separators are not allowed here."),
5200         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."),
5201         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."),
5202         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),
5203         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."),
5204         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."),
5205         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)."),
5206         _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),
5207         Include_modules_imported_with_json_extension: diag(6197, ts.DiagnosticCategory.Message, "Include_modules_imported_with_json_extension_6197", "Include modules imported with '.json' extension"),
5208         All_destructured_elements_are_unused: diag(6198, ts.DiagnosticCategory.Error, "All_destructured_elements_are_unused_6198", "All destructured elements are unused.", true),
5209         All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", true),
5210         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}"),
5211         Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."),
5212         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}"),
5213         _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."),
5214         and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."),
5215         All_type_parameters_are_unused: diag(6205, ts.DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused"),
5216         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."),
5217         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}'."),
5218         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}'."),
5219         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."),
5220         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."),
5221         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."),
5222         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?"),
5223         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?"),
5224         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."),
5225         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}'."),
5226         Found_1_error: diag(6216, ts.DiagnosticCategory.Message, "Found_1_error_6216", "Found 1 error."),
5227         Found_0_errors: diag(6217, ts.DiagnosticCategory.Message, "Found_0_errors_6217", "Found {0} errors."),
5228         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}'. ========"),
5229         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}. ========"),
5230         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."),
5231         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."),
5232         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."),
5233         Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."),
5234         Disable_solution_searching_for_this_project: diag(6224, ts.DiagnosticCategory.Message, "Disable_solution_searching_for_this_project_6224", "Disable solution searching for this project."),
5235         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'."),
5236         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'."),
5237         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'."),
5238         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."),
5239         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}'."),
5240         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."),
5241         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}."),
5242         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."),
5243         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."),
5244         Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"),
5245         Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"),
5246         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."),
5247         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}'."),
5248         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."),
5249         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."),
5250         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"),
5251         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"),
5252         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}'"),
5253         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}'"),
5254         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"),
5255         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"),
5256         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"),
5257         Projects_in_this_build_Colon_0: diag(6355, ts.DiagnosticCategory.Message, "Projects_in_this_build_Colon_0_6355", "Projects in this build: {0}"),
5258         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}"),
5259         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}'"),
5260         Building_project_0: diag(6358, ts.DiagnosticCategory.Message, "Building_project_0_6358", "Building project '{0}'..."),
5261         Updating_output_timestamps_of_project_0: diag(6359, ts.DiagnosticCategory.Message, "Updating_output_timestamps_of_project_0_6359", "Updating output timestamps of project '{0}'..."),
5262         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"),
5263         Project_0_is_up_to_date: diag(6361, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_6361", "Project '{0}' is up to date"),
5264         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"),
5265         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"),
5266         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"),
5267         Delete_the_outputs_of_all_projects: diag(6365, ts.DiagnosticCategory.Message, "Delete_the_outputs_of_all_projects_6365", "Delete the outputs of all projects"),
5268         Enable_verbose_logging: diag(6366, ts.DiagnosticCategory.Message, "Enable_verbose_logging_6366", "Enable verbose logging"),
5269         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')"),
5270         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"),
5271         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."),
5272         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."),
5273         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}'..."),
5274         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"),
5275         Updating_output_of_project_0: diag(6373, ts.DiagnosticCategory.Message, "Updating_output_of_project_0_6373", "Updating output of project '{0}'..."),
5276         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}'"),
5277         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}'"),
5278         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}'"),
5279         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}'"),
5280         Enable_incremental_compilation: diag(6378, ts.DiagnosticCategory.Message, "Enable_incremental_compilation_6378", "Enable incremental compilation"),
5281         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."),
5282         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"),
5283         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}'"),
5284         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"),
5285         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"),
5286         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."),
5287         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}'"),
5288         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."),
5289         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."),
5290         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."),
5291         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?"),
5292         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."),
5293         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."),
5294         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."),
5295         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."),
5296         _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."),
5297         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."),
5298         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."),
5299         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."),
5300         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'."),
5301         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."),
5302         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."),
5303         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."),
5304         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."),
5305         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."),
5306         _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."),
5307         _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."),
5308         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."),
5309         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."),
5310         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."),
5311         Unreachable_code_detected: diag(7027, ts.DiagnosticCategory.Error, "Unreachable_code_detected_7027", "Unreachable code detected.", true),
5312         Unused_label: diag(7028, ts.DiagnosticCategory.Error, "Unused_label_7028", "Unused label.", true),
5313         Fallthrough_case_in_switch: diag(7029, ts.DiagnosticCategory.Error, "Fallthrough_case_in_switch_7029", "Fallthrough case in switch."),
5314         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."),
5315         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."),
5316         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."),
5317         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."),
5318         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."),
5319         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}';`"),
5320         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}'."),
5321         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'."),
5322         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."),
5323         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."),
5324         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}`"),
5325         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'."),
5326         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."),
5327         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."),
5328         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."),
5329         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."),
5330         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."),
5331         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."),
5332         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."),
5333         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."),
5334         _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."),
5335         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}'?"),
5336         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}'?"),
5337         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}'."),
5338         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}'."),
5339         _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."),
5340         You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
5341         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."),
5342         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."),
5343         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."),
5344         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."),
5345         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."),
5346         _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."),
5347         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."),
5348         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."),
5349         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."),
5350         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."),
5351         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."),
5352         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."),
5353         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."),
5354         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}'."),
5355         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}'."),
5356         Report_errors_in_js_files: diag(8019, ts.DiagnosticCategory.Message, "Report_errors_in_js_files_8019", "Report errors in .js files."),
5357         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."),
5358         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."),
5359         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."),
5360         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."),
5361         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."),
5362         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."),
5363         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."),
5364         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."),
5365         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."),
5366         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."),
5367         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."),
5368         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."),
5369         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}'."),
5370         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."),
5371         class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."),
5372         Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."),
5373         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."),
5374         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."),
5375         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'."),
5376         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."),
5377         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}'."),
5378         JSX_attribute_expected: diag(17003, ts.DiagnosticCategory.Error, "JSX_attribute_expected_17003", "JSX attribute expected."),
5379         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."),
5380         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'."),
5381         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."),
5382         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."),
5383         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."),
5384         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."),
5385         Unknown_type_acquisition_option_0: diag(17010, ts.DiagnosticCategory.Error, "Unknown_type_acquisition_option_0_17010", "Unknown type acquisition option '{0}'."),
5386         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."),
5387         _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}'?"),
5388         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."),
5389         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."),
5390         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."),
5391         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"),
5392         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"),
5393         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}'?"),
5394         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}"),
5395         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."),
5396         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."),
5397         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}'."),
5398         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."),
5399         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."),
5400         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."),
5401         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."),
5402         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."),
5403         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."),
5404         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."),
5405         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."),
5406         Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"),
5407         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"),
5408         Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"),
5409         Remove_unused_declaration_for_Colon_0: diag(90004, ts.DiagnosticCategory.Message, "Remove_unused_declaration_for_Colon_0_90004", "Remove unused declaration for: '{0}'"),
5410         Remove_import_from_0: diag(90005, ts.DiagnosticCategory.Message, "Remove_import_from_0_90005", "Remove import from '{0}'"),
5411         Implement_interface_0: diag(90006, ts.DiagnosticCategory.Message, "Implement_interface_0_90006", "Implement interface '{0}'"),
5412         Implement_inherited_abstract_class: diag(90007, ts.DiagnosticCategory.Message, "Implement_inherited_abstract_class_90007", "Implement inherited abstract class"),
5413         Add_0_to_unresolved_variable: diag(90008, ts.DiagnosticCategory.Message, "Add_0_to_unresolved_variable_90008", "Add '{0}.' to unresolved variable"),
5414         Remove_destructuring: diag(90009, ts.DiagnosticCategory.Message, "Remove_destructuring_90009", "Remove destructuring"),
5415         Remove_variable_statement: diag(90010, ts.DiagnosticCategory.Message, "Remove_variable_statement_90010", "Remove variable statement"),
5416         Remove_template_tag: diag(90011, ts.DiagnosticCategory.Message, "Remove_template_tag_90011", "Remove template tag"),
5417         Remove_type_parameters: diag(90012, ts.DiagnosticCategory.Message, "Remove_type_parameters_90012", "Remove type parameters"),
5418         Import_0_from_module_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_module_1_90013", "Import '{0}' from module \"{1}\""),
5419         Change_0_to_1: diag(90014, ts.DiagnosticCategory.Message, "Change_0_to_1_90014", "Change '{0}' to '{1}'"),
5420         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}\""),
5421         Declare_property_0: diag(90016, ts.DiagnosticCategory.Message, "Declare_property_0_90016", "Declare property '{0}'"),
5422         Add_index_signature_for_property_0: diag(90017, ts.DiagnosticCategory.Message, "Add_index_signature_for_property_0_90017", "Add index signature for property '{0}'"),
5423         Disable_checking_for_this_file: diag(90018, ts.DiagnosticCategory.Message, "Disable_checking_for_this_file_90018", "Disable checking for this file"),
5424         Ignore_this_error_message: diag(90019, ts.DiagnosticCategory.Message, "Ignore_this_error_message_90019", "Ignore this error message"),
5425         Initialize_property_0_in_the_constructor: diag(90020, ts.DiagnosticCategory.Message, "Initialize_property_0_in_the_constructor_90020", "Initialize property '{0}' in the constructor"),
5426         Initialize_static_property_0: diag(90021, ts.DiagnosticCategory.Message, "Initialize_static_property_0_90021", "Initialize static property '{0}'"),
5427         Change_spelling_to_0: diag(90022, ts.DiagnosticCategory.Message, "Change_spelling_to_0_90022", "Change spelling to '{0}'"),
5428         Declare_method_0: diag(90023, ts.DiagnosticCategory.Message, "Declare_method_0_90023", "Declare method '{0}'"),
5429         Declare_static_method_0: diag(90024, ts.DiagnosticCategory.Message, "Declare_static_method_0_90024", "Declare static method '{0}'"),
5430         Prefix_0_with_an_underscore: diag(90025, ts.DiagnosticCategory.Message, "Prefix_0_with_an_underscore_90025", "Prefix '{0}' with an underscore"),
5431         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}'"),
5432         Declare_static_property_0: diag(90027, ts.DiagnosticCategory.Message, "Declare_static_property_0_90027", "Declare static property '{0}'"),
5433         Call_decorator_expression: diag(90028, ts.DiagnosticCategory.Message, "Call_decorator_expression_90028", "Call decorator expression"),
5434         Add_async_modifier_to_containing_function: diag(90029, ts.DiagnosticCategory.Message, "Add_async_modifier_to_containing_function_90029", "Add async modifier to containing function"),
5435         Replace_infer_0_with_unknown: diag(90030, ts.DiagnosticCategory.Message, "Replace_infer_0_with_unknown_90030", "Replace 'infer {0}' with 'unknown'"),
5436         Replace_all_unused_infer_with_unknown: diag(90031, ts.DiagnosticCategory.Message, "Replace_all_unused_infer_with_unknown_90031", "Replace all unused 'infer' with 'unknown'"),
5437         Import_default_0_from_module_1: diag(90032, ts.DiagnosticCategory.Message, "Import_default_0_from_module_1_90032", "Import default '{0}' from module \"{1}\""),
5438         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}\""),
5439         Add_parameter_name: diag(90034, ts.DiagnosticCategory.Message, "Add_parameter_name_90034", "Add parameter name"),
5440         Declare_private_property_0: diag(90035, ts.DiagnosticCategory.Message, "Declare_private_property_0_90035", "Declare private property '{0}'"),
5441         Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."),
5442         Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
5443         Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"),
5444         Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
5445         Extract_function: diag(95005, ts.DiagnosticCategory.Message, "Extract_function_95005", "Extract function"),
5446         Extract_constant: diag(95006, ts.DiagnosticCategory.Message, "Extract_constant_95006", "Extract constant"),
5447         Extract_to_0_in_enclosing_scope: diag(95007, ts.DiagnosticCategory.Message, "Extract_to_0_in_enclosing_scope_95007", "Extract to {0} in enclosing scope"),
5448         Extract_to_0_in_1_scope: diag(95008, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_scope_95008", "Extract to {0} in {1} scope"),
5449         Annotate_with_type_from_JSDoc: diag(95009, ts.DiagnosticCategory.Message, "Annotate_with_type_from_JSDoc_95009", "Annotate with type from JSDoc"),
5450         Annotate_with_types_from_JSDoc: diag(95010, ts.DiagnosticCategory.Message, "Annotate_with_types_from_JSDoc_95010", "Annotate with types from JSDoc"),
5451         Infer_type_of_0_from_usage: diag(95011, ts.DiagnosticCategory.Message, "Infer_type_of_0_from_usage_95011", "Infer type of '{0}' from usage"),
5452         Infer_parameter_types_from_usage: diag(95012, ts.DiagnosticCategory.Message, "Infer_parameter_types_from_usage_95012", "Infer parameter types from usage"),
5453         Convert_to_default_import: diag(95013, ts.DiagnosticCategory.Message, "Convert_to_default_import_95013", "Convert to default import"),
5454         Install_0: diag(95014, ts.DiagnosticCategory.Message, "Install_0_95014", "Install '{0}'"),
5455         Replace_import_with_0: diag(95015, ts.DiagnosticCategory.Message, "Replace_import_with_0_95015", "Replace import with '{0}'."),
5456         Use_synthetic_default_member: diag(95016, ts.DiagnosticCategory.Message, "Use_synthetic_default_member_95016", "Use synthetic 'default' member."),
5457         Convert_to_ES6_module: diag(95017, ts.DiagnosticCategory.Message, "Convert_to_ES6_module_95017", "Convert to ES6 module"),
5458         Add_undefined_type_to_property_0: diag(95018, ts.DiagnosticCategory.Message, "Add_undefined_type_to_property_0_95018", "Add 'undefined' type to property '{0}'"),
5459         Add_initializer_to_property_0: diag(95019, ts.DiagnosticCategory.Message, "Add_initializer_to_property_0_95019", "Add initializer to property '{0}'"),
5460         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}'"),
5461         Add_all_missing_members: diag(95022, ts.DiagnosticCategory.Message, "Add_all_missing_members_95022", "Add all missing members"),
5462         Infer_all_types_from_usage: diag(95023, ts.DiagnosticCategory.Message, "Infer_all_types_from_usage_95023", "Infer all types from usage"),
5463         Delete_all_unused_declarations: diag(95024, ts.DiagnosticCategory.Message, "Delete_all_unused_declarations_95024", "Delete all unused declarations"),
5464         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"),
5465         Fix_all_detected_spelling_errors: diag(95026, ts.DiagnosticCategory.Message, "Fix_all_detected_spelling_errors_95026", "Fix all detected spelling errors"),
5466         Add_initializers_to_all_uninitialized_properties: diag(95027, ts.DiagnosticCategory.Message, "Add_initializers_to_all_uninitialized_properties_95027", "Add initializers to all uninitialized properties"),
5467         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"),
5468         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"),
5469         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"),
5470         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)"),
5471         Implement_all_unimplemented_interfaces: diag(95032, ts.DiagnosticCategory.Message, "Implement_all_unimplemented_interfaces_95032", "Implement all unimplemented interfaces"),
5472         Install_all_missing_types_packages: diag(95033, ts.DiagnosticCategory.Message, "Install_all_missing_types_packages_95033", "Install all missing types packages"),
5473         Rewrite_all_as_indexed_access_types: diag(95034, ts.DiagnosticCategory.Message, "Rewrite_all_as_indexed_access_types_95034", "Rewrite all as indexed access types"),
5474         Convert_all_to_default_imports: diag(95035, ts.DiagnosticCategory.Message, "Convert_all_to_default_imports_95035", "Convert all to default imports"),
5475         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"),
5476         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"),
5477         Change_all_extended_interfaces_to_implements: diag(95038, ts.DiagnosticCategory.Message, "Change_all_extended_interfaces_to_implements_95038", "Change all extended interfaces to 'implements'"),
5478         Add_all_missing_super_calls: diag(95039, ts.DiagnosticCategory.Message, "Add_all_missing_super_calls_95039", "Add all missing super calls"),
5479         Implement_all_inherited_abstract_classes: diag(95040, ts.DiagnosticCategory.Message, "Implement_all_inherited_abstract_classes_95040", "Implement all inherited abstract classes"),
5480         Add_all_missing_async_modifiers: diag(95041, ts.DiagnosticCategory.Message, "Add_all_missing_async_modifiers_95041", "Add all missing 'async' modifiers"),
5481         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"),
5482         Annotate_everything_with_types_from_JSDoc: diag(95043, ts.DiagnosticCategory.Message, "Annotate_everything_with_types_from_JSDoc_95043", "Annotate everything with types from JSDoc"),
5483         Add_to_all_uncalled_decorators: diag(95044, ts.DiagnosticCategory.Message, "Add_to_all_uncalled_decorators_95044", "Add '()' to all uncalled decorators"),
5484         Convert_all_constructor_functions_to_classes: diag(95045, ts.DiagnosticCategory.Message, "Convert_all_constructor_functions_to_classes_95045", "Convert all constructor functions to classes"),
5485         Generate_get_and_set_accessors: diag(95046, ts.DiagnosticCategory.Message, "Generate_get_and_set_accessors_95046", "Generate 'get' and 'set' accessors"),
5486         Convert_require_to_import: diag(95047, ts.DiagnosticCategory.Message, "Convert_require_to_import_95047", "Convert 'require' to 'import'"),
5487         Convert_all_require_to_import: diag(95048, ts.DiagnosticCategory.Message, "Convert_all_require_to_import_95048", "Convert all 'require' to 'import'"),
5488         Move_to_a_new_file: diag(95049, ts.DiagnosticCategory.Message, "Move_to_a_new_file_95049", "Move to a new file"),
5489         Remove_unreachable_code: diag(95050, ts.DiagnosticCategory.Message, "Remove_unreachable_code_95050", "Remove unreachable code"),
5490         Remove_all_unreachable_code: diag(95051, ts.DiagnosticCategory.Message, "Remove_all_unreachable_code_95051", "Remove all unreachable code"),
5491         Add_missing_typeof: diag(95052, ts.DiagnosticCategory.Message, "Add_missing_typeof_95052", "Add missing 'typeof'"),
5492         Remove_unused_label: diag(95053, ts.DiagnosticCategory.Message, "Remove_unused_label_95053", "Remove unused label"),
5493         Remove_all_unused_labels: diag(95054, ts.DiagnosticCategory.Message, "Remove_all_unused_labels_95054", "Remove all unused labels"),
5494         Convert_0_to_mapped_object_type: diag(95055, ts.DiagnosticCategory.Message, "Convert_0_to_mapped_object_type_95055", "Convert '{0}' to mapped object type"),
5495         Convert_namespace_import_to_named_imports: diag(95056, ts.DiagnosticCategory.Message, "Convert_namespace_import_to_named_imports_95056", "Convert namespace import to named imports"),
5496         Convert_named_imports_to_namespace_import: diag(95057, ts.DiagnosticCategory.Message, "Convert_named_imports_to_namespace_import_95057", "Convert named imports to namespace import"),
5497         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"),
5498         Add_braces_to_arrow_function: diag(95059, ts.DiagnosticCategory.Message, "Add_braces_to_arrow_function_95059", "Add braces to arrow function"),
5499         Remove_braces_from_arrow_function: diag(95060, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_95060", "Remove braces from arrow function"),
5500         Convert_default_export_to_named_export: diag(95061, ts.DiagnosticCategory.Message, "Convert_default_export_to_named_export_95061", "Convert default export to named export"),
5501         Convert_named_export_to_default_export: diag(95062, ts.DiagnosticCategory.Message, "Convert_named_export_to_default_export_95062", "Convert named export to default export"),
5502         Add_missing_enum_member_0: diag(95063, ts.DiagnosticCategory.Message, "Add_missing_enum_member_0_95063", "Add missing enum member '{0}'"),
5503         Add_all_missing_imports: diag(95064, ts.DiagnosticCategory.Message, "Add_all_missing_imports_95064", "Add all missing imports"),
5504         Convert_to_async_function: diag(95065, ts.DiagnosticCategory.Message, "Convert_to_async_function_95065", "Convert to async function"),
5505         Convert_all_to_async_functions: diag(95066, ts.DiagnosticCategory.Message, "Convert_all_to_async_functions_95066", "Convert all to async functions"),
5506         Add_missing_call_parentheses: diag(95067, ts.DiagnosticCategory.Message, "Add_missing_call_parentheses_95067", "Add missing call parentheses"),
5507         Add_all_missing_call_parentheses: diag(95068, ts.DiagnosticCategory.Message, "Add_all_missing_call_parentheses_95068", "Add all missing call parentheses"),
5508         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"),
5509         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"),
5510         Add_missing_new_operator_to_call: diag(95071, ts.DiagnosticCategory.Message, "Add_missing_new_operator_to_call_95071", "Add missing 'new' operator to call"),
5511         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"),
5512         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"),
5513         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"),
5514         Convert_parameters_to_destructured_object: diag(95075, ts.DiagnosticCategory.Message, "Convert_parameters_to_destructured_object_95075", "Convert parameters to destructured object"),
5515         Allow_accessing_UMD_globals_from_modules: diag(95076, ts.DiagnosticCategory.Message, "Allow_accessing_UMD_globals_from_modules_95076", "Allow accessing UMD globals from modules."),
5516         Extract_type: diag(95077, ts.DiagnosticCategory.Message, "Extract_type_95077", "Extract type"),
5517         Extract_to_type_alias: diag(95078, ts.DiagnosticCategory.Message, "Extract_to_type_alias_95078", "Extract to type alias"),
5518         Extract_to_typedef: diag(95079, ts.DiagnosticCategory.Message, "Extract_to_typedef_95079", "Extract to typedef"),
5519         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"),
5520         Add_const_to_unresolved_variable: diag(95081, ts.DiagnosticCategory.Message, "Add_const_to_unresolved_variable_95081", "Add 'const' to unresolved variable"),
5521         Add_const_to_all_unresolved_variables: diag(95082, ts.DiagnosticCategory.Message, "Add_const_to_all_unresolved_variables_95082", "Add 'const' to all unresolved variables"),
5522         Add_await: diag(95083, ts.DiagnosticCategory.Message, "Add_await_95083", "Add 'await'"),
5523         Add_await_to_initializer_for_0: diag(95084, ts.DiagnosticCategory.Message, "Add_await_to_initializer_for_0_95084", "Add 'await' to initializer for '{0}'"),
5524         Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"),
5525         Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"),
5526         Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"),
5527         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"),
5528         Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"),
5529         Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"),
5530         Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"),
5531         Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"),
5532         Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"),
5533         Prefix_with_declare: diag(95094, ts.DiagnosticCategory.Message, "Prefix_with_declare_95094", "Prefix with 'declare'"),
5534         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'"),
5535         Convert_to_template_string: diag(95096, ts.DiagnosticCategory.Message, "Convert_to_template_string_95096", "Convert to template string"),
5536         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"),
5537         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}'"),
5538         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}'"),
5539         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"),
5540         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"),
5541         Add_class_tag: diag(95102, ts.DiagnosticCategory.Message, "Add_class_tag_95102", "Add '@class' tag"),
5542         Add_this_tag: diag(95103, ts.DiagnosticCategory.Message, "Add_this_tag_95103", "Add '@this' tag"),
5543         Add_this_parameter: diag(95104, ts.DiagnosticCategory.Message, "Add_this_parameter_95104", "Add 'this' parameter."),
5544         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"),
5545         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"),
5546         Fix_all_implicit_this_errors: diag(95107, ts.DiagnosticCategory.Message, "Fix_all_implicit_this_errors_95107", "Fix all implicit-'this' errors"),
5547         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"),
5548         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"),
5549         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"),
5550         Add_a_return_statement: diag(95111, ts.DiagnosticCategory.Message, "Add_a_return_statement_95111", "Add a return statement"),
5551         Remove_block_body_braces: diag(95112, ts.DiagnosticCategory.Message, "Remove_block_body_braces_95112", "Remove block body braces"),
5552         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"),
5553         Add_all_missing_return_statement: diag(95114, ts.DiagnosticCategory.Message, "Add_all_missing_return_statement_95114", "Add all missing return statement"),
5554         Remove_all_incorrect_body_block_braces: diag(95115, ts.DiagnosticCategory.Message, "Remove_all_incorrect_body_block_braces_95115", "Remove all incorrect body block braces"),
5555         Wrap_all_object_literal_with_parentheses: diag(95116, ts.DiagnosticCategory.Message, "Wrap_all_object_literal_with_parentheses_95116", "Wrap all object literal with parentheses"),
5556         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."),
5557         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'."),
5558         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?"),
5559         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"),
5560         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."),
5561         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."),
5562         constructor_is_a_reserved_word: diag(18012, ts.DiagnosticCategory.Error, "constructor_is_a_reserved_word_18012", "'#constructor' is a reserved word."),
5563         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."),
5564         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."),
5565         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}'."),
5566         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."),
5567         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"),
5568         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"),
5569         _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"),
5570         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."),
5571         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."),
5572         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."),
5573         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."),
5574         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."),
5575         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."),
5576         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."),
5577         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."),
5578         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."),
5579         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."),
5580         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."),
5581     };
5582 })(ts || (ts = {}));
5583 var ts;
5584 (function (ts) {
5585     var _a;
5586     function tokenIsIdentifierOrKeyword(token) {
5587         return token >= 75;
5588     }
5589     ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword;
5590     function tokenIsIdentifierOrKeywordOrGreaterThan(token) {
5591         return token === 31 || tokenIsIdentifierOrKeyword(token);
5592     }
5593     ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan;
5594     var textToKeywordObj = (_a = {
5595             abstract: 122,
5596             any: 125,
5597             as: 123,
5598             asserts: 124,
5599             bigint: 151,
5600             boolean: 128,
5601             break: 77,
5602             case: 78,
5603             catch: 79,
5604             class: 80,
5605             continue: 82,
5606             const: 81
5607         },
5608         _a["" + "constructor"] = 129,
5609         _a.debugger = 83,
5610         _a.declare = 130,
5611         _a.default = 84,
5612         _a.delete = 85,
5613         _a.do = 86,
5614         _a.else = 87,
5615         _a.enum = 88,
5616         _a.export = 89,
5617         _a.extends = 90,
5618         _a.false = 91,
5619         _a.finally = 92,
5620         _a.for = 93,
5621         _a.from = 149,
5622         _a.function = 94,
5623         _a.get = 131,
5624         _a.if = 95,
5625         _a.implements = 113,
5626         _a.import = 96,
5627         _a.in = 97,
5628         _a.infer = 132,
5629         _a.instanceof = 98,
5630         _a.interface = 114,
5631         _a.is = 133,
5632         _a.keyof = 134,
5633         _a.let = 115,
5634         _a.module = 135,
5635         _a.namespace = 136,
5636         _a.never = 137,
5637         _a.new = 99,
5638         _a.null = 100,
5639         _a.number = 140,
5640         _a.object = 141,
5641         _a.package = 116,
5642         _a.private = 117,
5643         _a.protected = 118,
5644         _a.public = 119,
5645         _a.readonly = 138,
5646         _a.require = 139,
5647         _a.global = 150,
5648         _a.return = 101,
5649         _a.set = 142,
5650         _a.static = 120,
5651         _a.string = 143,
5652         _a.super = 102,
5653         _a.switch = 103,
5654         _a.symbol = 144,
5655         _a.this = 104,
5656         _a.throw = 105,
5657         _a.true = 106,
5658         _a.try = 107,
5659         _a.type = 145,
5660         _a.typeof = 108,
5661         _a.undefined = 146,
5662         _a.unique = 147,
5663         _a.unknown = 148,
5664         _a.var = 109,
5665         _a.void = 110,
5666         _a.while = 111,
5667         _a.with = 112,
5668         _a.yield = 121,
5669         _a.async = 126,
5670         _a.await = 127,
5671         _a.of = 152,
5672         _a);
5673     var textToKeyword = ts.createMapFromTemplate(textToKeywordObj);
5674     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 }));
5675     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,];
5676     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,];
5677     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,];
5678     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,];
5679     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];
5680     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];
5681     var commentDirectiveRegExSingleLine = /^\s*\/\/\/?\s*@(ts-expect-error|ts-ignore)/;
5682     var commentDirectiveRegExMultiLine = /^\s*(?:\/|\*)*\s*@(ts-expect-error|ts-ignore)/;
5683     function lookupInUnicodeMap(code, map) {
5684         if (code < map[0]) {
5685             return false;
5686         }
5687         var lo = 0;
5688         var hi = map.length;
5689         var mid;
5690         while (lo + 1 < hi) {
5691             mid = lo + (hi - lo) / 2;
5692             mid -= mid % 2;
5693             if (map[mid] <= code && code <= map[mid + 1]) {
5694                 return true;
5695             }
5696             if (code < map[mid]) {
5697                 hi = mid;
5698             }
5699             else {
5700                 lo = mid + 2;
5701             }
5702         }
5703         return false;
5704     }
5705     function isUnicodeIdentifierStart(code, languageVersion) {
5706         return languageVersion >= 2 ?
5707             lookupInUnicodeMap(code, unicodeESNextIdentifierStart) :
5708             languageVersion === 1 ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) :
5709                 lookupInUnicodeMap(code, unicodeES3IdentifierStart);
5710     }
5711     ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart;
5712     function isUnicodeIdentifierPart(code, languageVersion) {
5713         return languageVersion >= 2 ?
5714             lookupInUnicodeMap(code, unicodeESNextIdentifierPart) :
5715             languageVersion === 1 ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) :
5716                 lookupInUnicodeMap(code, unicodeES3IdentifierPart);
5717     }
5718     function makeReverseMap(source) {
5719         var result = [];
5720         source.forEach(function (value, name) {
5721             result[value] = name;
5722         });
5723         return result;
5724     }
5725     var tokenStrings = makeReverseMap(textToToken);
5726     function tokenToString(t) {
5727         return tokenStrings[t];
5728     }
5729     ts.tokenToString = tokenToString;
5730     function stringToToken(s) {
5731         return textToToken.get(s);
5732     }
5733     ts.stringToToken = stringToToken;
5734     function computeLineStarts(text) {
5735         var result = new Array();
5736         var pos = 0;
5737         var lineStart = 0;
5738         while (pos < text.length) {
5739             var ch = text.charCodeAt(pos);
5740             pos++;
5741             switch (ch) {
5742                 case 13:
5743                     if (text.charCodeAt(pos) === 10) {
5744                         pos++;
5745                     }
5746                 case 10:
5747                     result.push(lineStart);
5748                     lineStart = pos;
5749                     break;
5750                 default:
5751                     if (ch > 127 && isLineBreak(ch)) {
5752                         result.push(lineStart);
5753                         lineStart = pos;
5754                     }
5755                     break;
5756             }
5757         }
5758         result.push(lineStart);
5759         return result;
5760     }
5761     ts.computeLineStarts = computeLineStarts;
5762     function getPositionOfLineAndCharacter(sourceFile, line, character, allowEdits) {
5763         return sourceFile.getPositionOfLineAndCharacter ?
5764             sourceFile.getPositionOfLineAndCharacter(line, character, allowEdits) :
5765             computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character, sourceFile.text, allowEdits);
5766     }
5767     ts.getPositionOfLineAndCharacter = getPositionOfLineAndCharacter;
5768     function computePositionOfLineAndCharacter(lineStarts, line, character, debugText, allowEdits) {
5769         if (line < 0 || line >= lineStarts.length) {
5770             if (allowEdits) {
5771                 line = line < 0 ? 0 : line >= lineStarts.length ? lineStarts.length - 1 : line;
5772             }
5773             else {
5774                 ts.Debug.fail("Bad line number. Line: " + line + ", lineStarts.length: " + lineStarts.length + " , line map is correct? " + (debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown"));
5775             }
5776         }
5777         var res = lineStarts[line] + character;
5778         if (allowEdits) {
5779             return res > lineStarts[line + 1] ? lineStarts[line + 1] : typeof debugText === "string" && res > debugText.length ? debugText.length : res;
5780         }
5781         if (line < lineStarts.length - 1) {
5782             ts.Debug.assert(res < lineStarts[line + 1]);
5783         }
5784         else if (debugText !== undefined) {
5785             ts.Debug.assert(res <= debugText.length);
5786         }
5787         return res;
5788     }
5789     ts.computePositionOfLineAndCharacter = computePositionOfLineAndCharacter;
5790     function getLineStarts(sourceFile) {
5791         return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text));
5792     }
5793     ts.getLineStarts = getLineStarts;
5794     function computeLineAndCharacterOfPosition(lineStarts, position) {
5795         var lineNumber = computeLineOfPosition(lineStarts, position);
5796         return {
5797             line: lineNumber,
5798             character: position - lineStarts[lineNumber]
5799         };
5800     }
5801     ts.computeLineAndCharacterOfPosition = computeLineAndCharacterOfPosition;
5802     function computeLineOfPosition(lineStarts, position, lowerBound) {
5803         var lineNumber = ts.binarySearch(lineStarts, position, ts.identity, ts.compareValues, lowerBound);
5804         if (lineNumber < 0) {
5805             lineNumber = ~lineNumber - 1;
5806             ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file");
5807         }
5808         return lineNumber;
5809     }
5810     ts.computeLineOfPosition = computeLineOfPosition;
5811     function getLinesBetweenPositions(sourceFile, pos1, pos2) {
5812         if (pos1 === pos2)
5813             return 0;
5814         var lineStarts = getLineStarts(sourceFile);
5815         var lower = Math.min(pos1, pos2);
5816         var isNegative = lower === pos2;
5817         var upper = isNegative ? pos1 : pos2;
5818         var lowerLine = computeLineOfPosition(lineStarts, lower);
5819         var upperLine = computeLineOfPosition(lineStarts, upper, lowerLine);
5820         return isNegative ? lowerLine - upperLine : upperLine - lowerLine;
5821     }
5822     ts.getLinesBetweenPositions = getLinesBetweenPositions;
5823     function getLineAndCharacterOfPosition(sourceFile, position) {
5824         return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position);
5825     }
5826     ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition;
5827     function isWhiteSpaceLike(ch) {
5828         return isWhiteSpaceSingleLine(ch) || isLineBreak(ch);
5829     }
5830     ts.isWhiteSpaceLike = isWhiteSpaceLike;
5831     function isWhiteSpaceSingleLine(ch) {
5832         return ch === 32 ||
5833             ch === 9 ||
5834             ch === 11 ||
5835             ch === 12 ||
5836             ch === 160 ||
5837             ch === 133 ||
5838             ch === 5760 ||
5839             ch >= 8192 && ch <= 8203 ||
5840             ch === 8239 ||
5841             ch === 8287 ||
5842             ch === 12288 ||
5843             ch === 65279;
5844     }
5845     ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine;
5846     function isLineBreak(ch) {
5847         return ch === 10 ||
5848             ch === 13 ||
5849             ch === 8232 ||
5850             ch === 8233;
5851     }
5852     ts.isLineBreak = isLineBreak;
5853     function isDigit(ch) {
5854         return ch >= 48 && ch <= 57;
5855     }
5856     function isHexDigit(ch) {
5857         return isDigit(ch) || ch >= 65 && ch <= 70 || ch >= 97 && ch <= 102;
5858     }
5859     function isCodePoint(code) {
5860         return code <= 0x10FFFF;
5861     }
5862     function isOctalDigit(ch) {
5863         return ch >= 48 && ch <= 55;
5864     }
5865     ts.isOctalDigit = isOctalDigit;
5866     function couldStartTrivia(text, pos) {
5867         var ch = text.charCodeAt(pos);
5868         switch (ch) {
5869             case 13:
5870             case 10:
5871             case 9:
5872             case 11:
5873             case 12:
5874             case 32:
5875             case 47:
5876             case 60:
5877             case 124:
5878             case 61:
5879             case 62:
5880                 return true;
5881             case 35:
5882                 return pos === 0;
5883             default:
5884                 return ch > 127;
5885         }
5886     }
5887     ts.couldStartTrivia = couldStartTrivia;
5888     function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments) {
5889         if (stopAtComments === void 0) { stopAtComments = false; }
5890         if (ts.positionIsSynthesized(pos)) {
5891             return pos;
5892         }
5893         while (true) {
5894             var ch = text.charCodeAt(pos);
5895             switch (ch) {
5896                 case 13:
5897                     if (text.charCodeAt(pos + 1) === 10) {
5898                         pos++;
5899                     }
5900                 case 10:
5901                     pos++;
5902                     if (stopAfterLineBreak) {
5903                         return pos;
5904                     }
5905                     continue;
5906                 case 9:
5907                 case 11:
5908                 case 12:
5909                 case 32:
5910                     pos++;
5911                     continue;
5912                 case 47:
5913                     if (stopAtComments) {
5914                         break;
5915                     }
5916                     if (text.charCodeAt(pos + 1) === 47) {
5917                         pos += 2;
5918                         while (pos < text.length) {
5919                             if (isLineBreak(text.charCodeAt(pos))) {
5920                                 break;
5921                             }
5922                             pos++;
5923                         }
5924                         continue;
5925                     }
5926                     if (text.charCodeAt(pos + 1) === 42) {
5927                         pos += 2;
5928                         while (pos < text.length) {
5929                             if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) {
5930                                 pos += 2;
5931                                 break;
5932                             }
5933                             pos++;
5934                         }
5935                         continue;
5936                     }
5937                     break;
5938                 case 60:
5939                 case 124:
5940                 case 61:
5941                 case 62:
5942                     if (isConflictMarkerTrivia(text, pos)) {
5943                         pos = scanConflictMarkerTrivia(text, pos);
5944                         continue;
5945                     }
5946                     break;
5947                 case 35:
5948                     if (pos === 0 && isShebangTrivia(text, pos)) {
5949                         pos = scanShebangTrivia(text, pos);
5950                         continue;
5951                     }
5952                     break;
5953                 default:
5954                     if (ch > 127 && (isWhiteSpaceLike(ch))) {
5955                         pos++;
5956                         continue;
5957                     }
5958                     break;
5959             }
5960             return pos;
5961         }
5962     }
5963     ts.skipTrivia = skipTrivia;
5964     var mergeConflictMarkerLength = "<<<<<<<".length;
5965     function isConflictMarkerTrivia(text, pos) {
5966         ts.Debug.assert(pos >= 0);
5967         if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) {
5968             var ch = text.charCodeAt(pos);
5969             if ((pos + mergeConflictMarkerLength) < text.length) {
5970                 for (var i = 0; i < mergeConflictMarkerLength; i++) {
5971                     if (text.charCodeAt(pos + i) !== ch) {
5972                         return false;
5973                     }
5974                 }
5975                 return ch === 61 ||
5976                     text.charCodeAt(pos + mergeConflictMarkerLength) === 32;
5977             }
5978         }
5979         return false;
5980     }
5981     function scanConflictMarkerTrivia(text, pos, error) {
5982         if (error) {
5983             error(ts.Diagnostics.Merge_conflict_marker_encountered, pos, mergeConflictMarkerLength);
5984         }
5985         var ch = text.charCodeAt(pos);
5986         var len = text.length;
5987         if (ch === 60 || ch === 62) {
5988             while (pos < len && !isLineBreak(text.charCodeAt(pos))) {
5989                 pos++;
5990             }
5991         }
5992         else {
5993             ts.Debug.assert(ch === 124 || ch === 61);
5994             while (pos < len) {
5995                 var currentChar = text.charCodeAt(pos);
5996                 if ((currentChar === 61 || currentChar === 62) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) {
5997                     break;
5998                 }
5999                 pos++;
6000             }
6001         }
6002         return pos;
6003     }
6004     var shebangTriviaRegex = /^#!.*/;
6005     function isShebangTrivia(text, pos) {
6006         ts.Debug.assert(pos === 0);
6007         return shebangTriviaRegex.test(text);
6008     }
6009     ts.isShebangTrivia = isShebangTrivia;
6010     function scanShebangTrivia(text, pos) {
6011         var shebang = shebangTriviaRegex.exec(text)[0];
6012         pos = pos + shebang.length;
6013         return pos;
6014     }
6015     ts.scanShebangTrivia = scanShebangTrivia;
6016     function iterateCommentRanges(reduce, text, pos, trailing, cb, state, initial) {
6017         var pendingPos;
6018         var pendingEnd;
6019         var pendingKind;
6020         var pendingHasTrailingNewLine;
6021         var hasPendingCommentRange = false;
6022         var collecting = trailing;
6023         var accumulator = initial;
6024         if (pos === 0) {
6025             collecting = true;
6026             var shebang = getShebang(text);
6027             if (shebang) {
6028                 pos = shebang.length;
6029             }
6030         }
6031         scan: while (pos >= 0 && pos < text.length) {
6032             var ch = text.charCodeAt(pos);
6033             switch (ch) {
6034                 case 13:
6035                     if (text.charCodeAt(pos + 1) === 10) {
6036                         pos++;
6037                     }
6038                 case 10:
6039                     pos++;
6040                     if (trailing) {
6041                         break scan;
6042                     }
6043                     collecting = true;
6044                     if (hasPendingCommentRange) {
6045                         pendingHasTrailingNewLine = true;
6046                     }
6047                     continue;
6048                 case 9:
6049                 case 11:
6050                 case 12:
6051                 case 32:
6052                     pos++;
6053                     continue;
6054                 case 47:
6055                     var nextChar = text.charCodeAt(pos + 1);
6056                     var hasTrailingNewLine = false;
6057                     if (nextChar === 47 || nextChar === 42) {
6058                         var kind = nextChar === 47 ? 2 : 3;
6059                         var startPos = pos;
6060                         pos += 2;
6061                         if (nextChar === 47) {
6062                             while (pos < text.length) {
6063                                 if (isLineBreak(text.charCodeAt(pos))) {
6064                                     hasTrailingNewLine = true;
6065                                     break;
6066                                 }
6067                                 pos++;
6068                             }
6069                         }
6070                         else {
6071                             while (pos < text.length) {
6072                                 if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) {
6073                                     pos += 2;
6074                                     break;
6075                                 }
6076                                 pos++;
6077                             }
6078                         }
6079                         if (collecting) {
6080                             if (hasPendingCommentRange) {
6081                                 accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator);
6082                                 if (!reduce && accumulator) {
6083                                     return accumulator;
6084                                 }
6085                             }
6086                             pendingPos = startPos;
6087                             pendingEnd = pos;
6088                             pendingKind = kind;
6089                             pendingHasTrailingNewLine = hasTrailingNewLine;
6090                             hasPendingCommentRange = true;
6091                         }
6092                         continue;
6093                     }
6094                     break scan;
6095                 default:
6096                     if (ch > 127 && (isWhiteSpaceLike(ch))) {
6097                         if (hasPendingCommentRange && isLineBreak(ch)) {
6098                             pendingHasTrailingNewLine = true;
6099                         }
6100                         pos++;
6101                         continue;
6102                     }
6103                     break scan;
6104             }
6105         }
6106         if (hasPendingCommentRange) {
6107             accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator);
6108         }
6109         return accumulator;
6110     }
6111     function forEachLeadingCommentRange(text, pos, cb, state) {
6112         return iterateCommentRanges(false, text, pos, false, cb, state);
6113     }
6114     ts.forEachLeadingCommentRange = forEachLeadingCommentRange;
6115     function forEachTrailingCommentRange(text, pos, cb, state) {
6116         return iterateCommentRanges(false, text, pos, true, cb, state);
6117     }
6118     ts.forEachTrailingCommentRange = forEachTrailingCommentRange;
6119     function reduceEachLeadingCommentRange(text, pos, cb, state, initial) {
6120         return iterateCommentRanges(true, text, pos, false, cb, state, initial);
6121     }
6122     ts.reduceEachLeadingCommentRange = reduceEachLeadingCommentRange;
6123     function reduceEachTrailingCommentRange(text, pos, cb, state, initial) {
6124         return iterateCommentRanges(true, text, pos, true, cb, state, initial);
6125     }
6126     ts.reduceEachTrailingCommentRange = reduceEachTrailingCommentRange;
6127     function appendCommentRange(pos, end, kind, hasTrailingNewLine, _state, comments) {
6128         if (!comments) {
6129             comments = [];
6130         }
6131         comments.push({ kind: kind, pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine });
6132         return comments;
6133     }
6134     function getLeadingCommentRanges(text, pos) {
6135         return reduceEachLeadingCommentRange(text, pos, appendCommentRange, undefined, undefined);
6136     }
6137     ts.getLeadingCommentRanges = getLeadingCommentRanges;
6138     function getTrailingCommentRanges(text, pos) {
6139         return reduceEachTrailingCommentRange(text, pos, appendCommentRange, undefined, undefined);
6140     }
6141     ts.getTrailingCommentRanges = getTrailingCommentRanges;
6142     function getShebang(text) {
6143         var match = shebangTriviaRegex.exec(text);
6144         if (match) {
6145             return match[0];
6146         }
6147     }
6148     ts.getShebang = getShebang;
6149     function isIdentifierStart(ch, languageVersion) {
6150         return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 ||
6151             ch === 36 || ch === 95 ||
6152             ch > 127 && isUnicodeIdentifierStart(ch, languageVersion);
6153     }
6154     ts.isIdentifierStart = isIdentifierStart;
6155     function isIdentifierPart(ch, languageVersion, identifierVariant) {
6156         return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 ||
6157             ch >= 48 && ch <= 57 || ch === 36 || ch === 95 ||
6158             (identifierVariant === 1 ? (ch === 45 || ch === 58) : false) ||
6159             ch > 127 && isUnicodeIdentifierPart(ch, languageVersion);
6160     }
6161     ts.isIdentifierPart = isIdentifierPart;
6162     function isIdentifierText(name, languageVersion, identifierVariant) {
6163         var ch = codePointAt(name, 0);
6164         if (!isIdentifierStart(ch, languageVersion)) {
6165             return false;
6166         }
6167         for (var i = charSize(ch); i < name.length; i += charSize(ch)) {
6168             if (!isIdentifierPart(ch = codePointAt(name, i), languageVersion, identifierVariant)) {
6169                 return false;
6170             }
6171         }
6172         return true;
6173     }
6174     ts.isIdentifierText = isIdentifierText;
6175     function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) {
6176         if (languageVariant === void 0) { languageVariant = 0; }
6177         var text = textInitial;
6178         var pos;
6179         var end;
6180         var startPos;
6181         var tokenPos;
6182         var token;
6183         var tokenValue;
6184         var tokenFlags;
6185         var commentDirectives;
6186         var inJSDocType = 0;
6187         setText(text, start, length);
6188         var scanner = {
6189             getStartPos: function () { return startPos; },
6190             getTextPos: function () { return pos; },
6191             getToken: function () { return token; },
6192             getTokenPos: function () { return tokenPos; },
6193             getTokenText: function () { return text.substring(tokenPos, pos); },
6194             getTokenValue: function () { return tokenValue; },
6195             hasUnicodeEscape: function () { return (tokenFlags & 1024) !== 0; },
6196             hasExtendedUnicodeEscape: function () { return (tokenFlags & 8) !== 0; },
6197             hasPrecedingLineBreak: function () { return (tokenFlags & 1) !== 0; },
6198             isIdentifier: function () { return token === 75 || token > 112; },
6199             isReservedWord: function () { return token >= 77 && token <= 112; },
6200             isUnterminated: function () { return (tokenFlags & 4) !== 0; },
6201             getCommentDirectives: function () { return commentDirectives; },
6202             getTokenFlags: function () { return tokenFlags; },
6203             reScanGreaterToken: reScanGreaterToken,
6204             reScanSlashToken: reScanSlashToken,
6205             reScanTemplateToken: reScanTemplateToken,
6206             reScanTemplateHeadOrNoSubstitutionTemplate: reScanTemplateHeadOrNoSubstitutionTemplate,
6207             scanJsxIdentifier: scanJsxIdentifier,
6208             scanJsxAttributeValue: scanJsxAttributeValue,
6209             reScanJsxAttributeValue: reScanJsxAttributeValue,
6210             reScanJsxToken: reScanJsxToken,
6211             reScanLessThanToken: reScanLessThanToken,
6212             reScanQuestionToken: reScanQuestionToken,
6213             scanJsxToken: scanJsxToken,
6214             scanJsDocToken: scanJsDocToken,
6215             scan: scan,
6216             getText: getText,
6217             clearCommentDirectives: clearCommentDirectives,
6218             setText: setText,
6219             setScriptTarget: setScriptTarget,
6220             setLanguageVariant: setLanguageVariant,
6221             setOnError: setOnError,
6222             setTextPos: setTextPos,
6223             setInJSDocType: setInJSDocType,
6224             tryScan: tryScan,
6225             lookAhead: lookAhead,
6226             scanRange: scanRange,
6227         };
6228         if (ts.Debug.isDebugging) {
6229             Object.defineProperty(scanner, "__debugShowCurrentPositionInText", {
6230                 get: function () {
6231                     var text = scanner.getText();
6232                     return text.slice(0, scanner.getStartPos()) + "â•‘" + text.slice(scanner.getStartPos());
6233                 },
6234             });
6235         }
6236         return scanner;
6237         function error(message, errPos, length) {
6238             if (errPos === void 0) { errPos = pos; }
6239             if (onError) {
6240                 var oldPos = pos;
6241                 pos = errPos;
6242                 onError(message, length || 0);
6243                 pos = oldPos;
6244             }
6245         }
6246         function scanNumberFragment() {
6247             var start = pos;
6248             var allowSeparator = false;
6249             var isPreviousTokenSeparator = false;
6250             var result = "";
6251             while (true) {
6252                 var ch = text.charCodeAt(pos);
6253                 if (ch === 95) {
6254                     tokenFlags |= 512;
6255                     if (allowSeparator) {
6256                         allowSeparator = false;
6257                         isPreviousTokenSeparator = true;
6258                         result += text.substring(start, pos);
6259                     }
6260                     else if (isPreviousTokenSeparator) {
6261                         error(ts.Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
6262                     }
6263                     else {
6264                         error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
6265                     }
6266                     pos++;
6267                     start = pos;
6268                     continue;
6269                 }
6270                 if (isDigit(ch)) {
6271                     allowSeparator = true;
6272                     isPreviousTokenSeparator = false;
6273                     pos++;
6274                     continue;
6275                 }
6276                 break;
6277             }
6278             if (text.charCodeAt(pos - 1) === 95) {
6279                 error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
6280             }
6281             return result + text.substring(start, pos);
6282         }
6283         function scanNumber() {
6284             var start = pos;
6285             var mainFragment = scanNumberFragment();
6286             var decimalFragment;
6287             var scientificFragment;
6288             if (text.charCodeAt(pos) === 46) {
6289                 pos++;
6290                 decimalFragment = scanNumberFragment();
6291             }
6292             var end = pos;
6293             if (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101) {
6294                 pos++;
6295                 tokenFlags |= 16;
6296                 if (text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45)
6297                     pos++;
6298                 var preNumericPart = pos;
6299                 var finalFragment = scanNumberFragment();
6300                 if (!finalFragment) {
6301                     error(ts.Diagnostics.Digit_expected);
6302                 }
6303                 else {
6304                     scientificFragment = text.substring(end, preNumericPart) + finalFragment;
6305                     end = pos;
6306                 }
6307             }
6308             var result;
6309             if (tokenFlags & 512) {
6310                 result = mainFragment;
6311                 if (decimalFragment) {
6312                     result += "." + decimalFragment;
6313                 }
6314                 if (scientificFragment) {
6315                     result += scientificFragment;
6316                 }
6317             }
6318             else {
6319                 result = text.substring(start, end);
6320             }
6321             if (decimalFragment !== undefined || tokenFlags & 16) {
6322                 checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16));
6323                 return {
6324                     type: 8,
6325                     value: "" + +result
6326                 };
6327             }
6328             else {
6329                 tokenValue = result;
6330                 var type = checkBigIntSuffix();
6331                 checkForIdentifierStartAfterNumericLiteral(start);
6332                 return { type: type, value: tokenValue };
6333             }
6334         }
6335         function checkForIdentifierStartAfterNumericLiteral(numericStart, isScientific) {
6336             if (!isIdentifierStart(codePointAt(text, pos), languageVersion)) {
6337                 return;
6338             }
6339             var identifierStart = pos;
6340             var length = scanIdentifierParts().length;
6341             if (length === 1 && text[identifierStart] === "n") {
6342                 if (isScientific) {
6343                     error(ts.Diagnostics.A_bigint_literal_cannot_use_exponential_notation, numericStart, identifierStart - numericStart + 1);
6344                 }
6345                 else {
6346                     error(ts.Diagnostics.A_bigint_literal_must_be_an_integer, numericStart, identifierStart - numericStart + 1);
6347                 }
6348             }
6349             else {
6350                 error(ts.Diagnostics.An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal, identifierStart, length);
6351                 pos = identifierStart;
6352             }
6353         }
6354         function scanOctalDigits() {
6355             var start = pos;
6356             while (isOctalDigit(text.charCodeAt(pos))) {
6357                 pos++;
6358             }
6359             return +(text.substring(start, pos));
6360         }
6361         function scanExactNumberOfHexDigits(count, canHaveSeparators) {
6362             var valueString = scanHexDigits(count, false, canHaveSeparators);
6363             return valueString ? parseInt(valueString, 16) : -1;
6364         }
6365         function scanMinimumNumberOfHexDigits(count, canHaveSeparators) {
6366             return scanHexDigits(count, true, canHaveSeparators);
6367         }
6368         function scanHexDigits(minCount, scanAsManyAsPossible, canHaveSeparators) {
6369             var valueChars = [];
6370             var allowSeparator = false;
6371             var isPreviousTokenSeparator = false;
6372             while (valueChars.length < minCount || scanAsManyAsPossible) {
6373                 var ch = text.charCodeAt(pos);
6374                 if (canHaveSeparators && ch === 95) {
6375                     tokenFlags |= 512;
6376                     if (allowSeparator) {
6377                         allowSeparator = false;
6378                         isPreviousTokenSeparator = true;
6379                     }
6380                     else if (isPreviousTokenSeparator) {
6381                         error(ts.Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
6382                     }
6383                     else {
6384                         error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
6385                     }
6386                     pos++;
6387                     continue;
6388                 }
6389                 allowSeparator = canHaveSeparators;
6390                 if (ch >= 65 && ch <= 70) {
6391                     ch += 97 - 65;
6392                 }
6393                 else if (!((ch >= 48 && ch <= 57) ||
6394                     (ch >= 97 && ch <= 102))) {
6395                     break;
6396                 }
6397                 valueChars.push(ch);
6398                 pos++;
6399                 isPreviousTokenSeparator = false;
6400             }
6401             if (valueChars.length < minCount) {
6402                 valueChars = [];
6403             }
6404             if (text.charCodeAt(pos - 1) === 95) {
6405                 error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
6406             }
6407             return String.fromCharCode.apply(String, valueChars);
6408         }
6409         function scanString(jsxAttributeString) {
6410             if (jsxAttributeString === void 0) { jsxAttributeString = false; }
6411             var quote = text.charCodeAt(pos);
6412             pos++;
6413             var result = "";
6414             var start = pos;
6415             while (true) {
6416                 if (pos >= end) {
6417                     result += text.substring(start, pos);
6418                     tokenFlags |= 4;
6419                     error(ts.Diagnostics.Unterminated_string_literal);
6420                     break;
6421                 }
6422                 var ch = text.charCodeAt(pos);
6423                 if (ch === quote) {
6424                     result += text.substring(start, pos);
6425                     pos++;
6426                     break;
6427                 }
6428                 if (ch === 92 && !jsxAttributeString) {
6429                     result += text.substring(start, pos);
6430                     result += scanEscapeSequence();
6431                     start = pos;
6432                     continue;
6433                 }
6434                 if (isLineBreak(ch) && !jsxAttributeString) {
6435                     result += text.substring(start, pos);
6436                     tokenFlags |= 4;
6437                     error(ts.Diagnostics.Unterminated_string_literal);
6438                     break;
6439                 }
6440                 pos++;
6441             }
6442             return result;
6443         }
6444         function scanTemplateAndSetTokenValue(isTaggedTemplate) {
6445             var startedWithBacktick = text.charCodeAt(pos) === 96;
6446             pos++;
6447             var start = pos;
6448             var contents = "";
6449             var resultingToken;
6450             while (true) {
6451                 if (pos >= end) {
6452                     contents += text.substring(start, pos);
6453                     tokenFlags |= 4;
6454                     error(ts.Diagnostics.Unterminated_template_literal);
6455                     resultingToken = startedWithBacktick ? 14 : 17;
6456                     break;
6457                 }
6458                 var currChar = text.charCodeAt(pos);
6459                 if (currChar === 96) {
6460                     contents += text.substring(start, pos);
6461                     pos++;
6462                     resultingToken = startedWithBacktick ? 14 : 17;
6463                     break;
6464                 }
6465                 if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) {
6466                     contents += text.substring(start, pos);
6467                     pos += 2;
6468                     resultingToken = startedWithBacktick ? 15 : 16;
6469                     break;
6470                 }
6471                 if (currChar === 92) {
6472                     contents += text.substring(start, pos);
6473                     contents += scanEscapeSequence(isTaggedTemplate);
6474                     start = pos;
6475                     continue;
6476                 }
6477                 if (currChar === 13) {
6478                     contents += text.substring(start, pos);
6479                     pos++;
6480                     if (pos < end && text.charCodeAt(pos) === 10) {
6481                         pos++;
6482                     }
6483                     contents += "\n";
6484                     start = pos;
6485                     continue;
6486                 }
6487                 pos++;
6488             }
6489             ts.Debug.assert(resultingToken !== undefined);
6490             tokenValue = contents;
6491             return resultingToken;
6492         }
6493         function scanEscapeSequence(isTaggedTemplate) {
6494             var start = pos;
6495             pos++;
6496             if (pos >= end) {
6497                 error(ts.Diagnostics.Unexpected_end_of_text);
6498                 return "";
6499             }
6500             var ch = text.charCodeAt(pos);
6501             pos++;
6502             switch (ch) {
6503                 case 48:
6504                     if (isTaggedTemplate && pos < end && isDigit(text.charCodeAt(pos))) {
6505                         pos++;
6506                         tokenFlags |= 2048;
6507                         return text.substring(start, pos);
6508                     }
6509                     return "\0";
6510                 case 98:
6511                     return "\b";
6512                 case 116:
6513                     return "\t";
6514                 case 110:
6515                     return "\n";
6516                 case 118:
6517                     return "\v";
6518                 case 102:
6519                     return "\f";
6520                 case 114:
6521                     return "\r";
6522                 case 39:
6523                     return "\'";
6524                 case 34:
6525                     return "\"";
6526                 case 117:
6527                     if (isTaggedTemplate) {
6528                         for (var escapePos = pos; escapePos < pos + 4; escapePos++) {
6529                             if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123) {
6530                                 pos = escapePos;
6531                                 tokenFlags |= 2048;
6532                                 return text.substring(start, pos);
6533                             }
6534                         }
6535                     }
6536                     if (pos < end && text.charCodeAt(pos) === 123) {
6537                         pos++;
6538                         if (isTaggedTemplate && !isHexDigit(text.charCodeAt(pos))) {
6539                             tokenFlags |= 2048;
6540                             return text.substring(start, pos);
6541                         }
6542                         if (isTaggedTemplate) {
6543                             var savePos = pos;
6544                             var escapedValueString = scanMinimumNumberOfHexDigits(1, false);
6545                             var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
6546                             if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125) {
6547                                 tokenFlags |= 2048;
6548                                 return text.substring(start, pos);
6549                             }
6550                             else {
6551                                 pos = savePos;
6552                             }
6553                         }
6554                         tokenFlags |= 8;
6555                         return scanExtendedUnicodeEscape();
6556                     }
6557                     tokenFlags |= 1024;
6558                     return scanHexadecimalEscape(4);
6559                 case 120:
6560                     if (isTaggedTemplate) {
6561                         if (!isHexDigit(text.charCodeAt(pos))) {
6562                             tokenFlags |= 2048;
6563                             return text.substring(start, pos);
6564                         }
6565                         else if (!isHexDigit(text.charCodeAt(pos + 1))) {
6566                             pos++;
6567                             tokenFlags |= 2048;
6568                             return text.substring(start, pos);
6569                         }
6570                     }
6571                     return scanHexadecimalEscape(2);
6572                 case 13:
6573                     if (pos < end && text.charCodeAt(pos) === 10) {
6574                         pos++;
6575                     }
6576                 case 10:
6577                 case 8232:
6578                 case 8233:
6579                     return "";
6580                 default:
6581                     return String.fromCharCode(ch);
6582             }
6583         }
6584         function scanHexadecimalEscape(numDigits) {
6585             var escapedValue = scanExactNumberOfHexDigits(numDigits, false);
6586             if (escapedValue >= 0) {
6587                 return String.fromCharCode(escapedValue);
6588             }
6589             else {
6590                 error(ts.Diagnostics.Hexadecimal_digit_expected);
6591                 return "";
6592             }
6593         }
6594         function scanExtendedUnicodeEscape() {
6595             var escapedValueString = scanMinimumNumberOfHexDigits(1, false);
6596             var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
6597             var isInvalidExtendedEscape = false;
6598             if (escapedValue < 0) {
6599                 error(ts.Diagnostics.Hexadecimal_digit_expected);
6600                 isInvalidExtendedEscape = true;
6601             }
6602             else if (escapedValue > 0x10FFFF) {
6603                 error(ts.Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive);
6604                 isInvalidExtendedEscape = true;
6605             }
6606             if (pos >= end) {
6607                 error(ts.Diagnostics.Unexpected_end_of_text);
6608                 isInvalidExtendedEscape = true;
6609             }
6610             else if (text.charCodeAt(pos) === 125) {
6611                 pos++;
6612             }
6613             else {
6614                 error(ts.Diagnostics.Unterminated_Unicode_escape_sequence);
6615                 isInvalidExtendedEscape = true;
6616             }
6617             if (isInvalidExtendedEscape) {
6618                 return "";
6619             }
6620             return utf16EncodeAsString(escapedValue);
6621         }
6622         function peekUnicodeEscape() {
6623             if (pos + 5 < end && text.charCodeAt(pos + 1) === 117) {
6624                 var start_1 = pos;
6625                 pos += 2;
6626                 var value = scanExactNumberOfHexDigits(4, false);
6627                 pos = start_1;
6628                 return value;
6629             }
6630             return -1;
6631         }
6632         function peekExtendedUnicodeEscape() {
6633             if (languageVersion >= 2 && codePointAt(text, pos + 1) === 117 && codePointAt(text, pos + 2) === 123) {
6634                 var start_2 = pos;
6635                 pos += 3;
6636                 var escapedValueString = scanMinimumNumberOfHexDigits(1, false);
6637                 var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
6638                 pos = start_2;
6639                 return escapedValue;
6640             }
6641             return -1;
6642         }
6643         function scanIdentifierParts() {
6644             var result = "";
6645             var start = pos;
6646             while (pos < end) {
6647                 var ch = codePointAt(text, pos);
6648                 if (isIdentifierPart(ch, languageVersion)) {
6649                     pos += charSize(ch);
6650                 }
6651                 else if (ch === 92) {
6652                     ch = peekExtendedUnicodeEscape();
6653                     if (ch >= 0 && isIdentifierPart(ch, languageVersion)) {
6654                         pos += 3;
6655                         tokenFlags |= 8;
6656                         result += scanExtendedUnicodeEscape();
6657                         start = pos;
6658                         continue;
6659                     }
6660                     ch = peekUnicodeEscape();
6661                     if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) {
6662                         break;
6663                     }
6664                     tokenFlags |= 1024;
6665                     result += text.substring(start, pos);
6666                     result += utf16EncodeAsString(ch);
6667                     pos += 6;
6668                     start = pos;
6669                 }
6670                 else {
6671                     break;
6672                 }
6673             }
6674             result += text.substring(start, pos);
6675             return result;
6676         }
6677         function getIdentifierToken() {
6678             var len = tokenValue.length;
6679             if (len >= 2 && len <= 11) {
6680                 var ch = tokenValue.charCodeAt(0);
6681                 if (ch >= 97 && ch <= 122) {
6682                     var keyword = textToKeyword.get(tokenValue);
6683                     if (keyword !== undefined) {
6684                         return token = keyword;
6685                     }
6686                 }
6687             }
6688             return token = 75;
6689         }
6690         function scanBinaryOrOctalDigits(base) {
6691             var value = "";
6692             var separatorAllowed = false;
6693             var isPreviousTokenSeparator = false;
6694             while (true) {
6695                 var ch = text.charCodeAt(pos);
6696                 if (ch === 95) {
6697                     tokenFlags |= 512;
6698                     if (separatorAllowed) {
6699                         separatorAllowed = false;
6700                         isPreviousTokenSeparator = true;
6701                     }
6702                     else if (isPreviousTokenSeparator) {
6703                         error(ts.Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
6704                     }
6705                     else {
6706                         error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
6707                     }
6708                     pos++;
6709                     continue;
6710                 }
6711                 separatorAllowed = true;
6712                 if (!isDigit(ch) || ch - 48 >= base) {
6713                     break;
6714                 }
6715                 value += text[pos];
6716                 pos++;
6717                 isPreviousTokenSeparator = false;
6718             }
6719             if (text.charCodeAt(pos - 1) === 95) {
6720                 error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
6721             }
6722             return value;
6723         }
6724         function checkBigIntSuffix() {
6725             if (text.charCodeAt(pos) === 110) {
6726                 tokenValue += "n";
6727                 if (tokenFlags & 384) {
6728                     tokenValue = ts.parsePseudoBigInt(tokenValue) + "n";
6729                 }
6730                 pos++;
6731                 return 9;
6732             }
6733             else {
6734                 var numericValue = tokenFlags & 128
6735                     ? parseInt(tokenValue.slice(2), 2)
6736                     : tokenFlags & 256
6737                         ? parseInt(tokenValue.slice(2), 8)
6738                         : +tokenValue;
6739                 tokenValue = "" + numericValue;
6740                 return 8;
6741             }
6742         }
6743         function scan() {
6744             var _a;
6745             startPos = pos;
6746             tokenFlags = 0;
6747             var asteriskSeen = false;
6748             while (true) {
6749                 tokenPos = pos;
6750                 if (pos >= end) {
6751                     return token = 1;
6752                 }
6753                 var ch = codePointAt(text, pos);
6754                 if (ch === 35 && pos === 0 && isShebangTrivia(text, pos)) {
6755                     pos = scanShebangTrivia(text, pos);
6756                     if (skipTrivia) {
6757                         continue;
6758                     }
6759                     else {
6760                         return token = 6;
6761                     }
6762                 }
6763                 switch (ch) {
6764                     case 10:
6765                     case 13:
6766                         tokenFlags |= 1;
6767                         if (skipTrivia) {
6768                             pos++;
6769                             continue;
6770                         }
6771                         else {
6772                             if (ch === 13 && pos + 1 < end && text.charCodeAt(pos + 1) === 10) {
6773                                 pos += 2;
6774                             }
6775                             else {
6776                                 pos++;
6777                             }
6778                             return token = 4;
6779                         }
6780                     case 9:
6781                     case 11:
6782                     case 12:
6783                     case 32:
6784                     case 160:
6785                     case 5760:
6786                     case 8192:
6787                     case 8193:
6788                     case 8194:
6789                     case 8195:
6790                     case 8196:
6791                     case 8197:
6792                     case 8198:
6793                     case 8199:
6794                     case 8200:
6795                     case 8201:
6796                     case 8202:
6797                     case 8203:
6798                     case 8239:
6799                     case 8287:
6800                     case 12288:
6801                     case 65279:
6802                         if (skipTrivia) {
6803                             pos++;
6804                             continue;
6805                         }
6806                         else {
6807                             while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) {
6808                                 pos++;
6809                             }
6810                             return token = 5;
6811                         }
6812                     case 33:
6813                         if (text.charCodeAt(pos + 1) === 61) {
6814                             if (text.charCodeAt(pos + 2) === 61) {
6815                                 return pos += 3, token = 37;
6816                             }
6817                             return pos += 2, token = 35;
6818                         }
6819                         pos++;
6820                         return token = 53;
6821                     case 34:
6822                     case 39:
6823                         tokenValue = scanString();
6824                         return token = 10;
6825                     case 96:
6826                         return token = scanTemplateAndSetTokenValue(false);
6827                     case 37:
6828                         if (text.charCodeAt(pos + 1) === 61) {
6829                             return pos += 2, token = 68;
6830                         }
6831                         pos++;
6832                         return token = 44;
6833                     case 38:
6834                         if (text.charCodeAt(pos + 1) === 38) {
6835                             return pos += 2, token = 55;
6836                         }
6837                         if (text.charCodeAt(pos + 1) === 61) {
6838                             return pos += 2, token = 72;
6839                         }
6840                         pos++;
6841                         return token = 50;
6842                     case 40:
6843                         pos++;
6844                         return token = 20;
6845                     case 41:
6846                         pos++;
6847                         return token = 21;
6848                     case 42:
6849                         if (text.charCodeAt(pos + 1) === 61) {
6850                             return pos += 2, token = 65;
6851                         }
6852                         if (text.charCodeAt(pos + 1) === 42) {
6853                             if (text.charCodeAt(pos + 2) === 61) {
6854                                 return pos += 3, token = 66;
6855                             }
6856                             return pos += 2, token = 42;
6857                         }
6858                         pos++;
6859                         if (inJSDocType && !asteriskSeen && (tokenFlags & 1)) {
6860                             asteriskSeen = true;
6861                             continue;
6862                         }
6863                         return token = 41;
6864                     case 43:
6865                         if (text.charCodeAt(pos + 1) === 43) {
6866                             return pos += 2, token = 45;
6867                         }
6868                         if (text.charCodeAt(pos + 1) === 61) {
6869                             return pos += 2, token = 63;
6870                         }
6871                         pos++;
6872                         return token = 39;
6873                     case 44:
6874                         pos++;
6875                         return token = 27;
6876                     case 45:
6877                         if (text.charCodeAt(pos + 1) === 45) {
6878                             return pos += 2, token = 46;
6879                         }
6880                         if (text.charCodeAt(pos + 1) === 61) {
6881                             return pos += 2, token = 64;
6882                         }
6883                         pos++;
6884                         return token = 40;
6885                     case 46:
6886                         if (isDigit(text.charCodeAt(pos + 1))) {
6887                             tokenValue = scanNumber().value;
6888                             return token = 8;
6889                         }
6890                         if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) {
6891                             return pos += 3, token = 25;
6892                         }
6893                         pos++;
6894                         return token = 24;
6895                     case 47:
6896                         if (text.charCodeAt(pos + 1) === 47) {
6897                             pos += 2;
6898                             while (pos < end) {
6899                                 if (isLineBreak(text.charCodeAt(pos))) {
6900                                     break;
6901                                 }
6902                                 pos++;
6903                             }
6904                             commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(tokenPos, pos), commentDirectiveRegExSingleLine, tokenPos);
6905                             if (skipTrivia) {
6906                                 continue;
6907                             }
6908                             else {
6909                                 return token = 2;
6910                             }
6911                         }
6912                         if (text.charCodeAt(pos + 1) === 42) {
6913                             pos += 2;
6914                             if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) !== 47) {
6915                                 tokenFlags |= 2;
6916                             }
6917                             var commentClosed = false;
6918                             var lastLineStart = tokenPos;
6919                             while (pos < end) {
6920                                 var ch_1 = text.charCodeAt(pos);
6921                                 if (ch_1 === 42 && text.charCodeAt(pos + 1) === 47) {
6922                                     pos += 2;
6923                                     commentClosed = true;
6924                                     break;
6925                                 }
6926                                 pos++;
6927                                 if (isLineBreak(ch_1)) {
6928                                     lastLineStart = pos;
6929                                     tokenFlags |= 1;
6930                                 }
6931                             }
6932                             commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(lastLineStart, pos), commentDirectiveRegExMultiLine, lastLineStart);
6933                             if (!commentClosed) {
6934                                 error(ts.Diagnostics.Asterisk_Slash_expected);
6935                             }
6936                             if (skipTrivia) {
6937                                 continue;
6938                             }
6939                             else {
6940                                 if (!commentClosed) {
6941                                     tokenFlags |= 4;
6942                                 }
6943                                 return token = 3;
6944                             }
6945                         }
6946                         if (text.charCodeAt(pos + 1) === 61) {
6947                             return pos += 2, token = 67;
6948                         }
6949                         pos++;
6950                         return token = 43;
6951                     case 48:
6952                         if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) {
6953                             pos += 2;
6954                             tokenValue = scanMinimumNumberOfHexDigits(1, true);
6955                             if (!tokenValue) {
6956                                 error(ts.Diagnostics.Hexadecimal_digit_expected);
6957                                 tokenValue = "0";
6958                             }
6959                             tokenValue = "0x" + tokenValue;
6960                             tokenFlags |= 64;
6961                             return token = checkBigIntSuffix();
6962                         }
6963                         else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) {
6964                             pos += 2;
6965                             tokenValue = scanBinaryOrOctalDigits(2);
6966                             if (!tokenValue) {
6967                                 error(ts.Diagnostics.Binary_digit_expected);
6968                                 tokenValue = "0";
6969                             }
6970                             tokenValue = "0b" + tokenValue;
6971                             tokenFlags |= 128;
6972                             return token = checkBigIntSuffix();
6973                         }
6974                         else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) {
6975                             pos += 2;
6976                             tokenValue = scanBinaryOrOctalDigits(8);
6977                             if (!tokenValue) {
6978                                 error(ts.Diagnostics.Octal_digit_expected);
6979                                 tokenValue = "0";
6980                             }
6981                             tokenValue = "0o" + tokenValue;
6982                             tokenFlags |= 256;
6983                             return token = checkBigIntSuffix();
6984                         }
6985                         if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) {
6986                             tokenValue = "" + scanOctalDigits();
6987                             tokenFlags |= 32;
6988                             return token = 8;
6989                         }
6990                     case 49:
6991                     case 50:
6992                     case 51:
6993                     case 52:
6994                     case 53:
6995                     case 54:
6996                     case 55:
6997                     case 56:
6998                     case 57:
6999                         (_a = scanNumber(), token = _a.type, tokenValue = _a.value);
7000                         return token;
7001                     case 58:
7002                         pos++;
7003                         return token = 58;
7004                     case 59:
7005                         pos++;
7006                         return token = 26;
7007                     case 60:
7008                         if (isConflictMarkerTrivia(text, pos)) {
7009                             pos = scanConflictMarkerTrivia(text, pos, error);
7010                             if (skipTrivia) {
7011                                 continue;
7012                             }
7013                             else {
7014                                 return token = 7;
7015                             }
7016                         }
7017                         if (text.charCodeAt(pos + 1) === 60) {
7018                             if (text.charCodeAt(pos + 2) === 61) {
7019                                 return pos += 3, token = 69;
7020                             }
7021                             return pos += 2, token = 47;
7022                         }
7023                         if (text.charCodeAt(pos + 1) === 61) {
7024                             return pos += 2, token = 32;
7025                         }
7026                         if (languageVariant === 1 &&
7027                             text.charCodeAt(pos + 1) === 47 &&
7028                             text.charCodeAt(pos + 2) !== 42) {
7029                             return pos += 2, token = 30;
7030                         }
7031                         pos++;
7032                         return token = 29;
7033                     case 61:
7034                         if (isConflictMarkerTrivia(text, pos)) {
7035                             pos = scanConflictMarkerTrivia(text, pos, error);
7036                             if (skipTrivia) {
7037                                 continue;
7038                             }
7039                             else {
7040                                 return token = 7;
7041                             }
7042                         }
7043                         if (text.charCodeAt(pos + 1) === 61) {
7044                             if (text.charCodeAt(pos + 2) === 61) {
7045                                 return pos += 3, token = 36;
7046                             }
7047                             return pos += 2, token = 34;
7048                         }
7049                         if (text.charCodeAt(pos + 1) === 62) {
7050                             return pos += 2, token = 38;
7051                         }
7052                         pos++;
7053                         return token = 62;
7054                     case 62:
7055                         if (isConflictMarkerTrivia(text, pos)) {
7056                             pos = scanConflictMarkerTrivia(text, pos, error);
7057                             if (skipTrivia) {
7058                                 continue;
7059                             }
7060                             else {
7061                                 return token = 7;
7062                             }
7063                         }
7064                         pos++;
7065                         return token = 31;
7066                     case 63:
7067                         pos++;
7068                         if (text.charCodeAt(pos) === 46 && !isDigit(text.charCodeAt(pos + 1))) {
7069                             pos++;
7070                             return token = 28;
7071                         }
7072                         if (text.charCodeAt(pos) === 63) {
7073                             pos++;
7074                             return token = 60;
7075                         }
7076                         return token = 57;
7077                     case 91:
7078                         pos++;
7079                         return token = 22;
7080                     case 93:
7081                         pos++;
7082                         return token = 23;
7083                     case 94:
7084                         if (text.charCodeAt(pos + 1) === 61) {
7085                             return pos += 2, token = 74;
7086                         }
7087                         pos++;
7088                         return token = 52;
7089                     case 123:
7090                         pos++;
7091                         return token = 18;
7092                     case 124:
7093                         if (isConflictMarkerTrivia(text, pos)) {
7094                             pos = scanConflictMarkerTrivia(text, pos, error);
7095                             if (skipTrivia) {
7096                                 continue;
7097                             }
7098                             else {
7099                                 return token = 7;
7100                             }
7101                         }
7102                         if (text.charCodeAt(pos + 1) === 124) {
7103                             return pos += 2, token = 56;
7104                         }
7105                         if (text.charCodeAt(pos + 1) === 61) {
7106                             return pos += 2, token = 73;
7107                         }
7108                         pos++;
7109                         return token = 51;
7110                     case 125:
7111                         pos++;
7112                         return token = 19;
7113                     case 126:
7114                         pos++;
7115                         return token = 54;
7116                     case 64:
7117                         pos++;
7118                         return token = 59;
7119                     case 92:
7120                         var extendedCookedChar = peekExtendedUnicodeEscape();
7121                         if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) {
7122                             pos += 3;
7123                             tokenFlags |= 8;
7124                             tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts();
7125                             return token = getIdentifierToken();
7126                         }
7127                         var cookedChar = peekUnicodeEscape();
7128                         if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) {
7129                             pos += 6;
7130                             tokenFlags |= 1024;
7131                             tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts();
7132                             return token = getIdentifierToken();
7133                         }
7134                         error(ts.Diagnostics.Invalid_character);
7135                         pos++;
7136                         return token = 0;
7137                     case 35:
7138                         if (pos !== 0 && text[pos + 1] === "!") {
7139                             error(ts.Diagnostics.can_only_be_used_at_the_start_of_a_file);
7140                             pos++;
7141                             return token = 0;
7142                         }
7143                         pos++;
7144                         if (isIdentifierStart(ch = text.charCodeAt(pos), languageVersion)) {
7145                             pos++;
7146                             while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion))
7147                                 pos++;
7148                             tokenValue = text.substring(tokenPos, pos);
7149                             if (ch === 92) {
7150                                 tokenValue += scanIdentifierParts();
7151                             }
7152                         }
7153                         else {
7154                             tokenValue = "#";
7155                             error(ts.Diagnostics.Invalid_character);
7156                         }
7157                         return token = 76;
7158                     default:
7159                         if (isIdentifierStart(ch, languageVersion)) {
7160                             pos += charSize(ch);
7161                             while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion))
7162                                 pos += charSize(ch);
7163                             tokenValue = text.substring(tokenPos, pos);
7164                             if (ch === 92) {
7165                                 tokenValue += scanIdentifierParts();
7166                             }
7167                             return token = getIdentifierToken();
7168                         }
7169                         else if (isWhiteSpaceSingleLine(ch)) {
7170                             pos += charSize(ch);
7171                             continue;
7172                         }
7173                         else if (isLineBreak(ch)) {
7174                             tokenFlags |= 1;
7175                             pos += charSize(ch);
7176                             continue;
7177                         }
7178                         error(ts.Diagnostics.Invalid_character);
7179                         pos += charSize(ch);
7180                         return token = 0;
7181                 }
7182             }
7183         }
7184         function reScanGreaterToken() {
7185             if (token === 31) {
7186                 if (text.charCodeAt(pos) === 62) {
7187                     if (text.charCodeAt(pos + 1) === 62) {
7188                         if (text.charCodeAt(pos + 2) === 61) {
7189                             return pos += 3, token = 71;
7190                         }
7191                         return pos += 2, token = 49;
7192                     }
7193                     if (text.charCodeAt(pos + 1) === 61) {
7194                         return pos += 2, token = 70;
7195                     }
7196                     pos++;
7197                     return token = 48;
7198                 }
7199                 if (text.charCodeAt(pos) === 61) {
7200                     pos++;
7201                     return token = 33;
7202                 }
7203             }
7204             return token;
7205         }
7206         function reScanSlashToken() {
7207             if (token === 43 || token === 67) {
7208                 var p = tokenPos + 1;
7209                 var inEscape = false;
7210                 var inCharacterClass = false;
7211                 while (true) {
7212                     if (p >= end) {
7213                         tokenFlags |= 4;
7214                         error(ts.Diagnostics.Unterminated_regular_expression_literal);
7215                         break;
7216                     }
7217                     var ch = text.charCodeAt(p);
7218                     if (isLineBreak(ch)) {
7219                         tokenFlags |= 4;
7220                         error(ts.Diagnostics.Unterminated_regular_expression_literal);
7221                         break;
7222                     }
7223                     if (inEscape) {
7224                         inEscape = false;
7225                     }
7226                     else if (ch === 47 && !inCharacterClass) {
7227                         p++;
7228                         break;
7229                     }
7230                     else if (ch === 91) {
7231                         inCharacterClass = true;
7232                     }
7233                     else if (ch === 92) {
7234                         inEscape = true;
7235                     }
7236                     else if (ch === 93) {
7237                         inCharacterClass = false;
7238                     }
7239                     p++;
7240                 }
7241                 while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) {
7242                     p++;
7243                 }
7244                 pos = p;
7245                 tokenValue = text.substring(tokenPos, pos);
7246                 token = 13;
7247             }
7248             return token;
7249         }
7250         function appendIfCommentDirective(commentDirectives, text, commentDirectiveRegEx, lineStart) {
7251             var type = getDirectiveFromComment(text, commentDirectiveRegEx);
7252             if (type === undefined) {
7253                 return commentDirectives;
7254             }
7255             return ts.append(commentDirectives, {
7256                 range: { pos: lineStart, end: pos },
7257                 type: type,
7258             });
7259         }
7260         function getDirectiveFromComment(text, commentDirectiveRegEx) {
7261             var match = commentDirectiveRegEx.exec(text);
7262             if (!match) {
7263                 return undefined;
7264             }
7265             switch (match[1]) {
7266                 case "ts-expect-error":
7267                     return 0;
7268                 case "ts-ignore":
7269                     return 1;
7270             }
7271             return undefined;
7272         }
7273         function reScanTemplateToken(isTaggedTemplate) {
7274             ts.Debug.assert(token === 19, "'reScanTemplateToken' should only be called on a '}'");
7275             pos = tokenPos;
7276             return token = scanTemplateAndSetTokenValue(isTaggedTemplate);
7277         }
7278         function reScanTemplateHeadOrNoSubstitutionTemplate() {
7279             pos = tokenPos;
7280             return token = scanTemplateAndSetTokenValue(true);
7281         }
7282         function reScanJsxToken() {
7283             pos = tokenPos = startPos;
7284             return token = scanJsxToken();
7285         }
7286         function reScanLessThanToken() {
7287             if (token === 47) {
7288                 pos = tokenPos + 1;
7289                 return token = 29;
7290             }
7291             return token;
7292         }
7293         function reScanQuestionToken() {
7294             ts.Debug.assert(token === 60, "'reScanQuestionToken' should only be called on a '??'");
7295             pos = tokenPos + 1;
7296             return token = 57;
7297         }
7298         function scanJsxToken() {
7299             startPos = tokenPos = pos;
7300             if (pos >= end) {
7301                 return token = 1;
7302             }
7303             var char = text.charCodeAt(pos);
7304             if (char === 60) {
7305                 if (text.charCodeAt(pos + 1) === 47) {
7306                     pos += 2;
7307                     return token = 30;
7308                 }
7309                 pos++;
7310                 return token = 29;
7311             }
7312             if (char === 123) {
7313                 pos++;
7314                 return token = 18;
7315             }
7316             var firstNonWhitespace = 0;
7317             var lastNonWhitespace = -1;
7318             while (pos < end) {
7319                 if (!isWhiteSpaceSingleLine(char)) {
7320                     lastNonWhitespace = pos;
7321                 }
7322                 char = text.charCodeAt(pos);
7323                 if (char === 123) {
7324                     break;
7325                 }
7326                 if (char === 60) {
7327                     if (isConflictMarkerTrivia(text, pos)) {
7328                         pos = scanConflictMarkerTrivia(text, pos, error);
7329                         return token = 7;
7330                     }
7331                     break;
7332                 }
7333                 if (char === 62) {
7334                     error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_gt, pos, 1);
7335                 }
7336                 if (char === 125) {
7337                     error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1);
7338                 }
7339                 if (lastNonWhitespace > 0)
7340                     lastNonWhitespace++;
7341                 if (isLineBreak(char) && firstNonWhitespace === 0) {
7342                     firstNonWhitespace = -1;
7343                 }
7344                 else if (!isWhiteSpaceLike(char)) {
7345                     firstNonWhitespace = pos;
7346                 }
7347                 pos++;
7348             }
7349             var endPosition = lastNonWhitespace === -1 ? pos : lastNonWhitespace;
7350             tokenValue = text.substring(startPos, endPosition);
7351             return firstNonWhitespace === -1 ? 12 : 11;
7352         }
7353         function scanJsxIdentifier() {
7354             if (tokenIsIdentifierOrKeyword(token)) {
7355                 while (pos < end) {
7356                     var ch = text.charCodeAt(pos);
7357                     if (ch === 45) {
7358                         tokenValue += "-";
7359                         pos++;
7360                         continue;
7361                     }
7362                     var oldPos = pos;
7363                     tokenValue += scanIdentifierParts();
7364                     if (pos === oldPos) {
7365                         break;
7366                     }
7367                 }
7368             }
7369             return token;
7370         }
7371         function scanJsxAttributeValue() {
7372             startPos = pos;
7373             switch (text.charCodeAt(pos)) {
7374                 case 34:
7375                 case 39:
7376                     tokenValue = scanString(true);
7377                     return token = 10;
7378                 default:
7379                     return scan();
7380             }
7381         }
7382         function reScanJsxAttributeValue() {
7383             pos = tokenPos = startPos;
7384             return scanJsxAttributeValue();
7385         }
7386         function scanJsDocToken() {
7387             startPos = tokenPos = pos;
7388             tokenFlags = 0;
7389             if (pos >= end) {
7390                 return token = 1;
7391             }
7392             var ch = codePointAt(text, pos);
7393             pos += charSize(ch);
7394             switch (ch) {
7395                 case 9:
7396                 case 11:
7397                 case 12:
7398                 case 32:
7399                     while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) {
7400                         pos++;
7401                     }
7402                     return token = 5;
7403                 case 64:
7404                     return token = 59;
7405                 case 10:
7406                 case 13:
7407                     tokenFlags |= 1;
7408                     return token = 4;
7409                 case 42:
7410                     return token = 41;
7411                 case 123:
7412                     return token = 18;
7413                 case 125:
7414                     return token = 19;
7415                 case 91:
7416                     return token = 22;
7417                 case 93:
7418                     return token = 23;
7419                 case 60:
7420                     return token = 29;
7421                 case 62:
7422                     return token = 31;
7423                 case 61:
7424                     return token = 62;
7425                 case 44:
7426                     return token = 27;
7427                 case 46:
7428                     return token = 24;
7429                 case 96:
7430                     return token = 61;
7431                 case 92:
7432                     pos--;
7433                     var extendedCookedChar = peekExtendedUnicodeEscape();
7434                     if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) {
7435                         pos += 3;
7436                         tokenFlags |= 8;
7437                         tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts();
7438                         return token = getIdentifierToken();
7439                     }
7440                     var cookedChar = peekUnicodeEscape();
7441                     if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) {
7442                         pos += 6;
7443                         tokenFlags |= 1024;
7444                         tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts();
7445                         return token = getIdentifierToken();
7446                     }
7447                     pos++;
7448                     return token = 0;
7449             }
7450             if (isIdentifierStart(ch, languageVersion)) {
7451                 var char = ch;
7452                 while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45)
7453                     pos += charSize(char);
7454                 tokenValue = text.substring(tokenPos, pos);
7455                 if (char === 92) {
7456                     tokenValue += scanIdentifierParts();
7457                 }
7458                 return token = getIdentifierToken();
7459             }
7460             else {
7461                 return token = 0;
7462             }
7463         }
7464         function speculationHelper(callback, isLookahead) {
7465             var savePos = pos;
7466             var saveStartPos = startPos;
7467             var saveTokenPos = tokenPos;
7468             var saveToken = token;
7469             var saveTokenValue = tokenValue;
7470             var saveTokenFlags = tokenFlags;
7471             var result = callback();
7472             if (!result || isLookahead) {
7473                 pos = savePos;
7474                 startPos = saveStartPos;
7475                 tokenPos = saveTokenPos;
7476                 token = saveToken;
7477                 tokenValue = saveTokenValue;
7478                 tokenFlags = saveTokenFlags;
7479             }
7480             return result;
7481         }
7482         function scanRange(start, length, callback) {
7483             var saveEnd = end;
7484             var savePos = pos;
7485             var saveStartPos = startPos;
7486             var saveTokenPos = tokenPos;
7487             var saveToken = token;
7488             var saveTokenValue = tokenValue;
7489             var saveTokenFlags = tokenFlags;
7490             var saveErrorExpectations = commentDirectives;
7491             setText(text, start, length);
7492             var result = callback();
7493             end = saveEnd;
7494             pos = savePos;
7495             startPos = saveStartPos;
7496             tokenPos = saveTokenPos;
7497             token = saveToken;
7498             tokenValue = saveTokenValue;
7499             tokenFlags = saveTokenFlags;
7500             commentDirectives = saveErrorExpectations;
7501             return result;
7502         }
7503         function lookAhead(callback) {
7504             return speculationHelper(callback, true);
7505         }
7506         function tryScan(callback) {
7507             return speculationHelper(callback, false);
7508         }
7509         function getText() {
7510             return text;
7511         }
7512         function clearCommentDirectives() {
7513             commentDirectives = undefined;
7514         }
7515         function setText(newText, start, length) {
7516             text = newText || "";
7517             end = length === undefined ? text.length : start + length;
7518             setTextPos(start || 0);
7519         }
7520         function setOnError(errorCallback) {
7521             onError = errorCallback;
7522         }
7523         function setScriptTarget(scriptTarget) {
7524             languageVersion = scriptTarget;
7525         }
7526         function setLanguageVariant(variant) {
7527             languageVariant = variant;
7528         }
7529         function setTextPos(textPos) {
7530             ts.Debug.assert(textPos >= 0);
7531             pos = textPos;
7532             startPos = textPos;
7533             tokenPos = textPos;
7534             token = 0;
7535             tokenValue = undefined;
7536             tokenFlags = 0;
7537         }
7538         function setInJSDocType(inType) {
7539             inJSDocType += inType ? 1 : -1;
7540         }
7541     }
7542     ts.createScanner = createScanner;
7543     var codePointAt = String.prototype.codePointAt ? function (s, i) { return s.codePointAt(i); } : function codePointAt(str, i) {
7544         var size = str.length;
7545         if (i < 0 || i >= size) {
7546             return undefined;
7547         }
7548         var first = str.charCodeAt(i);
7549         if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) {
7550             var second = str.charCodeAt(i + 1);
7551             if (second >= 0xDC00 && second <= 0xDFFF) {
7552                 return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
7553             }
7554         }
7555         return first;
7556     };
7557     function charSize(ch) {
7558         if (ch >= 0x10000) {
7559             return 2;
7560         }
7561         return 1;
7562     }
7563     function utf16EncodeAsStringFallback(codePoint) {
7564         ts.Debug.assert(0x0 <= codePoint && codePoint <= 0x10FFFF);
7565         if (codePoint <= 65535) {
7566             return String.fromCharCode(codePoint);
7567         }
7568         var codeUnit1 = Math.floor((codePoint - 65536) / 1024) + 0xD800;
7569         var codeUnit2 = ((codePoint - 65536) % 1024) + 0xDC00;
7570         return String.fromCharCode(codeUnit1, codeUnit2);
7571     }
7572     var utf16EncodeAsStringWorker = String.fromCodePoint ? function (codePoint) { return String.fromCodePoint(codePoint); } : utf16EncodeAsStringFallback;
7573     function utf16EncodeAsString(codePoint) {
7574         return utf16EncodeAsStringWorker(codePoint);
7575     }
7576     ts.utf16EncodeAsString = utf16EncodeAsString;
7577 })(ts || (ts = {}));
7578 var ts;
7579 (function (ts) {
7580     function isExternalModuleNameRelative(moduleName) {
7581         return ts.pathIsRelative(moduleName) || ts.isRootedDiskPath(moduleName);
7582     }
7583     ts.isExternalModuleNameRelative = isExternalModuleNameRelative;
7584     function sortAndDeduplicateDiagnostics(diagnostics) {
7585         return ts.sortAndDeduplicate(diagnostics, ts.compareDiagnostics);
7586     }
7587     ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics;
7588     function getDefaultLibFileName(options) {
7589         switch (options.target) {
7590             case 99:
7591                 return "lib.esnext.full.d.ts";
7592             case 7:
7593                 return "lib.es2020.full.d.ts";
7594             case 6:
7595                 return "lib.es2019.full.d.ts";
7596             case 5:
7597                 return "lib.es2018.full.d.ts";
7598             case 4:
7599                 return "lib.es2017.full.d.ts";
7600             case 3:
7601                 return "lib.es2016.full.d.ts";
7602             case 2:
7603                 return "lib.es6.d.ts";
7604             default:
7605                 return "lib.d.ts";
7606         }
7607     }
7608     ts.getDefaultLibFileName = getDefaultLibFileName;
7609     function textSpanEnd(span) {
7610         return span.start + span.length;
7611     }
7612     ts.textSpanEnd = textSpanEnd;
7613     function textSpanIsEmpty(span) {
7614         return span.length === 0;
7615     }
7616     ts.textSpanIsEmpty = textSpanIsEmpty;
7617     function textSpanContainsPosition(span, position) {
7618         return position >= span.start && position < textSpanEnd(span);
7619     }
7620     ts.textSpanContainsPosition = textSpanContainsPosition;
7621     function textRangeContainsPositionInclusive(span, position) {
7622         return position >= span.pos && position <= span.end;
7623     }
7624     ts.textRangeContainsPositionInclusive = textRangeContainsPositionInclusive;
7625     function textSpanContainsTextSpan(span, other) {
7626         return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span);
7627     }
7628     ts.textSpanContainsTextSpan = textSpanContainsTextSpan;
7629     function textSpanOverlapsWith(span, other) {
7630         return textSpanOverlap(span, other) !== undefined;
7631     }
7632     ts.textSpanOverlapsWith = textSpanOverlapsWith;
7633     function textSpanOverlap(span1, span2) {
7634         var overlap = textSpanIntersection(span1, span2);
7635         return overlap && overlap.length === 0 ? undefined : overlap;
7636     }
7637     ts.textSpanOverlap = textSpanOverlap;
7638     function textSpanIntersectsWithTextSpan(span, other) {
7639         return decodedTextSpanIntersectsWith(span.start, span.length, other.start, other.length);
7640     }
7641     ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan;
7642     function textSpanIntersectsWith(span, start, length) {
7643         return decodedTextSpanIntersectsWith(span.start, span.length, start, length);
7644     }
7645     ts.textSpanIntersectsWith = textSpanIntersectsWith;
7646     function decodedTextSpanIntersectsWith(start1, length1, start2, length2) {
7647         var end1 = start1 + length1;
7648         var end2 = start2 + length2;
7649         return start2 <= end1 && end2 >= start1;
7650     }
7651     ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith;
7652     function textSpanIntersectsWithPosition(span, position) {
7653         return position <= textSpanEnd(span) && position >= span.start;
7654     }
7655     ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition;
7656     function textSpanIntersection(span1, span2) {
7657         var start = Math.max(span1.start, span2.start);
7658         var end = Math.min(textSpanEnd(span1), textSpanEnd(span2));
7659         return start <= end ? createTextSpanFromBounds(start, end) : undefined;
7660     }
7661     ts.textSpanIntersection = textSpanIntersection;
7662     function createTextSpan(start, length) {
7663         if (start < 0) {
7664             throw new Error("start < 0");
7665         }
7666         if (length < 0) {
7667             throw new Error("length < 0");
7668         }
7669         return { start: start, length: length };
7670     }
7671     ts.createTextSpan = createTextSpan;
7672     function createTextSpanFromBounds(start, end) {
7673         return createTextSpan(start, end - start);
7674     }
7675     ts.createTextSpanFromBounds = createTextSpanFromBounds;
7676     function textChangeRangeNewSpan(range) {
7677         return createTextSpan(range.span.start, range.newLength);
7678     }
7679     ts.textChangeRangeNewSpan = textChangeRangeNewSpan;
7680     function textChangeRangeIsUnchanged(range) {
7681         return textSpanIsEmpty(range.span) && range.newLength === 0;
7682     }
7683     ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged;
7684     function createTextChangeRange(span, newLength) {
7685         if (newLength < 0) {
7686             throw new Error("newLength < 0");
7687         }
7688         return { span: span, newLength: newLength };
7689     }
7690     ts.createTextChangeRange = createTextChangeRange;
7691     ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
7692     function collapseTextChangeRangesAcrossMultipleVersions(changes) {
7693         if (changes.length === 0) {
7694             return ts.unchangedTextChangeRange;
7695         }
7696         if (changes.length === 1) {
7697             return changes[0];
7698         }
7699         var change0 = changes[0];
7700         var oldStartN = change0.span.start;
7701         var oldEndN = textSpanEnd(change0.span);
7702         var newEndN = oldStartN + change0.newLength;
7703         for (var i = 1; i < changes.length; i++) {
7704             var nextChange = changes[i];
7705             var oldStart1 = oldStartN;
7706             var oldEnd1 = oldEndN;
7707             var newEnd1 = newEndN;
7708             var oldStart2 = nextChange.span.start;
7709             var oldEnd2 = textSpanEnd(nextChange.span);
7710             var newEnd2 = oldStart2 + nextChange.newLength;
7711             oldStartN = Math.min(oldStart1, oldStart2);
7712             oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1));
7713             newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2));
7714         }
7715         return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN);
7716     }
7717     ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions;
7718     function getTypeParameterOwner(d) {
7719         if (d && d.kind === 155) {
7720             for (var current = d; current; current = current.parent) {
7721                 if (isFunctionLike(current) || isClassLike(current) || current.kind === 246) {
7722                     return current;
7723                 }
7724             }
7725         }
7726     }
7727     ts.getTypeParameterOwner = getTypeParameterOwner;
7728     function isParameterPropertyDeclaration(node, parent) {
7729         return ts.hasModifier(node, 92) && parent.kind === 162;
7730     }
7731     ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration;
7732     function isEmptyBindingPattern(node) {
7733         if (isBindingPattern(node)) {
7734             return ts.every(node.elements, isEmptyBindingElement);
7735         }
7736         return false;
7737     }
7738     ts.isEmptyBindingPattern = isEmptyBindingPattern;
7739     function isEmptyBindingElement(node) {
7740         if (isOmittedExpression(node)) {
7741             return true;
7742         }
7743         return isEmptyBindingPattern(node.name);
7744     }
7745     ts.isEmptyBindingElement = isEmptyBindingElement;
7746     function walkUpBindingElementsAndPatterns(binding) {
7747         var node = binding.parent;
7748         while (isBindingElement(node.parent)) {
7749             node = node.parent.parent;
7750         }
7751         return node.parent;
7752     }
7753     ts.walkUpBindingElementsAndPatterns = walkUpBindingElementsAndPatterns;
7754     function getCombinedFlags(node, getFlags) {
7755         if (isBindingElement(node)) {
7756             node = walkUpBindingElementsAndPatterns(node);
7757         }
7758         var flags = getFlags(node);
7759         if (node.kind === 242) {
7760             node = node.parent;
7761         }
7762         if (node && node.kind === 243) {
7763             flags |= getFlags(node);
7764             node = node.parent;
7765         }
7766         if (node && node.kind === 225) {
7767             flags |= getFlags(node);
7768         }
7769         return flags;
7770     }
7771     function getCombinedModifierFlags(node) {
7772         return getCombinedFlags(node, ts.getModifierFlags);
7773     }
7774     ts.getCombinedModifierFlags = getCombinedModifierFlags;
7775     function getCombinedNodeFlags(node) {
7776         return getCombinedFlags(node, function (n) { return n.flags; });
7777     }
7778     ts.getCombinedNodeFlags = getCombinedNodeFlags;
7779     function validateLocaleAndSetLanguage(locale, sys, errors) {
7780         var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase());
7781         if (!matchResult) {
7782             if (errors) {
7783                 errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp"));
7784             }
7785             return;
7786         }
7787         var language = matchResult[1];
7788         var territory = matchResult[3];
7789         if (!trySetLanguageAndTerritory(language, territory, errors)) {
7790             trySetLanguageAndTerritory(language, undefined, errors);
7791         }
7792         ts.setUILocale(locale);
7793         function trySetLanguageAndTerritory(language, territory, errors) {
7794             var compilerFilePath = ts.normalizePath(sys.getExecutingFilePath());
7795             var containingDirectoryPath = ts.getDirectoryPath(compilerFilePath);
7796             var filePath = ts.combinePaths(containingDirectoryPath, language);
7797             if (territory) {
7798                 filePath = filePath + "-" + territory;
7799             }
7800             filePath = sys.resolvePath(ts.combinePaths(filePath, "diagnosticMessages.generated.json"));
7801             if (!sys.fileExists(filePath)) {
7802                 return false;
7803             }
7804             var fileContents = "";
7805             try {
7806                 fileContents = sys.readFile(filePath);
7807             }
7808             catch (e) {
7809                 if (errors) {
7810                     errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unable_to_open_file_0, filePath));
7811                 }
7812                 return false;
7813             }
7814             try {
7815                 ts.setLocalizedDiagnosticMessages(JSON.parse(fileContents));
7816             }
7817             catch (_a) {
7818                 if (errors) {
7819                     errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Corrupted_locale_file_0, filePath));
7820                 }
7821                 return false;
7822             }
7823             return true;
7824         }
7825     }
7826     ts.validateLocaleAndSetLanguage = validateLocaleAndSetLanguage;
7827     function getOriginalNode(node, nodeTest) {
7828         if (node) {
7829             while (node.original !== undefined) {
7830                 node = node.original;
7831             }
7832         }
7833         return !nodeTest || nodeTest(node) ? node : undefined;
7834     }
7835     ts.getOriginalNode = getOriginalNode;
7836     function isParseTreeNode(node) {
7837         return (node.flags & 8) === 0;
7838     }
7839     ts.isParseTreeNode = isParseTreeNode;
7840     function getParseTreeNode(node, nodeTest) {
7841         if (node === undefined || isParseTreeNode(node)) {
7842             return node;
7843         }
7844         node = getOriginalNode(node);
7845         if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) {
7846             return node;
7847         }
7848         return undefined;
7849     }
7850     ts.getParseTreeNode = getParseTreeNode;
7851     function escapeLeadingUnderscores(identifier) {
7852         return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier);
7853     }
7854     ts.escapeLeadingUnderscores = escapeLeadingUnderscores;
7855     function unescapeLeadingUnderscores(identifier) {
7856         var id = identifier;
7857         return id.length >= 3 && id.charCodeAt(0) === 95 && id.charCodeAt(1) === 95 && id.charCodeAt(2) === 95 ? id.substr(1) : id;
7858     }
7859     ts.unescapeLeadingUnderscores = unescapeLeadingUnderscores;
7860     function idText(identifierOrPrivateName) {
7861         return unescapeLeadingUnderscores(identifierOrPrivateName.escapedText);
7862     }
7863     ts.idText = idText;
7864     function symbolName(symbol) {
7865         if (symbol.valueDeclaration && isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) {
7866             return idText(symbol.valueDeclaration.name);
7867         }
7868         return unescapeLeadingUnderscores(symbol.escapedName);
7869     }
7870     ts.symbolName = symbolName;
7871     function nameForNamelessJSDocTypedef(declaration) {
7872         var hostNode = declaration.parent.parent;
7873         if (!hostNode) {
7874             return undefined;
7875         }
7876         if (isDeclaration(hostNode)) {
7877             return getDeclarationIdentifier(hostNode);
7878         }
7879         switch (hostNode.kind) {
7880             case 225:
7881                 if (hostNode.declarationList && hostNode.declarationList.declarations[0]) {
7882                     return getDeclarationIdentifier(hostNode.declarationList.declarations[0]);
7883                 }
7884                 break;
7885             case 226:
7886                 var expr = hostNode.expression;
7887                 if (expr.kind === 209 && expr.operatorToken.kind === 62) {
7888                     expr = expr.left;
7889                 }
7890                 switch (expr.kind) {
7891                     case 194:
7892                         return expr.name;
7893                     case 195:
7894                         var arg = expr.argumentExpression;
7895                         if (isIdentifier(arg)) {
7896                             return arg;
7897                         }
7898                 }
7899                 break;
7900             case 200: {
7901                 return getDeclarationIdentifier(hostNode.expression);
7902             }
7903             case 238: {
7904                 if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) {
7905                     return getDeclarationIdentifier(hostNode.statement);
7906                 }
7907                 break;
7908             }
7909         }
7910     }
7911     function getDeclarationIdentifier(node) {
7912         var name = getNameOfDeclaration(node);
7913         return name && isIdentifier(name) ? name : undefined;
7914     }
7915     function nodeHasName(statement, name) {
7916         if (isNamedDeclaration(statement) && isIdentifier(statement.name) && idText(statement.name) === idText(name)) {
7917             return true;
7918         }
7919         if (isVariableStatement(statement) && ts.some(statement.declarationList.declarations, function (d) { return nodeHasName(d, name); })) {
7920             return true;
7921         }
7922         return false;
7923     }
7924     ts.nodeHasName = nodeHasName;
7925     function getNameOfJSDocTypedef(declaration) {
7926         return declaration.name || nameForNamelessJSDocTypedef(declaration);
7927     }
7928     ts.getNameOfJSDocTypedef = getNameOfJSDocTypedef;
7929     function isNamedDeclaration(node) {
7930         return !!node.name;
7931     }
7932     ts.isNamedDeclaration = isNamedDeclaration;
7933     function getNonAssignedNameOfDeclaration(declaration) {
7934         switch (declaration.kind) {
7935             case 75:
7936                 return declaration;
7937             case 323:
7938             case 317: {
7939                 var name = declaration.name;
7940                 if (name.kind === 153) {
7941                     return name.right;
7942                 }
7943                 break;
7944             }
7945             case 196:
7946             case 209: {
7947                 var expr_1 = declaration;
7948                 switch (ts.getAssignmentDeclarationKind(expr_1)) {
7949                     case 1:
7950                     case 4:
7951                     case 5:
7952                     case 3:
7953                         return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left);
7954                     case 7:
7955                     case 8:
7956                     case 9:
7957                         return expr_1.arguments[1];
7958                     default:
7959                         return undefined;
7960                 }
7961             }
7962             case 322:
7963                 return getNameOfJSDocTypedef(declaration);
7964             case 316:
7965                 return nameForNamelessJSDocTypedef(declaration);
7966             case 259: {
7967                 var expression = declaration.expression;
7968                 return isIdentifier(expression) ? expression : undefined;
7969             }
7970             case 195:
7971                 var expr = declaration;
7972                 if (ts.isBindableStaticElementAccessExpression(expr)) {
7973                     return expr.argumentExpression;
7974                 }
7975         }
7976         return declaration.name;
7977     }
7978     ts.getNonAssignedNameOfDeclaration = getNonAssignedNameOfDeclaration;
7979     function getNameOfDeclaration(declaration) {
7980         if (declaration === undefined)
7981             return undefined;
7982         return getNonAssignedNameOfDeclaration(declaration) ||
7983             (isFunctionExpression(declaration) || isClassExpression(declaration) ? getAssignedName(declaration) : undefined);
7984     }
7985     ts.getNameOfDeclaration = getNameOfDeclaration;
7986     function getAssignedName(node) {
7987         if (!node.parent) {
7988             return undefined;
7989         }
7990         else if (isPropertyAssignment(node.parent) || isBindingElement(node.parent)) {
7991             return node.parent.name;
7992         }
7993         else if (isBinaryExpression(node.parent) && node === node.parent.right) {
7994             if (isIdentifier(node.parent.left)) {
7995                 return node.parent.left;
7996             }
7997             else if (ts.isAccessExpression(node.parent.left)) {
7998                 return ts.getElementOrPropertyAccessArgumentExpressionOrName(node.parent.left);
7999             }
8000         }
8001         else if (isVariableDeclaration(node.parent) && isIdentifier(node.parent.name)) {
8002             return node.parent.name;
8003         }
8004     }
8005     function getJSDocParameterTags(param) {
8006         if (param.name) {
8007             if (isIdentifier(param.name)) {
8008                 var name_1 = param.name.escapedText;
8009                 return getJSDocTags(param.parent).filter(function (tag) { return isJSDocParameterTag(tag) && isIdentifier(tag.name) && tag.name.escapedText === name_1; });
8010             }
8011             else {
8012                 var i = param.parent.parameters.indexOf(param);
8013                 ts.Debug.assert(i > -1, "Parameters should always be in their parents' parameter list");
8014                 var paramTags = getJSDocTags(param.parent).filter(isJSDocParameterTag);
8015                 if (i < paramTags.length) {
8016                     return [paramTags[i]];
8017                 }
8018             }
8019         }
8020         return ts.emptyArray;
8021     }
8022     ts.getJSDocParameterTags = getJSDocParameterTags;
8023     function getJSDocTypeParameterTags(param) {
8024         var name = param.name.escapedText;
8025         return getJSDocTags(param.parent).filter(function (tag) {
8026             return isJSDocTemplateTag(tag) && tag.typeParameters.some(function (tp) { return tp.name.escapedText === name; });
8027         });
8028     }
8029     ts.getJSDocTypeParameterTags = getJSDocTypeParameterTags;
8030     function hasJSDocParameterTags(node) {
8031         return !!getFirstJSDocTag(node, isJSDocParameterTag);
8032     }
8033     ts.hasJSDocParameterTags = hasJSDocParameterTags;
8034     function getJSDocAugmentsTag(node) {
8035         return getFirstJSDocTag(node, isJSDocAugmentsTag);
8036     }
8037     ts.getJSDocAugmentsTag = getJSDocAugmentsTag;
8038     function getJSDocImplementsTags(node) {
8039         return getAllJSDocTags(node, isJSDocImplementsTag);
8040     }
8041     ts.getJSDocImplementsTags = getJSDocImplementsTags;
8042     function getJSDocClassTag(node) {
8043         return getFirstJSDocTag(node, isJSDocClassTag);
8044     }
8045     ts.getJSDocClassTag = getJSDocClassTag;
8046     function getJSDocPublicTag(node) {
8047         return getFirstJSDocTag(node, isJSDocPublicTag);
8048     }
8049     ts.getJSDocPublicTag = getJSDocPublicTag;
8050     function getJSDocPrivateTag(node) {
8051         return getFirstJSDocTag(node, isJSDocPrivateTag);
8052     }
8053     ts.getJSDocPrivateTag = getJSDocPrivateTag;
8054     function getJSDocProtectedTag(node) {
8055         return getFirstJSDocTag(node, isJSDocProtectedTag);
8056     }
8057     ts.getJSDocProtectedTag = getJSDocProtectedTag;
8058     function getJSDocReadonlyTag(node) {
8059         return getFirstJSDocTag(node, isJSDocReadonlyTag);
8060     }
8061     ts.getJSDocReadonlyTag = getJSDocReadonlyTag;
8062     function getJSDocEnumTag(node) {
8063         return getFirstJSDocTag(node, isJSDocEnumTag);
8064     }
8065     ts.getJSDocEnumTag = getJSDocEnumTag;
8066     function getJSDocThisTag(node) {
8067         return getFirstJSDocTag(node, isJSDocThisTag);
8068     }
8069     ts.getJSDocThisTag = getJSDocThisTag;
8070     function getJSDocReturnTag(node) {
8071         return getFirstJSDocTag(node, isJSDocReturnTag);
8072     }
8073     ts.getJSDocReturnTag = getJSDocReturnTag;
8074     function getJSDocTemplateTag(node) {
8075         return getFirstJSDocTag(node, isJSDocTemplateTag);
8076     }
8077     ts.getJSDocTemplateTag = getJSDocTemplateTag;
8078     function getJSDocTypeTag(node) {
8079         var tag = getFirstJSDocTag(node, isJSDocTypeTag);
8080         if (tag && tag.typeExpression && tag.typeExpression.type) {
8081             return tag;
8082         }
8083         return undefined;
8084     }
8085     ts.getJSDocTypeTag = getJSDocTypeTag;
8086     function getJSDocType(node) {
8087         var tag = getFirstJSDocTag(node, isJSDocTypeTag);
8088         if (!tag && isParameter(node)) {
8089             tag = ts.find(getJSDocParameterTags(node), function (tag) { return !!tag.typeExpression; });
8090         }
8091         return tag && tag.typeExpression && tag.typeExpression.type;
8092     }
8093     ts.getJSDocType = getJSDocType;
8094     function getJSDocReturnType(node) {
8095         var returnTag = getJSDocReturnTag(node);
8096         if (returnTag && returnTag.typeExpression) {
8097             return returnTag.typeExpression.type;
8098         }
8099         var typeTag = getJSDocTypeTag(node);
8100         if (typeTag && typeTag.typeExpression) {
8101             var type = typeTag.typeExpression.type;
8102             if (isTypeLiteralNode(type)) {
8103                 var sig = ts.find(type.members, isCallSignatureDeclaration);
8104                 return sig && sig.type;
8105             }
8106             if (isFunctionTypeNode(type) || isJSDocFunctionType(type)) {
8107                 return type.type;
8108             }
8109         }
8110     }
8111     ts.getJSDocReturnType = getJSDocReturnType;
8112     function getJSDocTags(node) {
8113         var tags = node.jsDocCache;
8114         if (tags === undefined) {
8115             var comments = ts.getJSDocCommentsAndTags(node);
8116             ts.Debug.assert(comments.length < 2 || comments[0] !== comments[1]);
8117             node.jsDocCache = tags = ts.flatMap(comments, function (j) { return isJSDoc(j) ? j.tags : j; });
8118         }
8119         return tags;
8120     }
8121     ts.getJSDocTags = getJSDocTags;
8122     function getFirstJSDocTag(node, predicate) {
8123         return ts.find(getJSDocTags(node), predicate);
8124     }
8125     function getAllJSDocTags(node, predicate) {
8126         return getJSDocTags(node).filter(predicate);
8127     }
8128     ts.getAllJSDocTags = getAllJSDocTags;
8129     function getAllJSDocTagsOfKind(node, kind) {
8130         return getJSDocTags(node).filter(function (doc) { return doc.kind === kind; });
8131     }
8132     ts.getAllJSDocTagsOfKind = getAllJSDocTagsOfKind;
8133     function getEffectiveTypeParameterDeclarations(node) {
8134         if (isJSDocSignature(node)) {
8135             return ts.emptyArray;
8136         }
8137         if (ts.isJSDocTypeAlias(node)) {
8138             ts.Debug.assert(node.parent.kind === 303);
8139             return ts.flatMap(node.parent.tags, function (tag) { return isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; });
8140         }
8141         if (node.typeParameters) {
8142             return node.typeParameters;
8143         }
8144         if (ts.isInJSFile(node)) {
8145             var decls = ts.getJSDocTypeParameterDeclarations(node);
8146             if (decls.length) {
8147                 return decls;
8148             }
8149             var typeTag = getJSDocType(node);
8150             if (typeTag && isFunctionTypeNode(typeTag) && typeTag.typeParameters) {
8151                 return typeTag.typeParameters;
8152             }
8153         }
8154         return ts.emptyArray;
8155     }
8156     ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations;
8157     function getEffectiveConstraintOfTypeParameter(node) {
8158         return node.constraint ? node.constraint :
8159             isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint :
8160                 undefined;
8161     }
8162     ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter;
8163     function isNumericLiteral(node) {
8164         return node.kind === 8;
8165     }
8166     ts.isNumericLiteral = isNumericLiteral;
8167     function isBigIntLiteral(node) {
8168         return node.kind === 9;
8169     }
8170     ts.isBigIntLiteral = isBigIntLiteral;
8171     function isStringLiteral(node) {
8172         return node.kind === 10;
8173     }
8174     ts.isStringLiteral = isStringLiteral;
8175     function isJsxText(node) {
8176         return node.kind === 11;
8177     }
8178     ts.isJsxText = isJsxText;
8179     function isRegularExpressionLiteral(node) {
8180         return node.kind === 13;
8181     }
8182     ts.isRegularExpressionLiteral = isRegularExpressionLiteral;
8183     function isNoSubstitutionTemplateLiteral(node) {
8184         return node.kind === 14;
8185     }
8186     ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral;
8187     function isTemplateHead(node) {
8188         return node.kind === 15;
8189     }
8190     ts.isTemplateHead = isTemplateHead;
8191     function isTemplateMiddle(node) {
8192         return node.kind === 16;
8193     }
8194     ts.isTemplateMiddle = isTemplateMiddle;
8195     function isTemplateTail(node) {
8196         return node.kind === 17;
8197     }
8198     ts.isTemplateTail = isTemplateTail;
8199     function isIdentifier(node) {
8200         return node.kind === 75;
8201     }
8202     ts.isIdentifier = isIdentifier;
8203     function isQualifiedName(node) {
8204         return node.kind === 153;
8205     }
8206     ts.isQualifiedName = isQualifiedName;
8207     function isComputedPropertyName(node) {
8208         return node.kind === 154;
8209     }
8210     ts.isComputedPropertyName = isComputedPropertyName;
8211     function isPrivateIdentifier(node) {
8212         return node.kind === 76;
8213     }
8214     ts.isPrivateIdentifier = isPrivateIdentifier;
8215     function isIdentifierOrPrivateIdentifier(node) {
8216         return node.kind === 75 || node.kind === 76;
8217     }
8218     ts.isIdentifierOrPrivateIdentifier = isIdentifierOrPrivateIdentifier;
8219     function isTypeParameterDeclaration(node) {
8220         return node.kind === 155;
8221     }
8222     ts.isTypeParameterDeclaration = isTypeParameterDeclaration;
8223     function isParameter(node) {
8224         return node.kind === 156;
8225     }
8226     ts.isParameter = isParameter;
8227     function isDecorator(node) {
8228         return node.kind === 157;
8229     }
8230     ts.isDecorator = isDecorator;
8231     function isPropertySignature(node) {
8232         return node.kind === 158;
8233     }
8234     ts.isPropertySignature = isPropertySignature;
8235     function isPropertyDeclaration(node) {
8236         return node.kind === 159;
8237     }
8238     ts.isPropertyDeclaration = isPropertyDeclaration;
8239     function isMethodSignature(node) {
8240         return node.kind === 160;
8241     }
8242     ts.isMethodSignature = isMethodSignature;
8243     function isMethodDeclaration(node) {
8244         return node.kind === 161;
8245     }
8246     ts.isMethodDeclaration = isMethodDeclaration;
8247     function isConstructorDeclaration(node) {
8248         return node.kind === 162;
8249     }
8250     ts.isConstructorDeclaration = isConstructorDeclaration;
8251     function isGetAccessorDeclaration(node) {
8252         return node.kind === 163;
8253     }
8254     ts.isGetAccessorDeclaration = isGetAccessorDeclaration;
8255     function isSetAccessorDeclaration(node) {
8256         return node.kind === 164;
8257     }
8258     ts.isSetAccessorDeclaration = isSetAccessorDeclaration;
8259     function isCallSignatureDeclaration(node) {
8260         return node.kind === 165;
8261     }
8262     ts.isCallSignatureDeclaration = isCallSignatureDeclaration;
8263     function isConstructSignatureDeclaration(node) {
8264         return node.kind === 166;
8265     }
8266     ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration;
8267     function isIndexSignatureDeclaration(node) {
8268         return node.kind === 167;
8269     }
8270     ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration;
8271     function isGetOrSetAccessorDeclaration(node) {
8272         return node.kind === 164 || node.kind === 163;
8273     }
8274     ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration;
8275     function isTypePredicateNode(node) {
8276         return node.kind === 168;
8277     }
8278     ts.isTypePredicateNode = isTypePredicateNode;
8279     function isTypeReferenceNode(node) {
8280         return node.kind === 169;
8281     }
8282     ts.isTypeReferenceNode = isTypeReferenceNode;
8283     function isFunctionTypeNode(node) {
8284         return node.kind === 170;
8285     }
8286     ts.isFunctionTypeNode = isFunctionTypeNode;
8287     function isConstructorTypeNode(node) {
8288         return node.kind === 171;
8289     }
8290     ts.isConstructorTypeNode = isConstructorTypeNode;
8291     function isTypeQueryNode(node) {
8292         return node.kind === 172;
8293     }
8294     ts.isTypeQueryNode = isTypeQueryNode;
8295     function isTypeLiteralNode(node) {
8296         return node.kind === 173;
8297     }
8298     ts.isTypeLiteralNode = isTypeLiteralNode;
8299     function isArrayTypeNode(node) {
8300         return node.kind === 174;
8301     }
8302     ts.isArrayTypeNode = isArrayTypeNode;
8303     function isTupleTypeNode(node) {
8304         return node.kind === 175;
8305     }
8306     ts.isTupleTypeNode = isTupleTypeNode;
8307     function isUnionTypeNode(node) {
8308         return node.kind === 178;
8309     }
8310     ts.isUnionTypeNode = isUnionTypeNode;
8311     function isIntersectionTypeNode(node) {
8312         return node.kind === 179;
8313     }
8314     ts.isIntersectionTypeNode = isIntersectionTypeNode;
8315     function isConditionalTypeNode(node) {
8316         return node.kind === 180;
8317     }
8318     ts.isConditionalTypeNode = isConditionalTypeNode;
8319     function isInferTypeNode(node) {
8320         return node.kind === 181;
8321     }
8322     ts.isInferTypeNode = isInferTypeNode;
8323     function isParenthesizedTypeNode(node) {
8324         return node.kind === 182;
8325     }
8326     ts.isParenthesizedTypeNode = isParenthesizedTypeNode;
8327     function isThisTypeNode(node) {
8328         return node.kind === 183;
8329     }
8330     ts.isThisTypeNode = isThisTypeNode;
8331     function isTypeOperatorNode(node) {
8332         return node.kind === 184;
8333     }
8334     ts.isTypeOperatorNode = isTypeOperatorNode;
8335     function isIndexedAccessTypeNode(node) {
8336         return node.kind === 185;
8337     }
8338     ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode;
8339     function isMappedTypeNode(node) {
8340         return node.kind === 186;
8341     }
8342     ts.isMappedTypeNode = isMappedTypeNode;
8343     function isLiteralTypeNode(node) {
8344         return node.kind === 187;
8345     }
8346     ts.isLiteralTypeNode = isLiteralTypeNode;
8347     function isImportTypeNode(node) {
8348         return node.kind === 188;
8349     }
8350     ts.isImportTypeNode = isImportTypeNode;
8351     function isObjectBindingPattern(node) {
8352         return node.kind === 189;
8353     }
8354     ts.isObjectBindingPattern = isObjectBindingPattern;
8355     function isArrayBindingPattern(node) {
8356         return node.kind === 190;
8357     }
8358     ts.isArrayBindingPattern = isArrayBindingPattern;
8359     function isBindingElement(node) {
8360         return node.kind === 191;
8361     }
8362     ts.isBindingElement = isBindingElement;
8363     function isArrayLiteralExpression(node) {
8364         return node.kind === 192;
8365     }
8366     ts.isArrayLiteralExpression = isArrayLiteralExpression;
8367     function isObjectLiteralExpression(node) {
8368         return node.kind === 193;
8369     }
8370     ts.isObjectLiteralExpression = isObjectLiteralExpression;
8371     function isPropertyAccessExpression(node) {
8372         return node.kind === 194;
8373     }
8374     ts.isPropertyAccessExpression = isPropertyAccessExpression;
8375     function isPropertyAccessChain(node) {
8376         return isPropertyAccessExpression(node) && !!(node.flags & 32);
8377     }
8378     ts.isPropertyAccessChain = isPropertyAccessChain;
8379     function isElementAccessExpression(node) {
8380         return node.kind === 195;
8381     }
8382     ts.isElementAccessExpression = isElementAccessExpression;
8383     function isElementAccessChain(node) {
8384         return isElementAccessExpression(node) && !!(node.flags & 32);
8385     }
8386     ts.isElementAccessChain = isElementAccessChain;
8387     function isCallExpression(node) {
8388         return node.kind === 196;
8389     }
8390     ts.isCallExpression = isCallExpression;
8391     function isCallChain(node) {
8392         return isCallExpression(node) && !!(node.flags & 32);
8393     }
8394     ts.isCallChain = isCallChain;
8395     function isOptionalChain(node) {
8396         var kind = node.kind;
8397         return !!(node.flags & 32) &&
8398             (kind === 194
8399                 || kind === 195
8400                 || kind === 196
8401                 || kind === 218);
8402     }
8403     ts.isOptionalChain = isOptionalChain;
8404     function isOptionalChainRoot(node) {
8405         return isOptionalChain(node) && !isNonNullExpression(node) && !!node.questionDotToken;
8406     }
8407     ts.isOptionalChainRoot = isOptionalChainRoot;
8408     function isExpressionOfOptionalChainRoot(node) {
8409         return isOptionalChainRoot(node.parent) && node.parent.expression === node;
8410     }
8411     ts.isExpressionOfOptionalChainRoot = isExpressionOfOptionalChainRoot;
8412     function isOutermostOptionalChain(node) {
8413         return !isOptionalChain(node.parent)
8414             || isOptionalChainRoot(node.parent)
8415             || node !== node.parent.expression;
8416     }
8417     ts.isOutermostOptionalChain = isOutermostOptionalChain;
8418     function isNullishCoalesce(node) {
8419         return node.kind === 209 && node.operatorToken.kind === 60;
8420     }
8421     ts.isNullishCoalesce = isNullishCoalesce;
8422     function isNewExpression(node) {
8423         return node.kind === 197;
8424     }
8425     ts.isNewExpression = isNewExpression;
8426     function isTaggedTemplateExpression(node) {
8427         return node.kind === 198;
8428     }
8429     ts.isTaggedTemplateExpression = isTaggedTemplateExpression;
8430     function isTypeAssertion(node) {
8431         return node.kind === 199;
8432     }
8433     ts.isTypeAssertion = isTypeAssertion;
8434     function isConstTypeReference(node) {
8435         return isTypeReferenceNode(node) && isIdentifier(node.typeName) &&
8436             node.typeName.escapedText === "const" && !node.typeArguments;
8437     }
8438     ts.isConstTypeReference = isConstTypeReference;
8439     function isParenthesizedExpression(node) {
8440         return node.kind === 200;
8441     }
8442     ts.isParenthesizedExpression = isParenthesizedExpression;
8443     function skipPartiallyEmittedExpressions(node) {
8444         return ts.skipOuterExpressions(node, 8);
8445     }
8446     ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions;
8447     function isFunctionExpression(node) {
8448         return node.kind === 201;
8449     }
8450     ts.isFunctionExpression = isFunctionExpression;
8451     function isArrowFunction(node) {
8452         return node.kind === 202;
8453     }
8454     ts.isArrowFunction = isArrowFunction;
8455     function isDeleteExpression(node) {
8456         return node.kind === 203;
8457     }
8458     ts.isDeleteExpression = isDeleteExpression;
8459     function isTypeOfExpression(node) {
8460         return node.kind === 204;
8461     }
8462     ts.isTypeOfExpression = isTypeOfExpression;
8463     function isVoidExpression(node) {
8464         return node.kind === 205;
8465     }
8466     ts.isVoidExpression = isVoidExpression;
8467     function isAwaitExpression(node) {
8468         return node.kind === 206;
8469     }
8470     ts.isAwaitExpression = isAwaitExpression;
8471     function isPrefixUnaryExpression(node) {
8472         return node.kind === 207;
8473     }
8474     ts.isPrefixUnaryExpression = isPrefixUnaryExpression;
8475     function isPostfixUnaryExpression(node) {
8476         return node.kind === 208;
8477     }
8478     ts.isPostfixUnaryExpression = isPostfixUnaryExpression;
8479     function isBinaryExpression(node) {
8480         return node.kind === 209;
8481     }
8482     ts.isBinaryExpression = isBinaryExpression;
8483     function isConditionalExpression(node) {
8484         return node.kind === 210;
8485     }
8486     ts.isConditionalExpression = isConditionalExpression;
8487     function isTemplateExpression(node) {
8488         return node.kind === 211;
8489     }
8490     ts.isTemplateExpression = isTemplateExpression;
8491     function isYieldExpression(node) {
8492         return node.kind === 212;
8493     }
8494     ts.isYieldExpression = isYieldExpression;
8495     function isSpreadElement(node) {
8496         return node.kind === 213;
8497     }
8498     ts.isSpreadElement = isSpreadElement;
8499     function isClassExpression(node) {
8500         return node.kind === 214;
8501     }
8502     ts.isClassExpression = isClassExpression;
8503     function isOmittedExpression(node) {
8504         return node.kind === 215;
8505     }
8506     ts.isOmittedExpression = isOmittedExpression;
8507     function isExpressionWithTypeArguments(node) {
8508         return node.kind === 216;
8509     }
8510     ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments;
8511     function isAsExpression(node) {
8512         return node.kind === 217;
8513     }
8514     ts.isAsExpression = isAsExpression;
8515     function isNonNullExpression(node) {
8516         return node.kind === 218;
8517     }
8518     ts.isNonNullExpression = isNonNullExpression;
8519     function isNonNullChain(node) {
8520         return isNonNullExpression(node) && !!(node.flags & 32);
8521     }
8522     ts.isNonNullChain = isNonNullChain;
8523     function isMetaProperty(node) {
8524         return node.kind === 219;
8525     }
8526     ts.isMetaProperty = isMetaProperty;
8527     function isTemplateSpan(node) {
8528         return node.kind === 221;
8529     }
8530     ts.isTemplateSpan = isTemplateSpan;
8531     function isSemicolonClassElement(node) {
8532         return node.kind === 222;
8533     }
8534     ts.isSemicolonClassElement = isSemicolonClassElement;
8535     function isBlock(node) {
8536         return node.kind === 223;
8537     }
8538     ts.isBlock = isBlock;
8539     function isVariableStatement(node) {
8540         return node.kind === 225;
8541     }
8542     ts.isVariableStatement = isVariableStatement;
8543     function isEmptyStatement(node) {
8544         return node.kind === 224;
8545     }
8546     ts.isEmptyStatement = isEmptyStatement;
8547     function isExpressionStatement(node) {
8548         return node.kind === 226;
8549     }
8550     ts.isExpressionStatement = isExpressionStatement;
8551     function isIfStatement(node) {
8552         return node.kind === 227;
8553     }
8554     ts.isIfStatement = isIfStatement;
8555     function isDoStatement(node) {
8556         return node.kind === 228;
8557     }
8558     ts.isDoStatement = isDoStatement;
8559     function isWhileStatement(node) {
8560         return node.kind === 229;
8561     }
8562     ts.isWhileStatement = isWhileStatement;
8563     function isForStatement(node) {
8564         return node.kind === 230;
8565     }
8566     ts.isForStatement = isForStatement;
8567     function isForInStatement(node) {
8568         return node.kind === 231;
8569     }
8570     ts.isForInStatement = isForInStatement;
8571     function isForOfStatement(node) {
8572         return node.kind === 232;
8573     }
8574     ts.isForOfStatement = isForOfStatement;
8575     function isContinueStatement(node) {
8576         return node.kind === 233;
8577     }
8578     ts.isContinueStatement = isContinueStatement;
8579     function isBreakStatement(node) {
8580         return node.kind === 234;
8581     }
8582     ts.isBreakStatement = isBreakStatement;
8583     function isBreakOrContinueStatement(node) {
8584         return node.kind === 234 || node.kind === 233;
8585     }
8586     ts.isBreakOrContinueStatement = isBreakOrContinueStatement;
8587     function isReturnStatement(node) {
8588         return node.kind === 235;
8589     }
8590     ts.isReturnStatement = isReturnStatement;
8591     function isWithStatement(node) {
8592         return node.kind === 236;
8593     }
8594     ts.isWithStatement = isWithStatement;
8595     function isSwitchStatement(node) {
8596         return node.kind === 237;
8597     }
8598     ts.isSwitchStatement = isSwitchStatement;
8599     function isLabeledStatement(node) {
8600         return node.kind === 238;
8601     }
8602     ts.isLabeledStatement = isLabeledStatement;
8603     function isThrowStatement(node) {
8604         return node.kind === 239;
8605     }
8606     ts.isThrowStatement = isThrowStatement;
8607     function isTryStatement(node) {
8608         return node.kind === 240;
8609     }
8610     ts.isTryStatement = isTryStatement;
8611     function isDebuggerStatement(node) {
8612         return node.kind === 241;
8613     }
8614     ts.isDebuggerStatement = isDebuggerStatement;
8615     function isVariableDeclaration(node) {
8616         return node.kind === 242;
8617     }
8618     ts.isVariableDeclaration = isVariableDeclaration;
8619     function isVariableDeclarationList(node) {
8620         return node.kind === 243;
8621     }
8622     ts.isVariableDeclarationList = isVariableDeclarationList;
8623     function isFunctionDeclaration(node) {
8624         return node.kind === 244;
8625     }
8626     ts.isFunctionDeclaration = isFunctionDeclaration;
8627     function isClassDeclaration(node) {
8628         return node.kind === 245;
8629     }
8630     ts.isClassDeclaration = isClassDeclaration;
8631     function isInterfaceDeclaration(node) {
8632         return node.kind === 246;
8633     }
8634     ts.isInterfaceDeclaration = isInterfaceDeclaration;
8635     function isTypeAliasDeclaration(node) {
8636         return node.kind === 247;
8637     }
8638     ts.isTypeAliasDeclaration = isTypeAliasDeclaration;
8639     function isEnumDeclaration(node) {
8640         return node.kind === 248;
8641     }
8642     ts.isEnumDeclaration = isEnumDeclaration;
8643     function isModuleDeclaration(node) {
8644         return node.kind === 249;
8645     }
8646     ts.isModuleDeclaration = isModuleDeclaration;
8647     function isModuleBlock(node) {
8648         return node.kind === 250;
8649     }
8650     ts.isModuleBlock = isModuleBlock;
8651     function isCaseBlock(node) {
8652         return node.kind === 251;
8653     }
8654     ts.isCaseBlock = isCaseBlock;
8655     function isNamespaceExportDeclaration(node) {
8656         return node.kind === 252;
8657     }
8658     ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration;
8659     function isImportEqualsDeclaration(node) {
8660         return node.kind === 253;
8661     }
8662     ts.isImportEqualsDeclaration = isImportEqualsDeclaration;
8663     function isImportDeclaration(node) {
8664         return node.kind === 254;
8665     }
8666     ts.isImportDeclaration = isImportDeclaration;
8667     function isImportClause(node) {
8668         return node.kind === 255;
8669     }
8670     ts.isImportClause = isImportClause;
8671     function isNamespaceImport(node) {
8672         return node.kind === 256;
8673     }
8674     ts.isNamespaceImport = isNamespaceImport;
8675     function isNamespaceExport(node) {
8676         return node.kind === 262;
8677     }
8678     ts.isNamespaceExport = isNamespaceExport;
8679     function isNamedExportBindings(node) {
8680         return node.kind === 262 || node.kind === 261;
8681     }
8682     ts.isNamedExportBindings = isNamedExportBindings;
8683     function isNamedImports(node) {
8684         return node.kind === 257;
8685     }
8686     ts.isNamedImports = isNamedImports;
8687     function isImportSpecifier(node) {
8688         return node.kind === 258;
8689     }
8690     ts.isImportSpecifier = isImportSpecifier;
8691     function isExportAssignment(node) {
8692         return node.kind === 259;
8693     }
8694     ts.isExportAssignment = isExportAssignment;
8695     function isExportDeclaration(node) {
8696         return node.kind === 260;
8697     }
8698     ts.isExportDeclaration = isExportDeclaration;
8699     function isNamedExports(node) {
8700         return node.kind === 261;
8701     }
8702     ts.isNamedExports = isNamedExports;
8703     function isExportSpecifier(node) {
8704         return node.kind === 263;
8705     }
8706     ts.isExportSpecifier = isExportSpecifier;
8707     function isMissingDeclaration(node) {
8708         return node.kind === 264;
8709     }
8710     ts.isMissingDeclaration = isMissingDeclaration;
8711     function isExternalModuleReference(node) {
8712         return node.kind === 265;
8713     }
8714     ts.isExternalModuleReference = isExternalModuleReference;
8715     function isJsxElement(node) {
8716         return node.kind === 266;
8717     }
8718     ts.isJsxElement = isJsxElement;
8719     function isJsxSelfClosingElement(node) {
8720         return node.kind === 267;
8721     }
8722     ts.isJsxSelfClosingElement = isJsxSelfClosingElement;
8723     function isJsxOpeningElement(node) {
8724         return node.kind === 268;
8725     }
8726     ts.isJsxOpeningElement = isJsxOpeningElement;
8727     function isJsxClosingElement(node) {
8728         return node.kind === 269;
8729     }
8730     ts.isJsxClosingElement = isJsxClosingElement;
8731     function isJsxFragment(node) {
8732         return node.kind === 270;
8733     }
8734     ts.isJsxFragment = isJsxFragment;
8735     function isJsxOpeningFragment(node) {
8736         return node.kind === 271;
8737     }
8738     ts.isJsxOpeningFragment = isJsxOpeningFragment;
8739     function isJsxClosingFragment(node) {
8740         return node.kind === 272;
8741     }
8742     ts.isJsxClosingFragment = isJsxClosingFragment;
8743     function isJsxAttribute(node) {
8744         return node.kind === 273;
8745     }
8746     ts.isJsxAttribute = isJsxAttribute;
8747     function isJsxAttributes(node) {
8748         return node.kind === 274;
8749     }
8750     ts.isJsxAttributes = isJsxAttributes;
8751     function isJsxSpreadAttribute(node) {
8752         return node.kind === 275;
8753     }
8754     ts.isJsxSpreadAttribute = isJsxSpreadAttribute;
8755     function isJsxExpression(node) {
8756         return node.kind === 276;
8757     }
8758     ts.isJsxExpression = isJsxExpression;
8759     function isCaseClause(node) {
8760         return node.kind === 277;
8761     }
8762     ts.isCaseClause = isCaseClause;
8763     function isDefaultClause(node) {
8764         return node.kind === 278;
8765     }
8766     ts.isDefaultClause = isDefaultClause;
8767     function isHeritageClause(node) {
8768         return node.kind === 279;
8769     }
8770     ts.isHeritageClause = isHeritageClause;
8771     function isCatchClause(node) {
8772         return node.kind === 280;
8773     }
8774     ts.isCatchClause = isCatchClause;
8775     function isPropertyAssignment(node) {
8776         return node.kind === 281;
8777     }
8778     ts.isPropertyAssignment = isPropertyAssignment;
8779     function isShorthandPropertyAssignment(node) {
8780         return node.kind === 282;
8781     }
8782     ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment;
8783     function isSpreadAssignment(node) {
8784         return node.kind === 283;
8785     }
8786     ts.isSpreadAssignment = isSpreadAssignment;
8787     function isEnumMember(node) {
8788         return node.kind === 284;
8789     }
8790     ts.isEnumMember = isEnumMember;
8791     function isSourceFile(node) {
8792         return node.kind === 290;
8793     }
8794     ts.isSourceFile = isSourceFile;
8795     function isBundle(node) {
8796         return node.kind === 291;
8797     }
8798     ts.isBundle = isBundle;
8799     function isUnparsedSource(node) {
8800         return node.kind === 292;
8801     }
8802     ts.isUnparsedSource = isUnparsedSource;
8803     function isUnparsedPrepend(node) {
8804         return node.kind === 286;
8805     }
8806     ts.isUnparsedPrepend = isUnparsedPrepend;
8807     function isUnparsedTextLike(node) {
8808         switch (node.kind) {
8809             case 287:
8810             case 288:
8811                 return true;
8812             default:
8813                 return false;
8814         }
8815     }
8816     ts.isUnparsedTextLike = isUnparsedTextLike;
8817     function isUnparsedNode(node) {
8818         return isUnparsedTextLike(node) ||
8819             node.kind === 285 ||
8820             node.kind === 289;
8821     }
8822     ts.isUnparsedNode = isUnparsedNode;
8823     function isJSDocTypeExpression(node) {
8824         return node.kind === 294;
8825     }
8826     ts.isJSDocTypeExpression = isJSDocTypeExpression;
8827     function isJSDocAllType(node) {
8828         return node.kind === 295;
8829     }
8830     ts.isJSDocAllType = isJSDocAllType;
8831     function isJSDocUnknownType(node) {
8832         return node.kind === 296;
8833     }
8834     ts.isJSDocUnknownType = isJSDocUnknownType;
8835     function isJSDocNullableType(node) {
8836         return node.kind === 297;
8837     }
8838     ts.isJSDocNullableType = isJSDocNullableType;
8839     function isJSDocNonNullableType(node) {
8840         return node.kind === 298;
8841     }
8842     ts.isJSDocNonNullableType = isJSDocNonNullableType;
8843     function isJSDocOptionalType(node) {
8844         return node.kind === 299;
8845     }
8846     ts.isJSDocOptionalType = isJSDocOptionalType;
8847     function isJSDocFunctionType(node) {
8848         return node.kind === 300;
8849     }
8850     ts.isJSDocFunctionType = isJSDocFunctionType;
8851     function isJSDocVariadicType(node) {
8852         return node.kind === 301;
8853     }
8854     ts.isJSDocVariadicType = isJSDocVariadicType;
8855     function isJSDoc(node) {
8856         return node.kind === 303;
8857     }
8858     ts.isJSDoc = isJSDoc;
8859     function isJSDocAuthorTag(node) {
8860         return node.kind === 309;
8861     }
8862     ts.isJSDocAuthorTag = isJSDocAuthorTag;
8863     function isJSDocAugmentsTag(node) {
8864         return node.kind === 307;
8865     }
8866     ts.isJSDocAugmentsTag = isJSDocAugmentsTag;
8867     function isJSDocImplementsTag(node) {
8868         return node.kind === 308;
8869     }
8870     ts.isJSDocImplementsTag = isJSDocImplementsTag;
8871     function isJSDocClassTag(node) {
8872         return node.kind === 310;
8873     }
8874     ts.isJSDocClassTag = isJSDocClassTag;
8875     function isJSDocPublicTag(node) {
8876         return node.kind === 311;
8877     }
8878     ts.isJSDocPublicTag = isJSDocPublicTag;
8879     function isJSDocPrivateTag(node) {
8880         return node.kind === 312;
8881     }
8882     ts.isJSDocPrivateTag = isJSDocPrivateTag;
8883     function isJSDocProtectedTag(node) {
8884         return node.kind === 313;
8885     }
8886     ts.isJSDocProtectedTag = isJSDocProtectedTag;
8887     function isJSDocReadonlyTag(node) {
8888         return node.kind === 314;
8889     }
8890     ts.isJSDocReadonlyTag = isJSDocReadonlyTag;
8891     function isJSDocEnumTag(node) {
8892         return node.kind === 316;
8893     }
8894     ts.isJSDocEnumTag = isJSDocEnumTag;
8895     function isJSDocThisTag(node) {
8896         return node.kind === 319;
8897     }
8898     ts.isJSDocThisTag = isJSDocThisTag;
8899     function isJSDocParameterTag(node) {
8900         return node.kind === 317;
8901     }
8902     ts.isJSDocParameterTag = isJSDocParameterTag;
8903     function isJSDocReturnTag(node) {
8904         return node.kind === 318;
8905     }
8906     ts.isJSDocReturnTag = isJSDocReturnTag;
8907     function isJSDocTypeTag(node) {
8908         return node.kind === 320;
8909     }
8910     ts.isJSDocTypeTag = isJSDocTypeTag;
8911     function isJSDocTemplateTag(node) {
8912         return node.kind === 321;
8913     }
8914     ts.isJSDocTemplateTag = isJSDocTemplateTag;
8915     function isJSDocTypedefTag(node) {
8916         return node.kind === 322;
8917     }
8918     ts.isJSDocTypedefTag = isJSDocTypedefTag;
8919     function isJSDocPropertyTag(node) {
8920         return node.kind === 323;
8921     }
8922     ts.isJSDocPropertyTag = isJSDocPropertyTag;
8923     function isJSDocPropertyLikeTag(node) {
8924         return node.kind === 323 || node.kind === 317;
8925     }
8926     ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag;
8927     function isJSDocTypeLiteral(node) {
8928         return node.kind === 304;
8929     }
8930     ts.isJSDocTypeLiteral = isJSDocTypeLiteral;
8931     function isJSDocCallbackTag(node) {
8932         return node.kind === 315;
8933     }
8934     ts.isJSDocCallbackTag = isJSDocCallbackTag;
8935     function isJSDocSignature(node) {
8936         return node.kind === 305;
8937     }
8938     ts.isJSDocSignature = isJSDocSignature;
8939     function isSyntaxList(n) {
8940         return n.kind === 324;
8941     }
8942     ts.isSyntaxList = isSyntaxList;
8943     function isNode(node) {
8944         return isNodeKind(node.kind);
8945     }
8946     ts.isNode = isNode;
8947     function isNodeKind(kind) {
8948         return kind >= 153;
8949     }
8950     ts.isNodeKind = isNodeKind;
8951     function isToken(n) {
8952         return n.kind >= 0 && n.kind <= 152;
8953     }
8954     ts.isToken = isToken;
8955     function isNodeArray(array) {
8956         return array.hasOwnProperty("pos") && array.hasOwnProperty("end");
8957     }
8958     ts.isNodeArray = isNodeArray;
8959     function isLiteralKind(kind) {
8960         return 8 <= kind && kind <= 14;
8961     }
8962     ts.isLiteralKind = isLiteralKind;
8963     function isLiteralExpression(node) {
8964         return isLiteralKind(node.kind);
8965     }
8966     ts.isLiteralExpression = isLiteralExpression;
8967     function isTemplateLiteralKind(kind) {
8968         return 14 <= kind && kind <= 17;
8969     }
8970     ts.isTemplateLiteralKind = isTemplateLiteralKind;
8971     function isTemplateLiteralToken(node) {
8972         return isTemplateLiteralKind(node.kind);
8973     }
8974     ts.isTemplateLiteralToken = isTemplateLiteralToken;
8975     function isTemplateMiddleOrTemplateTail(node) {
8976         var kind = node.kind;
8977         return kind === 16
8978             || kind === 17;
8979     }
8980     ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail;
8981     function isImportOrExportSpecifier(node) {
8982         return isImportSpecifier(node) || isExportSpecifier(node);
8983     }
8984     ts.isImportOrExportSpecifier = isImportOrExportSpecifier;
8985     function isTypeOnlyImportOrExportDeclaration(node) {
8986         switch (node.kind) {
8987             case 258:
8988             case 263:
8989                 return node.parent.parent.isTypeOnly;
8990             case 256:
8991                 return node.parent.isTypeOnly;
8992             case 255:
8993                 return node.isTypeOnly;
8994             default:
8995                 return false;
8996         }
8997     }
8998     ts.isTypeOnlyImportOrExportDeclaration = isTypeOnlyImportOrExportDeclaration;
8999     function isStringTextContainingNode(node) {
9000         return node.kind === 10 || isTemplateLiteralKind(node.kind);
9001     }
9002     ts.isStringTextContainingNode = isStringTextContainingNode;
9003     function isGeneratedIdentifier(node) {
9004         return isIdentifier(node) && (node.autoGenerateFlags & 7) > 0;
9005     }
9006     ts.isGeneratedIdentifier = isGeneratedIdentifier;
9007     function isPrivateIdentifierPropertyDeclaration(node) {
9008         return isPropertyDeclaration(node) && isPrivateIdentifier(node.name);
9009     }
9010     ts.isPrivateIdentifierPropertyDeclaration = isPrivateIdentifierPropertyDeclaration;
9011     function isPrivateIdentifierPropertyAccessExpression(node) {
9012         return isPropertyAccessExpression(node) && isPrivateIdentifier(node.name);
9013     }
9014     ts.isPrivateIdentifierPropertyAccessExpression = isPrivateIdentifierPropertyAccessExpression;
9015     function isModifierKind(token) {
9016         switch (token) {
9017             case 122:
9018             case 126:
9019             case 81:
9020             case 130:
9021             case 84:
9022             case 89:
9023             case 119:
9024             case 117:
9025             case 118:
9026             case 138:
9027             case 120:
9028                 return true;
9029         }
9030         return false;
9031     }
9032     ts.isModifierKind = isModifierKind;
9033     function isParameterPropertyModifier(kind) {
9034         return !!(ts.modifierToFlag(kind) & 92);
9035     }
9036     ts.isParameterPropertyModifier = isParameterPropertyModifier;
9037     function isClassMemberModifier(idToken) {
9038         return isParameterPropertyModifier(idToken) || idToken === 120;
9039     }
9040     ts.isClassMemberModifier = isClassMemberModifier;
9041     function isModifier(node) {
9042         return isModifierKind(node.kind);
9043     }
9044     ts.isModifier = isModifier;
9045     function isEntityName(node) {
9046         var kind = node.kind;
9047         return kind === 153
9048             || kind === 75;
9049     }
9050     ts.isEntityName = isEntityName;
9051     function isPropertyName(node) {
9052         var kind = node.kind;
9053         return kind === 75
9054             || kind === 76
9055             || kind === 10
9056             || kind === 8
9057             || kind === 154;
9058     }
9059     ts.isPropertyName = isPropertyName;
9060     function isBindingName(node) {
9061         var kind = node.kind;
9062         return kind === 75
9063             || kind === 189
9064             || kind === 190;
9065     }
9066     ts.isBindingName = isBindingName;
9067     function isFunctionLike(node) {
9068         return node && isFunctionLikeKind(node.kind);
9069     }
9070     ts.isFunctionLike = isFunctionLike;
9071     function isFunctionLikeDeclaration(node) {
9072         return node && isFunctionLikeDeclarationKind(node.kind);
9073     }
9074     ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration;
9075     function isFunctionLikeDeclarationKind(kind) {
9076         switch (kind) {
9077             case 244:
9078             case 161:
9079             case 162:
9080             case 163:
9081             case 164:
9082             case 201:
9083             case 202:
9084                 return true;
9085             default:
9086                 return false;
9087         }
9088     }
9089     function isFunctionLikeKind(kind) {
9090         switch (kind) {
9091             case 160:
9092             case 165:
9093             case 305:
9094             case 166:
9095             case 167:
9096             case 170:
9097             case 300:
9098             case 171:
9099                 return true;
9100             default:
9101                 return isFunctionLikeDeclarationKind(kind);
9102         }
9103     }
9104     ts.isFunctionLikeKind = isFunctionLikeKind;
9105     function isFunctionOrModuleBlock(node) {
9106         return isSourceFile(node) || isModuleBlock(node) || isBlock(node) && isFunctionLike(node.parent);
9107     }
9108     ts.isFunctionOrModuleBlock = isFunctionOrModuleBlock;
9109     function isClassElement(node) {
9110         var kind = node.kind;
9111         return kind === 162
9112             || kind === 159
9113             || kind === 161
9114             || kind === 163
9115             || kind === 164
9116             || kind === 167
9117             || kind === 222;
9118     }
9119     ts.isClassElement = isClassElement;
9120     function isClassLike(node) {
9121         return node && (node.kind === 245 || node.kind === 214);
9122     }
9123     ts.isClassLike = isClassLike;
9124     function isAccessor(node) {
9125         return node && (node.kind === 163 || node.kind === 164);
9126     }
9127     ts.isAccessor = isAccessor;
9128     function isMethodOrAccessor(node) {
9129         switch (node.kind) {
9130             case 161:
9131             case 163:
9132             case 164:
9133                 return true;
9134             default:
9135                 return false;
9136         }
9137     }
9138     ts.isMethodOrAccessor = isMethodOrAccessor;
9139     function isTypeElement(node) {
9140         var kind = node.kind;
9141         return kind === 166
9142             || kind === 165
9143             || kind === 158
9144             || kind === 160
9145             || kind === 167;
9146     }
9147     ts.isTypeElement = isTypeElement;
9148     function isClassOrTypeElement(node) {
9149         return isTypeElement(node) || isClassElement(node);
9150     }
9151     ts.isClassOrTypeElement = isClassOrTypeElement;
9152     function isObjectLiteralElementLike(node) {
9153         var kind = node.kind;
9154         return kind === 281
9155             || kind === 282
9156             || kind === 283
9157             || kind === 161
9158             || kind === 163
9159             || kind === 164;
9160     }
9161     ts.isObjectLiteralElementLike = isObjectLiteralElementLike;
9162     function isTypeNode(node) {
9163         return ts.isTypeNodeKind(node.kind);
9164     }
9165     ts.isTypeNode = isTypeNode;
9166     function isFunctionOrConstructorTypeNode(node) {
9167         switch (node.kind) {
9168             case 170:
9169             case 171:
9170                 return true;
9171         }
9172         return false;
9173     }
9174     ts.isFunctionOrConstructorTypeNode = isFunctionOrConstructorTypeNode;
9175     function isBindingPattern(node) {
9176         if (node) {
9177             var kind = node.kind;
9178             return kind === 190
9179                 || kind === 189;
9180         }
9181         return false;
9182     }
9183     ts.isBindingPattern = isBindingPattern;
9184     function isAssignmentPattern(node) {
9185         var kind = node.kind;
9186         return kind === 192
9187             || kind === 193;
9188     }
9189     ts.isAssignmentPattern = isAssignmentPattern;
9190     function isArrayBindingElement(node) {
9191         var kind = node.kind;
9192         return kind === 191
9193             || kind === 215;
9194     }
9195     ts.isArrayBindingElement = isArrayBindingElement;
9196     function isDeclarationBindingElement(bindingElement) {
9197         switch (bindingElement.kind) {
9198             case 242:
9199             case 156:
9200             case 191:
9201                 return true;
9202         }
9203         return false;
9204     }
9205     ts.isDeclarationBindingElement = isDeclarationBindingElement;
9206     function isBindingOrAssignmentPattern(node) {
9207         return isObjectBindingOrAssignmentPattern(node)
9208             || isArrayBindingOrAssignmentPattern(node);
9209     }
9210     ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern;
9211     function isObjectBindingOrAssignmentPattern(node) {
9212         switch (node.kind) {
9213             case 189:
9214             case 193:
9215                 return true;
9216         }
9217         return false;
9218     }
9219     ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern;
9220     function isArrayBindingOrAssignmentPattern(node) {
9221         switch (node.kind) {
9222             case 190:
9223             case 192:
9224                 return true;
9225         }
9226         return false;
9227     }
9228     ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern;
9229     function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) {
9230         var kind = node.kind;
9231         return kind === 194
9232             || kind === 153
9233             || kind === 188;
9234     }
9235     ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode;
9236     function isPropertyAccessOrQualifiedName(node) {
9237         var kind = node.kind;
9238         return kind === 194
9239             || kind === 153;
9240     }
9241     ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName;
9242     function isCallLikeExpression(node) {
9243         switch (node.kind) {
9244             case 268:
9245             case 267:
9246             case 196:
9247             case 197:
9248             case 198:
9249             case 157:
9250                 return true;
9251             default:
9252                 return false;
9253         }
9254     }
9255     ts.isCallLikeExpression = isCallLikeExpression;
9256     function isCallOrNewExpression(node) {
9257         return node.kind === 196 || node.kind === 197;
9258     }
9259     ts.isCallOrNewExpression = isCallOrNewExpression;
9260     function isTemplateLiteral(node) {
9261         var kind = node.kind;
9262         return kind === 211
9263             || kind === 14;
9264     }
9265     ts.isTemplateLiteral = isTemplateLiteral;
9266     function isLeftHandSideExpression(node) {
9267         return isLeftHandSideExpressionKind(skipPartiallyEmittedExpressions(node).kind);
9268     }
9269     ts.isLeftHandSideExpression = isLeftHandSideExpression;
9270     function isLeftHandSideExpressionKind(kind) {
9271         switch (kind) {
9272             case 194:
9273             case 195:
9274             case 197:
9275             case 196:
9276             case 266:
9277             case 267:
9278             case 270:
9279             case 198:
9280             case 192:
9281             case 200:
9282             case 193:
9283             case 214:
9284             case 201:
9285             case 75:
9286             case 13:
9287             case 8:
9288             case 9:
9289             case 10:
9290             case 14:
9291             case 211:
9292             case 91:
9293             case 100:
9294             case 104:
9295             case 106:
9296             case 102:
9297             case 218:
9298             case 219:
9299             case 96:
9300                 return true;
9301             default:
9302                 return false;
9303         }
9304     }
9305     function isUnaryExpression(node) {
9306         return isUnaryExpressionKind(skipPartiallyEmittedExpressions(node).kind);
9307     }
9308     ts.isUnaryExpression = isUnaryExpression;
9309     function isUnaryExpressionKind(kind) {
9310         switch (kind) {
9311             case 207:
9312             case 208:
9313             case 203:
9314             case 204:
9315             case 205:
9316             case 206:
9317             case 199:
9318                 return true;
9319             default:
9320                 return isLeftHandSideExpressionKind(kind);
9321         }
9322     }
9323     function isUnaryExpressionWithWrite(expr) {
9324         switch (expr.kind) {
9325             case 208:
9326                 return true;
9327             case 207:
9328                 return expr.operator === 45 ||
9329                     expr.operator === 46;
9330             default:
9331                 return false;
9332         }
9333     }
9334     ts.isUnaryExpressionWithWrite = isUnaryExpressionWithWrite;
9335     function isExpression(node) {
9336         return isExpressionKind(skipPartiallyEmittedExpressions(node).kind);
9337     }
9338     ts.isExpression = isExpression;
9339     function isExpressionKind(kind) {
9340         switch (kind) {
9341             case 210:
9342             case 212:
9343             case 202:
9344             case 209:
9345             case 213:
9346             case 217:
9347             case 215:
9348             case 327:
9349             case 326:
9350                 return true;
9351             default:
9352                 return isUnaryExpressionKind(kind);
9353         }
9354     }
9355     function isAssertionExpression(node) {
9356         var kind = node.kind;
9357         return kind === 199
9358             || kind === 217;
9359     }
9360     ts.isAssertionExpression = isAssertionExpression;
9361     function isPartiallyEmittedExpression(node) {
9362         return node.kind === 326;
9363     }
9364     ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression;
9365     function isNotEmittedStatement(node) {
9366         return node.kind === 325;
9367     }
9368     ts.isNotEmittedStatement = isNotEmittedStatement;
9369     function isSyntheticReference(node) {
9370         return node.kind === 330;
9371     }
9372     ts.isSyntheticReference = isSyntheticReference;
9373     function isNotEmittedOrPartiallyEmittedNode(node) {
9374         return isNotEmittedStatement(node)
9375             || isPartiallyEmittedExpression(node);
9376     }
9377     ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode;
9378     function isIterationStatement(node, lookInLabeledStatements) {
9379         switch (node.kind) {
9380             case 230:
9381             case 231:
9382             case 232:
9383             case 228:
9384             case 229:
9385                 return true;
9386             case 238:
9387                 return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements);
9388         }
9389         return false;
9390     }
9391     ts.isIterationStatement = isIterationStatement;
9392     function isScopeMarker(node) {
9393         return isExportAssignment(node) || isExportDeclaration(node);
9394     }
9395     ts.isScopeMarker = isScopeMarker;
9396     function hasScopeMarker(statements) {
9397         return ts.some(statements, isScopeMarker);
9398     }
9399     ts.hasScopeMarker = hasScopeMarker;
9400     function needsScopeMarker(result) {
9401         return !ts.isAnyImportOrReExport(result) && !isExportAssignment(result) && !ts.hasModifier(result, 1) && !ts.isAmbientModule(result);
9402     }
9403     ts.needsScopeMarker = needsScopeMarker;
9404     function isExternalModuleIndicator(result) {
9405         return ts.isAnyImportOrReExport(result) || isExportAssignment(result) || ts.hasModifier(result, 1);
9406     }
9407     ts.isExternalModuleIndicator = isExternalModuleIndicator;
9408     function isForInOrOfStatement(node) {
9409         return node.kind === 231 || node.kind === 232;
9410     }
9411     ts.isForInOrOfStatement = isForInOrOfStatement;
9412     function isConciseBody(node) {
9413         return isBlock(node)
9414             || isExpression(node);
9415     }
9416     ts.isConciseBody = isConciseBody;
9417     function isFunctionBody(node) {
9418         return isBlock(node);
9419     }
9420     ts.isFunctionBody = isFunctionBody;
9421     function isForInitializer(node) {
9422         return isVariableDeclarationList(node)
9423             || isExpression(node);
9424     }
9425     ts.isForInitializer = isForInitializer;
9426     function isModuleBody(node) {
9427         var kind = node.kind;
9428         return kind === 250
9429             || kind === 249
9430             || kind === 75;
9431     }
9432     ts.isModuleBody = isModuleBody;
9433     function isNamespaceBody(node) {
9434         var kind = node.kind;
9435         return kind === 250
9436             || kind === 249;
9437     }
9438     ts.isNamespaceBody = isNamespaceBody;
9439     function isJSDocNamespaceBody(node) {
9440         var kind = node.kind;
9441         return kind === 75
9442             || kind === 249;
9443     }
9444     ts.isJSDocNamespaceBody = isJSDocNamespaceBody;
9445     function isNamedImportBindings(node) {
9446         var kind = node.kind;
9447         return kind === 257
9448             || kind === 256;
9449     }
9450     ts.isNamedImportBindings = isNamedImportBindings;
9451     function isModuleOrEnumDeclaration(node) {
9452         return node.kind === 249 || node.kind === 248;
9453     }
9454     ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration;
9455     function isDeclarationKind(kind) {
9456         return kind === 202
9457             || kind === 191
9458             || kind === 245
9459             || kind === 214
9460             || kind === 162
9461             || kind === 248
9462             || kind === 284
9463             || kind === 263
9464             || kind === 244
9465             || kind === 201
9466             || kind === 163
9467             || kind === 255
9468             || kind === 253
9469             || kind === 258
9470             || kind === 246
9471             || kind === 273
9472             || kind === 161
9473             || kind === 160
9474             || kind === 249
9475             || kind === 252
9476             || kind === 256
9477             || kind === 262
9478             || kind === 156
9479             || kind === 281
9480             || kind === 159
9481             || kind === 158
9482             || kind === 164
9483             || kind === 282
9484             || kind === 247
9485             || kind === 155
9486             || kind === 242
9487             || kind === 322
9488             || kind === 315
9489             || kind === 323;
9490     }
9491     function isDeclarationStatementKind(kind) {
9492         return kind === 244
9493             || kind === 264
9494             || kind === 245
9495             || kind === 246
9496             || kind === 247
9497             || kind === 248
9498             || kind === 249
9499             || kind === 254
9500             || kind === 253
9501             || kind === 260
9502             || kind === 259
9503             || kind === 252;
9504     }
9505     function isStatementKindButNotDeclarationKind(kind) {
9506         return kind === 234
9507             || kind === 233
9508             || kind === 241
9509             || kind === 228
9510             || kind === 226
9511             || kind === 224
9512             || kind === 231
9513             || kind === 232
9514             || kind === 230
9515             || kind === 227
9516             || kind === 238
9517             || kind === 235
9518             || kind === 237
9519             || kind === 239
9520             || kind === 240
9521             || kind === 225
9522             || kind === 229
9523             || kind === 236
9524             || kind === 325
9525             || kind === 329
9526             || kind === 328;
9527     }
9528     function isDeclaration(node) {
9529         if (node.kind === 155) {
9530             return (node.parent && node.parent.kind !== 321) || ts.isInJSFile(node);
9531         }
9532         return isDeclarationKind(node.kind);
9533     }
9534     ts.isDeclaration = isDeclaration;
9535     function isDeclarationStatement(node) {
9536         return isDeclarationStatementKind(node.kind);
9537     }
9538     ts.isDeclarationStatement = isDeclarationStatement;
9539     function isStatementButNotDeclaration(node) {
9540         return isStatementKindButNotDeclarationKind(node.kind);
9541     }
9542     ts.isStatementButNotDeclaration = isStatementButNotDeclaration;
9543     function isStatement(node) {
9544         var kind = node.kind;
9545         return isStatementKindButNotDeclarationKind(kind)
9546             || isDeclarationStatementKind(kind)
9547             || isBlockStatement(node);
9548     }
9549     ts.isStatement = isStatement;
9550     function isBlockStatement(node) {
9551         if (node.kind !== 223)
9552             return false;
9553         if (node.parent !== undefined) {
9554             if (node.parent.kind === 240 || node.parent.kind === 280) {
9555                 return false;
9556             }
9557         }
9558         return !ts.isFunctionBlock(node);
9559     }
9560     function isModuleReference(node) {
9561         var kind = node.kind;
9562         return kind === 265
9563             || kind === 153
9564             || kind === 75;
9565     }
9566     ts.isModuleReference = isModuleReference;
9567     function isJsxTagNameExpression(node) {
9568         var kind = node.kind;
9569         return kind === 104
9570             || kind === 75
9571             || kind === 194;
9572     }
9573     ts.isJsxTagNameExpression = isJsxTagNameExpression;
9574     function isJsxChild(node) {
9575         var kind = node.kind;
9576         return kind === 266
9577             || kind === 276
9578             || kind === 267
9579             || kind === 11
9580             || kind === 270;
9581     }
9582     ts.isJsxChild = isJsxChild;
9583     function isJsxAttributeLike(node) {
9584         var kind = node.kind;
9585         return kind === 273
9586             || kind === 275;
9587     }
9588     ts.isJsxAttributeLike = isJsxAttributeLike;
9589     function isStringLiteralOrJsxExpression(node) {
9590         var kind = node.kind;
9591         return kind === 10
9592             || kind === 276;
9593     }
9594     ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression;
9595     function isJsxOpeningLikeElement(node) {
9596         var kind = node.kind;
9597         return kind === 268
9598             || kind === 267;
9599     }
9600     ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement;
9601     function isCaseOrDefaultClause(node) {
9602         var kind = node.kind;
9603         return kind === 277
9604             || kind === 278;
9605     }
9606     ts.isCaseOrDefaultClause = isCaseOrDefaultClause;
9607     function isJSDocNode(node) {
9608         return node.kind >= 294 && node.kind <= 323;
9609     }
9610     ts.isJSDocNode = isJSDocNode;
9611     function isJSDocCommentContainingNode(node) {
9612         return node.kind === 303 || node.kind === 302 || isJSDocTag(node) || isJSDocTypeLiteral(node) || isJSDocSignature(node);
9613     }
9614     ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode;
9615     function isJSDocTag(node) {
9616         return node.kind >= 306 && node.kind <= 323;
9617     }
9618     ts.isJSDocTag = isJSDocTag;
9619     function isSetAccessor(node) {
9620         return node.kind === 164;
9621     }
9622     ts.isSetAccessor = isSetAccessor;
9623     function isGetAccessor(node) {
9624         return node.kind === 163;
9625     }
9626     ts.isGetAccessor = isGetAccessor;
9627     function hasJSDocNodes(node) {
9628         var jsDoc = node.jsDoc;
9629         return !!jsDoc && jsDoc.length > 0;
9630     }
9631     ts.hasJSDocNodes = hasJSDocNodes;
9632     function hasType(node) {
9633         return !!node.type;
9634     }
9635     ts.hasType = hasType;
9636     function hasInitializer(node) {
9637         return !!node.initializer;
9638     }
9639     ts.hasInitializer = hasInitializer;
9640     function hasOnlyExpressionInitializer(node) {
9641         switch (node.kind) {
9642             case 242:
9643             case 156:
9644             case 191:
9645             case 158:
9646             case 159:
9647             case 281:
9648             case 284:
9649                 return true;
9650             default:
9651                 return false;
9652         }
9653     }
9654     ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer;
9655     function isObjectLiteralElement(node) {
9656         return node.kind === 273 || node.kind === 275 || isObjectLiteralElementLike(node);
9657     }
9658     ts.isObjectLiteralElement = isObjectLiteralElement;
9659     function isTypeReferenceType(node) {
9660         return node.kind === 169 || node.kind === 216;
9661     }
9662     ts.isTypeReferenceType = isTypeReferenceType;
9663     var MAX_SMI_X86 = 1073741823;
9664     function guessIndentation(lines) {
9665         var indentation = MAX_SMI_X86;
9666         for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
9667             var line = lines_1[_i];
9668             if (!line.length) {
9669                 continue;
9670             }
9671             var i = 0;
9672             for (; i < line.length && i < indentation; i++) {
9673                 if (!ts.isWhiteSpaceLike(line.charCodeAt(i))) {
9674                     break;
9675                 }
9676             }
9677             if (i < indentation) {
9678                 indentation = i;
9679             }
9680             if (indentation === 0) {
9681                 return 0;
9682             }
9683         }
9684         return indentation === MAX_SMI_X86 ? undefined : indentation;
9685     }
9686     ts.guessIndentation = guessIndentation;
9687     function isStringLiteralLike(node) {
9688         return node.kind === 10 || node.kind === 14;
9689     }
9690     ts.isStringLiteralLike = isStringLiteralLike;
9691 })(ts || (ts = {}));
9692 var ts;
9693 (function (ts) {
9694     ts.resolvingEmptyArray = [];
9695     ts.emptyMap = ts.createMap();
9696     ts.emptyUnderscoreEscapedMap = ts.emptyMap;
9697     ts.externalHelpersModuleNameText = "tslib";
9698     ts.defaultMaximumTruncationLength = 160;
9699     ts.noTruncationMaximumTruncationLength = 1000000;
9700     function getDeclarationOfKind(symbol, kind) {
9701         var declarations = symbol.declarations;
9702         if (declarations) {
9703             for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) {
9704                 var declaration = declarations_1[_i];
9705                 if (declaration.kind === kind) {
9706                     return declaration;
9707                 }
9708             }
9709         }
9710         return undefined;
9711     }
9712     ts.getDeclarationOfKind = getDeclarationOfKind;
9713     function createUnderscoreEscapedMap() {
9714         return new ts.Map();
9715     }
9716     ts.createUnderscoreEscapedMap = createUnderscoreEscapedMap;
9717     function hasEntries(map) {
9718         return !!map && !!map.size;
9719     }
9720     ts.hasEntries = hasEntries;
9721     function createSymbolTable(symbols) {
9722         var result = ts.createMap();
9723         if (symbols) {
9724             for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
9725                 var symbol = symbols_1[_i];
9726                 result.set(symbol.escapedName, symbol);
9727             }
9728         }
9729         return result;
9730     }
9731     ts.createSymbolTable = createSymbolTable;
9732     function isTransientSymbol(symbol) {
9733         return (symbol.flags & 33554432) !== 0;
9734     }
9735     ts.isTransientSymbol = isTransientSymbol;
9736     var stringWriter = createSingleLineStringWriter();
9737     function createSingleLineStringWriter() {
9738         var str = "";
9739         var writeText = function (text) { return str += text; };
9740         return {
9741             getText: function () { return str; },
9742             write: writeText,
9743             rawWrite: writeText,
9744             writeKeyword: writeText,
9745             writeOperator: writeText,
9746             writePunctuation: writeText,
9747             writeSpace: writeText,
9748             writeStringLiteral: writeText,
9749             writeLiteral: writeText,
9750             writeParameter: writeText,
9751             writeProperty: writeText,
9752             writeSymbol: function (s, _) { return writeText(s); },
9753             writeTrailingSemicolon: writeText,
9754             writeComment: writeText,
9755             getTextPos: function () { return str.length; },
9756             getLine: function () { return 0; },
9757             getColumn: function () { return 0; },
9758             getIndent: function () { return 0; },
9759             isAtStartOfLine: function () { return false; },
9760             hasTrailingComment: function () { return false; },
9761             hasTrailingWhitespace: function () { return !!str.length && ts.isWhiteSpaceLike(str.charCodeAt(str.length - 1)); },
9762             writeLine: function () { return str += " "; },
9763             increaseIndent: ts.noop,
9764             decreaseIndent: ts.noop,
9765             clear: function () { return str = ""; },
9766             trackSymbol: ts.noop,
9767             reportInaccessibleThisError: ts.noop,
9768             reportInaccessibleUniqueSymbolError: ts.noop,
9769             reportPrivateInBaseOfClassExpression: ts.noop,
9770         };
9771     }
9772     function changesAffectModuleResolution(oldOptions, newOptions) {
9773         return oldOptions.configFilePath !== newOptions.configFilePath ||
9774             optionsHaveModuleResolutionChanges(oldOptions, newOptions);
9775     }
9776     ts.changesAffectModuleResolution = changesAffectModuleResolution;
9777     function optionsHaveModuleResolutionChanges(oldOptions, newOptions) {
9778         return ts.moduleResolutionOptionDeclarations.some(function (o) {
9779             return !isJsonEqual(getCompilerOptionValue(oldOptions, o), getCompilerOptionValue(newOptions, o));
9780         });
9781     }
9782     ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges;
9783     function findAncestor(node, callback) {
9784         while (node) {
9785             var result = callback(node);
9786             if (result === "quit") {
9787                 return undefined;
9788             }
9789             else if (result) {
9790                 return node;
9791             }
9792             node = node.parent;
9793         }
9794         return undefined;
9795     }
9796     ts.findAncestor = findAncestor;
9797     function forEachAncestor(node, callback) {
9798         while (true) {
9799             var res = callback(node);
9800             if (res === "quit")
9801                 return undefined;
9802             if (res !== undefined)
9803                 return res;
9804             if (ts.isSourceFile(node))
9805                 return undefined;
9806             node = node.parent;
9807         }
9808     }
9809     ts.forEachAncestor = forEachAncestor;
9810     function forEachEntry(map, callback) {
9811         var iterator = map.entries();
9812         for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
9813             var _a = iterResult.value, key = _a[0], value = _a[1];
9814             var result = callback(value, key);
9815             if (result) {
9816                 return result;
9817             }
9818         }
9819         return undefined;
9820     }
9821     ts.forEachEntry = forEachEntry;
9822     function forEachKey(map, callback) {
9823         var iterator = map.keys();
9824         for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
9825             var result = callback(iterResult.value);
9826             if (result) {
9827                 return result;
9828             }
9829         }
9830         return undefined;
9831     }
9832     ts.forEachKey = forEachKey;
9833     function copyEntries(source, target) {
9834         source.forEach(function (value, key) {
9835             target.set(key, value);
9836         });
9837     }
9838     ts.copyEntries = copyEntries;
9839     function arrayToSet(array, makeKey) {
9840         return ts.arrayToMap(array, makeKey || (function (s) { return s; }), ts.returnTrue);
9841     }
9842     ts.arrayToSet = arrayToSet;
9843     function cloneMap(map) {
9844         var clone = ts.createMap();
9845         copyEntries(map, clone);
9846         return clone;
9847     }
9848     ts.cloneMap = cloneMap;
9849     function usingSingleLineStringWriter(action) {
9850         var oldString = stringWriter.getText();
9851         try {
9852             action(stringWriter);
9853             return stringWriter.getText();
9854         }
9855         finally {
9856             stringWriter.clear();
9857             stringWriter.writeKeyword(oldString);
9858         }
9859     }
9860     ts.usingSingleLineStringWriter = usingSingleLineStringWriter;
9861     function getFullWidth(node) {
9862         return node.end - node.pos;
9863     }
9864     ts.getFullWidth = getFullWidth;
9865     function getResolvedModule(sourceFile, moduleNameText) {
9866         return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText);
9867     }
9868     ts.getResolvedModule = getResolvedModule;
9869     function setResolvedModule(sourceFile, moduleNameText, resolvedModule) {
9870         if (!sourceFile.resolvedModules) {
9871             sourceFile.resolvedModules = ts.createMap();
9872         }
9873         sourceFile.resolvedModules.set(moduleNameText, resolvedModule);
9874     }
9875     ts.setResolvedModule = setResolvedModule;
9876     function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) {
9877         if (!sourceFile.resolvedTypeReferenceDirectiveNames) {
9878             sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap();
9879         }
9880         sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective);
9881     }
9882     ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective;
9883     function projectReferenceIsEqualTo(oldRef, newRef) {
9884         return oldRef.path === newRef.path &&
9885             !oldRef.prepend === !newRef.prepend &&
9886             !oldRef.circular === !newRef.circular;
9887     }
9888     ts.projectReferenceIsEqualTo = projectReferenceIsEqualTo;
9889     function moduleResolutionIsEqualTo(oldResolution, newResolution) {
9890         return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport &&
9891             oldResolution.extension === newResolution.extension &&
9892             oldResolution.resolvedFileName === newResolution.resolvedFileName &&
9893             oldResolution.originalPath === newResolution.originalPath &&
9894             packageIdIsEqual(oldResolution.packageId, newResolution.packageId);
9895     }
9896     ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo;
9897     function packageIdIsEqual(a, b) {
9898         return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version;
9899     }
9900     function packageIdToString(_a) {
9901         var name = _a.name, subModuleName = _a.subModuleName, version = _a.version;
9902         var fullName = subModuleName ? name + "/" + subModuleName : name;
9903         return fullName + "@" + version;
9904     }
9905     ts.packageIdToString = packageIdToString;
9906     function typeDirectiveIsEqualTo(oldResolution, newResolution) {
9907         return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary;
9908     }
9909     ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo;
9910     function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) {
9911         ts.Debug.assert(names.length === newResolutions.length);
9912         for (var i = 0; i < names.length; i++) {
9913             var newResolution = newResolutions[i];
9914             var oldResolution = oldResolutions && oldResolutions.get(names[i]);
9915             var changed = oldResolution
9916                 ? !newResolution || !comparer(oldResolution, newResolution)
9917                 : newResolution;
9918             if (changed) {
9919                 return true;
9920             }
9921         }
9922         return false;
9923     }
9924     ts.hasChangesInResolutions = hasChangesInResolutions;
9925     function containsParseError(node) {
9926         aggregateChildData(node);
9927         return (node.flags & 262144) !== 0;
9928     }
9929     ts.containsParseError = containsParseError;
9930     function aggregateChildData(node) {
9931         if (!(node.flags & 524288)) {
9932             var thisNodeOrAnySubNodesHasError = ((node.flags & 65536) !== 0) ||
9933                 ts.forEachChild(node, containsParseError);
9934             if (thisNodeOrAnySubNodesHasError) {
9935                 node.flags |= 262144;
9936             }
9937             node.flags |= 524288;
9938         }
9939     }
9940     function getSourceFileOfNode(node) {
9941         while (node && node.kind !== 290) {
9942             node = node.parent;
9943         }
9944         return node;
9945     }
9946     ts.getSourceFileOfNode = getSourceFileOfNode;
9947     function isStatementWithLocals(node) {
9948         switch (node.kind) {
9949             case 223:
9950             case 251:
9951             case 230:
9952             case 231:
9953             case 232:
9954                 return true;
9955         }
9956         return false;
9957     }
9958     ts.isStatementWithLocals = isStatementWithLocals;
9959     function getStartPositionOfLine(line, sourceFile) {
9960         ts.Debug.assert(line >= 0);
9961         return ts.getLineStarts(sourceFile)[line];
9962     }
9963     ts.getStartPositionOfLine = getStartPositionOfLine;
9964     function nodePosToString(node) {
9965         var file = getSourceFileOfNode(node);
9966         var loc = ts.getLineAndCharacterOfPosition(file, node.pos);
9967         return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")";
9968     }
9969     ts.nodePosToString = nodePosToString;
9970     function getEndLinePosition(line, sourceFile) {
9971         ts.Debug.assert(line >= 0);
9972         var lineStarts = ts.getLineStarts(sourceFile);
9973         var lineIndex = line;
9974         var sourceText = sourceFile.text;
9975         if (lineIndex + 1 === lineStarts.length) {
9976             return sourceText.length - 1;
9977         }
9978         else {
9979             var start = lineStarts[lineIndex];
9980             var pos = lineStarts[lineIndex + 1] - 1;
9981             ts.Debug.assert(ts.isLineBreak(sourceText.charCodeAt(pos)));
9982             while (start <= pos && ts.isLineBreak(sourceText.charCodeAt(pos))) {
9983                 pos--;
9984             }
9985             return pos;
9986         }
9987     }
9988     ts.getEndLinePosition = getEndLinePosition;
9989     function isFileLevelUniqueName(sourceFile, name, hasGlobalName) {
9990         return !(hasGlobalName && hasGlobalName(name)) && !sourceFile.identifiers.has(name);
9991     }
9992     ts.isFileLevelUniqueName = isFileLevelUniqueName;
9993     function nodeIsMissing(node) {
9994         if (node === undefined) {
9995             return true;
9996         }
9997         return node.pos === node.end && node.pos >= 0 && node.kind !== 1;
9998     }
9999     ts.nodeIsMissing = nodeIsMissing;
10000     function nodeIsPresent(node) {
10001         return !nodeIsMissing(node);
10002     }
10003     ts.nodeIsPresent = nodeIsPresent;
10004     function insertStatementsAfterPrologue(to, from, isPrologueDirective) {
10005         if (from === undefined || from.length === 0)
10006             return to;
10007         var statementIndex = 0;
10008         for (; statementIndex < to.length; ++statementIndex) {
10009             if (!isPrologueDirective(to[statementIndex])) {
10010                 break;
10011             }
10012         }
10013         to.splice.apply(to, __spreadArrays([statementIndex, 0], from));
10014         return to;
10015     }
10016     function insertStatementAfterPrologue(to, statement, isPrologueDirective) {
10017         if (statement === undefined)
10018             return to;
10019         var statementIndex = 0;
10020         for (; statementIndex < to.length; ++statementIndex) {
10021             if (!isPrologueDirective(to[statementIndex])) {
10022                 break;
10023             }
10024         }
10025         to.splice(statementIndex, 0, statement);
10026         return to;
10027     }
10028     function isAnyPrologueDirective(node) {
10029         return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576);
10030     }
10031     function insertStatementsAfterStandardPrologue(to, from) {
10032         return insertStatementsAfterPrologue(to, from, isPrologueDirective);
10033     }
10034     ts.insertStatementsAfterStandardPrologue = insertStatementsAfterStandardPrologue;
10035     function insertStatementsAfterCustomPrologue(to, from) {
10036         return insertStatementsAfterPrologue(to, from, isAnyPrologueDirective);
10037     }
10038     ts.insertStatementsAfterCustomPrologue = insertStatementsAfterCustomPrologue;
10039     function insertStatementAfterStandardPrologue(to, statement) {
10040         return insertStatementAfterPrologue(to, statement, isPrologueDirective);
10041     }
10042     ts.insertStatementAfterStandardPrologue = insertStatementAfterStandardPrologue;
10043     function insertStatementAfterCustomPrologue(to, statement) {
10044         return insertStatementAfterPrologue(to, statement, isAnyPrologueDirective);
10045     }
10046     ts.insertStatementAfterCustomPrologue = insertStatementAfterCustomPrologue;
10047     function isRecognizedTripleSlashComment(text, commentPos, commentEnd) {
10048         if (text.charCodeAt(commentPos + 1) === 47 &&
10049             commentPos + 2 < commentEnd &&
10050             text.charCodeAt(commentPos + 2) === 47) {
10051             var textSubStr = text.substring(commentPos, commentEnd);
10052             return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) ||
10053                 textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ||
10054                 textSubStr.match(fullTripleSlashReferenceTypeReferenceDirectiveRegEx) ||
10055                 textSubStr.match(defaultLibReferenceRegEx) ?
10056                 true : false;
10057         }
10058         return false;
10059     }
10060     ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment;
10061     function isPinnedComment(text, start) {
10062         return text.charCodeAt(start + 1) === 42 &&
10063             text.charCodeAt(start + 2) === 33;
10064     }
10065     ts.isPinnedComment = isPinnedComment;
10066     function createCommentDirectivesMap(sourceFile, commentDirectives) {
10067         var directivesByLine = ts.createMapFromEntries(commentDirectives.map(function (commentDirective) { return ([
10068             "" + ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line,
10069             commentDirective,
10070         ]); }));
10071         var usedLines = ts.createMap();
10072         return { getUnusedExpectations: getUnusedExpectations, markUsed: markUsed };
10073         function getUnusedExpectations() {
10074             return ts.arrayFrom(directivesByLine.entries())
10075                 .filter(function (_a) {
10076                 var line = _a[0], directive = _a[1];
10077                 return directive.type === 0 && !usedLines.get(line);
10078             })
10079                 .map(function (_a) {
10080                 var _ = _a[0], directive = _a[1];
10081                 return directive;
10082             });
10083         }
10084         function markUsed(line) {
10085             if (!directivesByLine.has("" + line)) {
10086                 return false;
10087             }
10088             usedLines.set("" + line, true);
10089             return true;
10090         }
10091     }
10092     ts.createCommentDirectivesMap = createCommentDirectivesMap;
10093     function getTokenPosOfNode(node, sourceFile, includeJsDoc) {
10094         if (nodeIsMissing(node)) {
10095             return node.pos;
10096         }
10097         if (ts.isJSDocNode(node)) {
10098             return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, true);
10099         }
10100         if (includeJsDoc && ts.hasJSDocNodes(node)) {
10101             return getTokenPosOfNode(node.jsDoc[0], sourceFile);
10102         }
10103         if (node.kind === 324 && node._children.length > 0) {
10104             return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc);
10105         }
10106         return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
10107     }
10108     ts.getTokenPosOfNode = getTokenPosOfNode;
10109     function getNonDecoratorTokenPosOfNode(node, sourceFile) {
10110         if (nodeIsMissing(node) || !node.decorators) {
10111             return getTokenPosOfNode(node, sourceFile);
10112         }
10113         return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end);
10114     }
10115     ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode;
10116     function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) {
10117         if (includeTrivia === void 0) { includeTrivia = false; }
10118         return getTextOfNodeFromSourceText(sourceFile.text, node, includeTrivia);
10119     }
10120     ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile;
10121     function isJSDocTypeExpressionOrChild(node) {
10122         return !!findAncestor(node, ts.isJSDocTypeExpression);
10123     }
10124     function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) {
10125         if (includeTrivia === void 0) { includeTrivia = false; }
10126         if (nodeIsMissing(node)) {
10127             return "";
10128         }
10129         var text = sourceText.substring(includeTrivia ? node.pos : ts.skipTrivia(sourceText, node.pos), node.end);
10130         if (isJSDocTypeExpressionOrChild(node)) {
10131             text = text.replace(/(^|\r?\n|\r)\s*\*\s*/g, "$1");
10132         }
10133         return text;
10134     }
10135     ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText;
10136     function getTextOfNode(node, includeTrivia) {
10137         if (includeTrivia === void 0) { includeTrivia = false; }
10138         return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia);
10139     }
10140     ts.getTextOfNode = getTextOfNode;
10141     function getPos(range) {
10142         return range.pos;
10143     }
10144     function indexOfNode(nodeArray, node) {
10145         return ts.binarySearch(nodeArray, node, getPos, ts.compareValues);
10146     }
10147     ts.indexOfNode = indexOfNode;
10148     function getEmitFlags(node) {
10149         var emitNode = node.emitNode;
10150         return emitNode && emitNode.flags || 0;
10151     }
10152     ts.getEmitFlags = getEmitFlags;
10153     function getLiteralText(node, sourceFile, neverAsciiEscape, jsxAttributeEscape) {
10154         if (!nodeIsSynthesized(node) && node.parent && !((ts.isNumericLiteral(node) && node.numericLiteralFlags & 512) ||
10155             ts.isBigIntLiteral(node))) {
10156             return getSourceTextOfNodeFromSourceFile(sourceFile, node);
10157         }
10158         switch (node.kind) {
10159             case 10: {
10160                 var escapeText = jsxAttributeEscape ? escapeJsxAttributeString :
10161                     neverAsciiEscape || (getEmitFlags(node) & 16777216) ? escapeString :
10162                         escapeNonAsciiString;
10163                 if (node.singleQuote) {
10164                     return "'" + escapeText(node.text, 39) + "'";
10165                 }
10166                 else {
10167                     return '"' + escapeText(node.text, 34) + '"';
10168                 }
10169             }
10170             case 14:
10171             case 15:
10172             case 16:
10173             case 17: {
10174                 var escapeText = neverAsciiEscape || (getEmitFlags(node) & 16777216) ? escapeString :
10175                     escapeNonAsciiString;
10176                 var rawText = node.rawText || escapeTemplateSubstitution(escapeText(node.text, 96));
10177                 switch (node.kind) {
10178                     case 14:
10179                         return "`" + rawText + "`";
10180                     case 15:
10181                         return "`" + rawText + "${";
10182                     case 16:
10183                         return "}" + rawText + "${";
10184                     case 17:
10185                         return "}" + rawText + "`";
10186                 }
10187                 break;
10188             }
10189             case 8:
10190             case 9:
10191             case 13:
10192                 return node.text;
10193         }
10194         return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for.");
10195     }
10196     ts.getLiteralText = getLiteralText;
10197     function getTextOfConstantValue(value) {
10198         return ts.isString(value) ? '"' + escapeNonAsciiString(value) + '"' : "" + value;
10199     }
10200     ts.getTextOfConstantValue = getTextOfConstantValue;
10201     function makeIdentifierFromModuleName(moduleName) {
10202         return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_");
10203     }
10204     ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName;
10205     function isBlockOrCatchScoped(declaration) {
10206         return (ts.getCombinedNodeFlags(declaration) & 3) !== 0 ||
10207             isCatchClauseVariableDeclarationOrBindingElement(declaration);
10208     }
10209     ts.isBlockOrCatchScoped = isBlockOrCatchScoped;
10210     function isCatchClauseVariableDeclarationOrBindingElement(declaration) {
10211         var node = getRootDeclaration(declaration);
10212         return node.kind === 242 && node.parent.kind === 280;
10213     }
10214     ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement;
10215     function isAmbientModule(node) {
10216         return ts.isModuleDeclaration(node) && (node.name.kind === 10 || isGlobalScopeAugmentation(node));
10217     }
10218     ts.isAmbientModule = isAmbientModule;
10219     function isModuleWithStringLiteralName(node) {
10220         return ts.isModuleDeclaration(node) && node.name.kind === 10;
10221     }
10222     ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName;
10223     function isNonGlobalAmbientModule(node) {
10224         return ts.isModuleDeclaration(node) && ts.isStringLiteral(node.name);
10225     }
10226     ts.isNonGlobalAmbientModule = isNonGlobalAmbientModule;
10227     function isEffectiveModuleDeclaration(node) {
10228         return ts.isModuleDeclaration(node) || ts.isIdentifier(node);
10229     }
10230     ts.isEffectiveModuleDeclaration = isEffectiveModuleDeclaration;
10231     function isShorthandAmbientModuleSymbol(moduleSymbol) {
10232         return isShorthandAmbientModule(moduleSymbol.valueDeclaration);
10233     }
10234     ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol;
10235     function isShorthandAmbientModule(node) {
10236         return node && node.kind === 249 && (!node.body);
10237     }
10238     function isBlockScopedContainerTopLevel(node) {
10239         return node.kind === 290 ||
10240             node.kind === 249 ||
10241             ts.isFunctionLike(node);
10242     }
10243     ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel;
10244     function isGlobalScopeAugmentation(module) {
10245         return !!(module.flags & 1024);
10246     }
10247     ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation;
10248     function isExternalModuleAugmentation(node) {
10249         return isAmbientModule(node) && isModuleAugmentationExternal(node);
10250     }
10251     ts.isExternalModuleAugmentation = isExternalModuleAugmentation;
10252     function isModuleAugmentationExternal(node) {
10253         switch (node.parent.kind) {
10254             case 290:
10255                 return ts.isExternalModule(node.parent);
10256             case 250:
10257                 return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent);
10258         }
10259         return false;
10260     }
10261     ts.isModuleAugmentationExternal = isModuleAugmentationExternal;
10262     function getNonAugmentationDeclaration(symbol) {
10263         return ts.find(symbol.declarations, function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); });
10264     }
10265     ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration;
10266     function isEffectiveExternalModule(node, compilerOptions) {
10267         return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS) && !!node.commonJsModuleIndicator);
10268     }
10269     ts.isEffectiveExternalModule = isEffectiveExternalModule;
10270     function isEffectiveStrictModeSourceFile(node, compilerOptions) {
10271         switch (node.scriptKind) {
10272             case 1:
10273             case 3:
10274             case 2:
10275             case 4:
10276                 break;
10277             default:
10278                 return false;
10279         }
10280         if (node.isDeclarationFile) {
10281             return false;
10282         }
10283         if (getStrictOptionValue(compilerOptions, "alwaysStrict")) {
10284             return true;
10285         }
10286         if (ts.startsWithUseStrict(node.statements)) {
10287             return true;
10288         }
10289         if (ts.isExternalModule(node) || compilerOptions.isolatedModules) {
10290             if (getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) {
10291                 return true;
10292             }
10293             return !compilerOptions.noImplicitUseStrict;
10294         }
10295         return false;
10296     }
10297     ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile;
10298     function isBlockScope(node, parentNode) {
10299         switch (node.kind) {
10300             case 290:
10301             case 251:
10302             case 280:
10303             case 249:
10304             case 230:
10305             case 231:
10306             case 232:
10307             case 162:
10308             case 161:
10309             case 163:
10310             case 164:
10311             case 244:
10312             case 201:
10313             case 202:
10314                 return true;
10315             case 223:
10316                 return !ts.isFunctionLike(parentNode);
10317         }
10318         return false;
10319     }
10320     ts.isBlockScope = isBlockScope;
10321     function isDeclarationWithTypeParameters(node) {
10322         switch (node.kind) {
10323             case 315:
10324             case 322:
10325             case 305:
10326                 return true;
10327             default:
10328                 ts.assertType(node);
10329                 return isDeclarationWithTypeParameterChildren(node);
10330         }
10331     }
10332     ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters;
10333     function isDeclarationWithTypeParameterChildren(node) {
10334         switch (node.kind) {
10335             case 165:
10336             case 166:
10337             case 160:
10338             case 167:
10339             case 170:
10340             case 171:
10341             case 300:
10342             case 245:
10343             case 214:
10344             case 246:
10345             case 247:
10346             case 321:
10347             case 244:
10348             case 161:
10349             case 162:
10350             case 163:
10351             case 164:
10352             case 201:
10353             case 202:
10354                 return true;
10355             default:
10356                 ts.assertType(node);
10357                 return false;
10358         }
10359     }
10360     ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren;
10361     function isAnyImportSyntax(node) {
10362         switch (node.kind) {
10363             case 254:
10364             case 253:
10365                 return true;
10366             default:
10367                 return false;
10368         }
10369     }
10370     ts.isAnyImportSyntax = isAnyImportSyntax;
10371     function isLateVisibilityPaintedStatement(node) {
10372         switch (node.kind) {
10373             case 254:
10374             case 253:
10375             case 225:
10376             case 245:
10377             case 244:
10378             case 249:
10379             case 247:
10380             case 246:
10381             case 248:
10382                 return true;
10383             default:
10384                 return false;
10385         }
10386     }
10387     ts.isLateVisibilityPaintedStatement = isLateVisibilityPaintedStatement;
10388     function isAnyImportOrReExport(node) {
10389         return isAnyImportSyntax(node) || ts.isExportDeclaration(node);
10390     }
10391     ts.isAnyImportOrReExport = isAnyImportOrReExport;
10392     function getEnclosingBlockScopeContainer(node) {
10393         return findAncestor(node.parent, function (current) { return isBlockScope(current, current.parent); });
10394     }
10395     ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer;
10396     function declarationNameToString(name) {
10397         return !name || getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name);
10398     }
10399     ts.declarationNameToString = declarationNameToString;
10400     function getNameFromIndexInfo(info) {
10401         return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : undefined;
10402     }
10403     ts.getNameFromIndexInfo = getNameFromIndexInfo;
10404     function isComputedNonLiteralName(name) {
10405         return name.kind === 154 && !isStringOrNumericLiteralLike(name.expression);
10406     }
10407     ts.isComputedNonLiteralName = isComputedNonLiteralName;
10408     function getTextOfPropertyName(name) {
10409         switch (name.kind) {
10410             case 75:
10411             case 76:
10412                 return name.escapedText;
10413             case 10:
10414             case 8:
10415             case 14:
10416                 return ts.escapeLeadingUnderscores(name.text);
10417             case 154:
10418                 if (isStringOrNumericLiteralLike(name.expression))
10419                     return ts.escapeLeadingUnderscores(name.expression.text);
10420                 return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames");
10421             default:
10422                 return ts.Debug.assertNever(name);
10423         }
10424     }
10425     ts.getTextOfPropertyName = getTextOfPropertyName;
10426     function entityNameToString(name) {
10427         switch (name.kind) {
10428             case 104:
10429                 return "this";
10430             case 76:
10431             case 75:
10432                 return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name);
10433             case 153:
10434                 return entityNameToString(name.left) + "." + entityNameToString(name.right);
10435             case 194:
10436                 if (ts.isIdentifier(name.name) || ts.isPrivateIdentifier(name.name)) {
10437                     return entityNameToString(name.expression) + "." + entityNameToString(name.name);
10438                 }
10439                 else {
10440                     return ts.Debug.assertNever(name.name);
10441                 }
10442             default:
10443                 return ts.Debug.assertNever(name);
10444         }
10445     }
10446     ts.entityNameToString = entityNameToString;
10447     function createDiagnosticForNode(node, message, arg0, arg1, arg2, arg3) {
10448         var sourceFile = getSourceFileOfNode(node);
10449         return createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2, arg3);
10450     }
10451     ts.createDiagnosticForNode = createDiagnosticForNode;
10452     function createDiagnosticForNodeArray(sourceFile, nodes, message, arg0, arg1, arg2, arg3) {
10453         var start = ts.skipTrivia(sourceFile.text, nodes.pos);
10454         return createFileDiagnostic(sourceFile, start, nodes.end - start, message, arg0, arg1, arg2, arg3);
10455     }
10456     ts.createDiagnosticForNodeArray = createDiagnosticForNodeArray;
10457     function createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2, arg3) {
10458         var span = getErrorSpanForNode(sourceFile, node);
10459         return createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2, arg3);
10460     }
10461     ts.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile;
10462     function createDiagnosticForNodeFromMessageChain(node, messageChain, relatedInformation) {
10463         var sourceFile = getSourceFileOfNode(node);
10464         var span = getErrorSpanForNode(sourceFile, node);
10465         return {
10466             file: sourceFile,
10467             start: span.start,
10468             length: span.length,
10469             code: messageChain.code,
10470             category: messageChain.category,
10471             messageText: messageChain.next ? messageChain : messageChain.messageText,
10472             relatedInformation: relatedInformation
10473         };
10474     }
10475     ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain;
10476     function createDiagnosticForRange(sourceFile, range, message) {
10477         return {
10478             file: sourceFile,
10479             start: range.pos,
10480             length: range.end - range.pos,
10481             code: message.code,
10482             category: message.category,
10483             messageText: message.message,
10484         };
10485     }
10486     ts.createDiagnosticForRange = createDiagnosticForRange;
10487     function getSpanOfTokenAtPosition(sourceFile, pos) {
10488         var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos);
10489         scanner.scan();
10490         var start = scanner.getTokenPos();
10491         return ts.createTextSpanFromBounds(start, scanner.getTextPos());
10492     }
10493     ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition;
10494     function getErrorSpanForArrowFunction(sourceFile, node) {
10495         var pos = ts.skipTrivia(sourceFile.text, node.pos);
10496         if (node.body && node.body.kind === 223) {
10497             var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line;
10498             var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line;
10499             if (startLine < endLine) {
10500                 return ts.createTextSpan(pos, getEndLinePosition(startLine, sourceFile) - pos + 1);
10501             }
10502         }
10503         return ts.createTextSpanFromBounds(pos, node.end);
10504     }
10505     function getErrorSpanForNode(sourceFile, node) {
10506         var errorNode = node;
10507         switch (node.kind) {
10508             case 290:
10509                 var pos_1 = ts.skipTrivia(sourceFile.text, 0, false);
10510                 if (pos_1 === sourceFile.text.length) {
10511                     return ts.createTextSpan(0, 0);
10512                 }
10513                 return getSpanOfTokenAtPosition(sourceFile, pos_1);
10514             case 242:
10515             case 191:
10516             case 245:
10517             case 214:
10518             case 246:
10519             case 249:
10520             case 248:
10521             case 284:
10522             case 244:
10523             case 201:
10524             case 161:
10525             case 163:
10526             case 164:
10527             case 247:
10528             case 159:
10529             case 158:
10530                 errorNode = node.name;
10531                 break;
10532             case 202:
10533                 return getErrorSpanForArrowFunction(sourceFile, node);
10534             case 277:
10535             case 278:
10536                 var start = ts.skipTrivia(sourceFile.text, node.pos);
10537                 var end = node.statements.length > 0 ? node.statements[0].pos : node.end;
10538                 return ts.createTextSpanFromBounds(start, end);
10539         }
10540         if (errorNode === undefined) {
10541             return getSpanOfTokenAtPosition(sourceFile, node.pos);
10542         }
10543         ts.Debug.assert(!ts.isJSDoc(errorNode));
10544         var isMissing = nodeIsMissing(errorNode);
10545         var pos = isMissing || ts.isJsxText(node)
10546             ? errorNode.pos
10547             : ts.skipTrivia(sourceFile.text, errorNode.pos);
10548         if (isMissing) {
10549             ts.Debug.assert(pos === errorNode.pos, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10550             ts.Debug.assert(pos === errorNode.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10551         }
10552         else {
10553             ts.Debug.assert(pos >= errorNode.pos, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10554             ts.Debug.assert(pos <= errorNode.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10555         }
10556         return ts.createTextSpanFromBounds(pos, errorNode.end);
10557     }
10558     ts.getErrorSpanForNode = getErrorSpanForNode;
10559     function isExternalOrCommonJsModule(file) {
10560         return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined;
10561     }
10562     ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule;
10563     function isJsonSourceFile(file) {
10564         return file.scriptKind === 6;
10565     }
10566     ts.isJsonSourceFile = isJsonSourceFile;
10567     function isEnumConst(node) {
10568         return !!(ts.getCombinedModifierFlags(node) & 2048);
10569     }
10570     ts.isEnumConst = isEnumConst;
10571     function isDeclarationReadonly(declaration) {
10572         return !!(ts.getCombinedModifierFlags(declaration) & 64 && !ts.isParameterPropertyDeclaration(declaration, declaration.parent));
10573     }
10574     ts.isDeclarationReadonly = isDeclarationReadonly;
10575     function isVarConst(node) {
10576         return !!(ts.getCombinedNodeFlags(node) & 2);
10577     }
10578     ts.isVarConst = isVarConst;
10579     function isLet(node) {
10580         return !!(ts.getCombinedNodeFlags(node) & 1);
10581     }
10582     ts.isLet = isLet;
10583     function isSuperCall(n) {
10584         return n.kind === 196 && n.expression.kind === 102;
10585     }
10586     ts.isSuperCall = isSuperCall;
10587     function isImportCall(n) {
10588         return n.kind === 196 && n.expression.kind === 96;
10589     }
10590     ts.isImportCall = isImportCall;
10591     function isImportMeta(n) {
10592         return ts.isMetaProperty(n)
10593             && n.keywordToken === 96
10594             && n.name.escapedText === "meta";
10595     }
10596     ts.isImportMeta = isImportMeta;
10597     function isLiteralImportTypeNode(n) {
10598         return ts.isImportTypeNode(n) && ts.isLiteralTypeNode(n.argument) && ts.isStringLiteral(n.argument.literal);
10599     }
10600     ts.isLiteralImportTypeNode = isLiteralImportTypeNode;
10601     function isPrologueDirective(node) {
10602         return node.kind === 226
10603             && node.expression.kind === 10;
10604     }
10605     ts.isPrologueDirective = isPrologueDirective;
10606     function isCustomPrologue(node) {
10607         return !!(getEmitFlags(node) & 1048576);
10608     }
10609     ts.isCustomPrologue = isCustomPrologue;
10610     function isHoistedFunction(node) {
10611         return isCustomPrologue(node)
10612             && ts.isFunctionDeclaration(node);
10613     }
10614     ts.isHoistedFunction = isHoistedFunction;
10615     function isHoistedVariable(node) {
10616         return ts.isIdentifier(node.name)
10617             && !node.initializer;
10618     }
10619     function isHoistedVariableStatement(node) {
10620         return isCustomPrologue(node)
10621             && ts.isVariableStatement(node)
10622             && ts.every(node.declarationList.declarations, isHoistedVariable);
10623     }
10624     ts.isHoistedVariableStatement = isHoistedVariableStatement;
10625     function getLeadingCommentRangesOfNode(node, sourceFileOfNode) {
10626         return node.kind !== 11 ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined;
10627     }
10628     ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode;
10629     function getJSDocCommentRanges(node, text) {
10630         var commentRanges = (node.kind === 156 ||
10631             node.kind === 155 ||
10632             node.kind === 201 ||
10633             node.kind === 202 ||
10634             node.kind === 200) ?
10635             ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) :
10636             ts.getLeadingCommentRanges(text, node.pos);
10637         return ts.filter(commentRanges, function (comment) {
10638             return text.charCodeAt(comment.pos + 1) === 42 &&
10639                 text.charCodeAt(comment.pos + 2) === 42 &&
10640                 text.charCodeAt(comment.pos + 3) !== 47;
10641         });
10642     }
10643     ts.getJSDocCommentRanges = getJSDocCommentRanges;
10644     ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
10645     var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*<reference\s+types\s*=\s*)('|")(.+?)\2.*?\/>/;
10646     ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*<amd-dependency\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
10647     var defaultLibReferenceRegEx = /^(\/\/\/\s*<reference\s+no-default-lib\s*=\s*)('|")(.+?)\2\s*\/>/;
10648     function isPartOfTypeNode(node) {
10649         if (168 <= node.kind && node.kind <= 188) {
10650             return true;
10651         }
10652         switch (node.kind) {
10653             case 125:
10654             case 148:
10655             case 140:
10656             case 151:
10657             case 143:
10658             case 128:
10659             case 144:
10660             case 141:
10661             case 146:
10662             case 137:
10663                 return true;
10664             case 110:
10665                 return node.parent.kind !== 205;
10666             case 216:
10667                 return !isExpressionWithTypeArgumentsInClassExtendsClause(node);
10668             case 155:
10669                 return node.parent.kind === 186 || node.parent.kind === 181;
10670             case 75:
10671                 if (node.parent.kind === 153 && node.parent.right === node) {
10672                     node = node.parent;
10673                 }
10674                 else if (node.parent.kind === 194 && node.parent.name === node) {
10675                     node = node.parent;
10676                 }
10677                 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'.");
10678             case 153:
10679             case 194:
10680             case 104: {
10681                 var parent = node.parent;
10682                 if (parent.kind === 172) {
10683                     return false;
10684                 }
10685                 if (parent.kind === 188) {
10686                     return !parent.isTypeOf;
10687                 }
10688                 if (168 <= parent.kind && parent.kind <= 188) {
10689                     return true;
10690                 }
10691                 switch (parent.kind) {
10692                     case 216:
10693                         return !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
10694                     case 155:
10695                         return node === parent.constraint;
10696                     case 321:
10697                         return node === parent.constraint;
10698                     case 159:
10699                     case 158:
10700                     case 156:
10701                     case 242:
10702                         return node === parent.type;
10703                     case 244:
10704                     case 201:
10705                     case 202:
10706                     case 162:
10707                     case 161:
10708                     case 160:
10709                     case 163:
10710                     case 164:
10711                         return node === parent.type;
10712                     case 165:
10713                     case 166:
10714                     case 167:
10715                         return node === parent.type;
10716                     case 199:
10717                         return node === parent.type;
10718                     case 196:
10719                     case 197:
10720                         return ts.contains(parent.typeArguments, node);
10721                     case 198:
10722                         return false;
10723                 }
10724             }
10725         }
10726         return false;
10727     }
10728     ts.isPartOfTypeNode = isPartOfTypeNode;
10729     function isChildOfNodeWithKind(node, kind) {
10730         while (node) {
10731             if (node.kind === kind) {
10732                 return true;
10733             }
10734             node = node.parent;
10735         }
10736         return false;
10737     }
10738     ts.isChildOfNodeWithKind = isChildOfNodeWithKind;
10739     function forEachReturnStatement(body, visitor) {
10740         return traverse(body);
10741         function traverse(node) {
10742             switch (node.kind) {
10743                 case 235:
10744                     return visitor(node);
10745                 case 251:
10746                 case 223:
10747                 case 227:
10748                 case 228:
10749                 case 229:
10750                 case 230:
10751                 case 231:
10752                 case 232:
10753                 case 236:
10754                 case 237:
10755                 case 277:
10756                 case 278:
10757                 case 238:
10758                 case 240:
10759                 case 280:
10760                     return ts.forEachChild(node, traverse);
10761             }
10762         }
10763     }
10764     ts.forEachReturnStatement = forEachReturnStatement;
10765     function forEachYieldExpression(body, visitor) {
10766         return traverse(body);
10767         function traverse(node) {
10768             switch (node.kind) {
10769                 case 212:
10770                     visitor(node);
10771                     var operand = node.expression;
10772                     if (operand) {
10773                         traverse(operand);
10774                     }
10775                     return;
10776                 case 248:
10777                 case 246:
10778                 case 249:
10779                 case 247:
10780                     return;
10781                 default:
10782                     if (ts.isFunctionLike(node)) {
10783                         if (node.name && node.name.kind === 154) {
10784                             traverse(node.name.expression);
10785                             return;
10786                         }
10787                     }
10788                     else if (!isPartOfTypeNode(node)) {
10789                         ts.forEachChild(node, traverse);
10790                     }
10791             }
10792         }
10793     }
10794     ts.forEachYieldExpression = forEachYieldExpression;
10795     function getRestParameterElementType(node) {
10796         if (node && node.kind === 174) {
10797             return node.elementType;
10798         }
10799         else if (node && node.kind === 169) {
10800             return ts.singleOrUndefined(node.typeArguments);
10801         }
10802         else {
10803             return undefined;
10804         }
10805     }
10806     ts.getRestParameterElementType = getRestParameterElementType;
10807     function getMembersOfDeclaration(node) {
10808         switch (node.kind) {
10809             case 246:
10810             case 245:
10811             case 214:
10812             case 173:
10813                 return node.members;
10814             case 193:
10815                 return node.properties;
10816         }
10817     }
10818     ts.getMembersOfDeclaration = getMembersOfDeclaration;
10819     function isVariableLike(node) {
10820         if (node) {
10821             switch (node.kind) {
10822                 case 191:
10823                 case 284:
10824                 case 156:
10825                 case 281:
10826                 case 159:
10827                 case 158:
10828                 case 282:
10829                 case 242:
10830                     return true;
10831             }
10832         }
10833         return false;
10834     }
10835     ts.isVariableLike = isVariableLike;
10836     function isVariableLikeOrAccessor(node) {
10837         return isVariableLike(node) || ts.isAccessor(node);
10838     }
10839     ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor;
10840     function isVariableDeclarationInVariableStatement(node) {
10841         return node.parent.kind === 243
10842             && node.parent.parent.kind === 225;
10843     }
10844     ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement;
10845     function isValidESSymbolDeclaration(node) {
10846         return ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
10847             ts.isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) :
10848                 ts.isPropertySignature(node) && hasReadonlyModifier(node);
10849     }
10850     ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration;
10851     function introducesArgumentsExoticObject(node) {
10852         switch (node.kind) {
10853             case 161:
10854             case 160:
10855             case 162:
10856             case 163:
10857             case 164:
10858             case 244:
10859             case 201:
10860                 return true;
10861         }
10862         return false;
10863     }
10864     ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject;
10865     function unwrapInnermostStatementOfLabel(node, beforeUnwrapLabelCallback) {
10866         while (true) {
10867             if (beforeUnwrapLabelCallback) {
10868                 beforeUnwrapLabelCallback(node);
10869             }
10870             if (node.statement.kind !== 238) {
10871                 return node.statement;
10872             }
10873             node = node.statement;
10874         }
10875     }
10876     ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel;
10877     function isFunctionBlock(node) {
10878         return node && node.kind === 223 && ts.isFunctionLike(node.parent);
10879     }
10880     ts.isFunctionBlock = isFunctionBlock;
10881     function isObjectLiteralMethod(node) {
10882         return node && node.kind === 161 && node.parent.kind === 193;
10883     }
10884     ts.isObjectLiteralMethod = isObjectLiteralMethod;
10885     function isObjectLiteralOrClassExpressionMethod(node) {
10886         return node.kind === 161 &&
10887             (node.parent.kind === 193 ||
10888                 node.parent.kind === 214);
10889     }
10890     ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod;
10891     function isIdentifierTypePredicate(predicate) {
10892         return predicate && predicate.kind === 1;
10893     }
10894     ts.isIdentifierTypePredicate = isIdentifierTypePredicate;
10895     function isThisTypePredicate(predicate) {
10896         return predicate && predicate.kind === 0;
10897     }
10898     ts.isThisTypePredicate = isThisTypePredicate;
10899     function getPropertyAssignment(objectLiteral, key, key2) {
10900         return objectLiteral.properties.filter(function (property) {
10901             if (property.kind === 281) {
10902                 var propName = getTextOfPropertyName(property.name);
10903                 return key === propName || (!!key2 && key2 === propName);
10904             }
10905             return false;
10906         });
10907     }
10908     ts.getPropertyAssignment = getPropertyAssignment;
10909     function getTsConfigObjectLiteralExpression(tsConfigSourceFile) {
10910         if (tsConfigSourceFile && tsConfigSourceFile.statements.length) {
10911             var expression = tsConfigSourceFile.statements[0].expression;
10912             return ts.tryCast(expression, ts.isObjectLiteralExpression);
10913         }
10914     }
10915     ts.getTsConfigObjectLiteralExpression = getTsConfigObjectLiteralExpression;
10916     function getTsConfigPropArrayElementValue(tsConfigSourceFile, propKey, elementValue) {
10917         return ts.firstDefined(getTsConfigPropArray(tsConfigSourceFile, propKey), function (property) {
10918             return ts.isArrayLiteralExpression(property.initializer) ?
10919                 ts.find(property.initializer.elements, function (element) { return ts.isStringLiteral(element) && element.text === elementValue; }) :
10920                 undefined;
10921         });
10922     }
10923     ts.getTsConfigPropArrayElementValue = getTsConfigPropArrayElementValue;
10924     function getTsConfigPropArray(tsConfigSourceFile, propKey) {
10925         var jsonObjectLiteral = getTsConfigObjectLiteralExpression(tsConfigSourceFile);
10926         return jsonObjectLiteral ? getPropertyAssignment(jsonObjectLiteral, propKey) : ts.emptyArray;
10927     }
10928     ts.getTsConfigPropArray = getTsConfigPropArray;
10929     function getContainingFunction(node) {
10930         return findAncestor(node.parent, ts.isFunctionLike);
10931     }
10932     ts.getContainingFunction = getContainingFunction;
10933     function getContainingFunctionDeclaration(node) {
10934         return findAncestor(node.parent, ts.isFunctionLikeDeclaration);
10935     }
10936     ts.getContainingFunctionDeclaration = getContainingFunctionDeclaration;
10937     function getContainingClass(node) {
10938         return findAncestor(node.parent, ts.isClassLike);
10939     }
10940     ts.getContainingClass = getContainingClass;
10941     function getThisContainer(node, includeArrowFunctions) {
10942         ts.Debug.assert(node.kind !== 290);
10943         while (true) {
10944             node = node.parent;
10945             if (!node) {
10946                 return ts.Debug.fail();
10947             }
10948             switch (node.kind) {
10949                 case 154:
10950                     if (ts.isClassLike(node.parent.parent)) {
10951                         return node;
10952                     }
10953                     node = node.parent;
10954                     break;
10955                 case 157:
10956                     if (node.parent.kind === 156 && ts.isClassElement(node.parent.parent)) {
10957                         node = node.parent.parent;
10958                     }
10959                     else if (ts.isClassElement(node.parent)) {
10960                         node = node.parent;
10961                     }
10962                     break;
10963                 case 202:
10964                     if (!includeArrowFunctions) {
10965                         continue;
10966                     }
10967                 case 244:
10968                 case 201:
10969                 case 249:
10970                 case 159:
10971                 case 158:
10972                 case 161:
10973                 case 160:
10974                 case 162:
10975                 case 163:
10976                 case 164:
10977                 case 165:
10978                 case 166:
10979                 case 167:
10980                 case 248:
10981                 case 290:
10982                     return node;
10983             }
10984         }
10985     }
10986     ts.getThisContainer = getThisContainer;
10987     function getNewTargetContainer(node) {
10988         var container = getThisContainer(node, false);
10989         if (container) {
10990             switch (container.kind) {
10991                 case 162:
10992                 case 244:
10993                 case 201:
10994                     return container;
10995             }
10996         }
10997         return undefined;
10998     }
10999     ts.getNewTargetContainer = getNewTargetContainer;
11000     function getSuperContainer(node, stopOnFunctions) {
11001         while (true) {
11002             node = node.parent;
11003             if (!node) {
11004                 return node;
11005             }
11006             switch (node.kind) {
11007                 case 154:
11008                     node = node.parent;
11009                     break;
11010                 case 244:
11011                 case 201:
11012                 case 202:
11013                     if (!stopOnFunctions) {
11014                         continue;
11015                     }
11016                 case 159:
11017                 case 158:
11018                 case 161:
11019                 case 160:
11020                 case 162:
11021                 case 163:
11022                 case 164:
11023                     return node;
11024                 case 157:
11025                     if (node.parent.kind === 156 && ts.isClassElement(node.parent.parent)) {
11026                         node = node.parent.parent;
11027                     }
11028                     else if (ts.isClassElement(node.parent)) {
11029                         node = node.parent;
11030                     }
11031                     break;
11032             }
11033         }
11034     }
11035     ts.getSuperContainer = getSuperContainer;
11036     function getImmediatelyInvokedFunctionExpression(func) {
11037         if (func.kind === 201 || func.kind === 202) {
11038             var prev = func;
11039             var parent = func.parent;
11040             while (parent.kind === 200) {
11041                 prev = parent;
11042                 parent = parent.parent;
11043             }
11044             if (parent.kind === 196 && parent.expression === prev) {
11045                 return parent;
11046             }
11047         }
11048     }
11049     ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression;
11050     function isSuperOrSuperProperty(node) {
11051         return node.kind === 102
11052             || isSuperProperty(node);
11053     }
11054     ts.isSuperOrSuperProperty = isSuperOrSuperProperty;
11055     function isSuperProperty(node) {
11056         var kind = node.kind;
11057         return (kind === 194 || kind === 195)
11058             && node.expression.kind === 102;
11059     }
11060     ts.isSuperProperty = isSuperProperty;
11061     function isThisProperty(node) {
11062         var kind = node.kind;
11063         return (kind === 194 || kind === 195)
11064             && node.expression.kind === 104;
11065     }
11066     ts.isThisProperty = isThisProperty;
11067     function getEntityNameFromTypeNode(node) {
11068         switch (node.kind) {
11069             case 169:
11070                 return node.typeName;
11071             case 216:
11072                 return isEntityNameExpression(node.expression)
11073                     ? node.expression
11074                     : undefined;
11075             case 75:
11076             case 153:
11077                 return node;
11078         }
11079         return undefined;
11080     }
11081     ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode;
11082     function getInvokedExpression(node) {
11083         switch (node.kind) {
11084             case 198:
11085                 return node.tag;
11086             case 268:
11087             case 267:
11088                 return node.tagName;
11089             default:
11090                 return node.expression;
11091         }
11092     }
11093     ts.getInvokedExpression = getInvokedExpression;
11094     function nodeCanBeDecorated(node, parent, grandparent) {
11095         if (ts.isNamedDeclaration(node) && ts.isPrivateIdentifier(node.name)) {
11096             return false;
11097         }
11098         switch (node.kind) {
11099             case 245:
11100                 return true;
11101             case 159:
11102                 return parent.kind === 245;
11103             case 163:
11104             case 164:
11105             case 161:
11106                 return node.body !== undefined
11107                     && parent.kind === 245;
11108             case 156:
11109                 return parent.body !== undefined
11110                     && (parent.kind === 162
11111                         || parent.kind === 161
11112                         || parent.kind === 164)
11113                     && grandparent.kind === 245;
11114         }
11115         return false;
11116     }
11117     ts.nodeCanBeDecorated = nodeCanBeDecorated;
11118     function nodeIsDecorated(node, parent, grandparent) {
11119         return node.decorators !== undefined
11120             && nodeCanBeDecorated(node, parent, grandparent);
11121     }
11122     ts.nodeIsDecorated = nodeIsDecorated;
11123     function nodeOrChildIsDecorated(node, parent, grandparent) {
11124         return nodeIsDecorated(node, parent, grandparent) || childIsDecorated(node, parent);
11125     }
11126     ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated;
11127     function childIsDecorated(node, parent) {
11128         switch (node.kind) {
11129             case 245:
11130                 return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); });
11131             case 161:
11132             case 164:
11133                 return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); });
11134             default:
11135                 return false;
11136         }
11137     }
11138     ts.childIsDecorated = childIsDecorated;
11139     function isJSXTagName(node) {
11140         var parent = node.parent;
11141         if (parent.kind === 268 ||
11142             parent.kind === 267 ||
11143             parent.kind === 269) {
11144             return parent.tagName === node;
11145         }
11146         return false;
11147     }
11148     ts.isJSXTagName = isJSXTagName;
11149     function isExpressionNode(node) {
11150         switch (node.kind) {
11151             case 102:
11152             case 100:
11153             case 106:
11154             case 91:
11155             case 13:
11156             case 192:
11157             case 193:
11158             case 194:
11159             case 195:
11160             case 196:
11161             case 197:
11162             case 198:
11163             case 217:
11164             case 199:
11165             case 218:
11166             case 200:
11167             case 201:
11168             case 214:
11169             case 202:
11170             case 205:
11171             case 203:
11172             case 204:
11173             case 207:
11174             case 208:
11175             case 209:
11176             case 210:
11177             case 213:
11178             case 211:
11179             case 215:
11180             case 266:
11181             case 267:
11182             case 270:
11183             case 212:
11184             case 206:
11185             case 219:
11186                 return true;
11187             case 153:
11188                 while (node.parent.kind === 153) {
11189                     node = node.parent;
11190                 }
11191                 return node.parent.kind === 172 || isJSXTagName(node);
11192             case 75:
11193                 if (node.parent.kind === 172 || isJSXTagName(node)) {
11194                     return true;
11195                 }
11196             case 8:
11197             case 9:
11198             case 10:
11199             case 14:
11200             case 104:
11201                 return isInExpressionContext(node);
11202             default:
11203                 return false;
11204         }
11205     }
11206     ts.isExpressionNode = isExpressionNode;
11207     function isInExpressionContext(node) {
11208         var parent = node.parent;
11209         switch (parent.kind) {
11210             case 242:
11211             case 156:
11212             case 159:
11213             case 158:
11214             case 284:
11215             case 281:
11216             case 191:
11217                 return parent.initializer === node;
11218             case 226:
11219             case 227:
11220             case 228:
11221             case 229:
11222             case 235:
11223             case 236:
11224             case 237:
11225             case 277:
11226             case 239:
11227                 return parent.expression === node;
11228             case 230:
11229                 var forStatement = parent;
11230                 return (forStatement.initializer === node && forStatement.initializer.kind !== 243) ||
11231                     forStatement.condition === node ||
11232                     forStatement.incrementor === node;
11233             case 231:
11234             case 232:
11235                 var forInStatement = parent;
11236                 return (forInStatement.initializer === node && forInStatement.initializer.kind !== 243) ||
11237                     forInStatement.expression === node;
11238             case 199:
11239             case 217:
11240                 return node === parent.expression;
11241             case 221:
11242                 return node === parent.expression;
11243             case 154:
11244                 return node === parent.expression;
11245             case 157:
11246             case 276:
11247             case 275:
11248             case 283:
11249                 return true;
11250             case 216:
11251                 return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent);
11252             case 282:
11253                 return parent.objectAssignmentInitializer === node;
11254             default:
11255                 return isExpressionNode(parent);
11256         }
11257     }
11258     ts.isInExpressionContext = isInExpressionContext;
11259     function isPartOfTypeQuery(node) {
11260         while (node.kind === 153 || node.kind === 75) {
11261             node = node.parent;
11262         }
11263         return node.kind === 172;
11264     }
11265     ts.isPartOfTypeQuery = isPartOfTypeQuery;
11266     function isExternalModuleImportEqualsDeclaration(node) {
11267         return node.kind === 253 && node.moduleReference.kind === 265;
11268     }
11269     ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration;
11270     function getExternalModuleImportEqualsDeclarationExpression(node) {
11271         ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node));
11272         return node.moduleReference.expression;
11273     }
11274     ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression;
11275     function isInternalModuleImportEqualsDeclaration(node) {
11276         return node.kind === 253 && node.moduleReference.kind !== 265;
11277     }
11278     ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration;
11279     function isSourceFileJS(file) {
11280         return isInJSFile(file);
11281     }
11282     ts.isSourceFileJS = isSourceFileJS;
11283     function isSourceFileNotJS(file) {
11284         return !isInJSFile(file);
11285     }
11286     ts.isSourceFileNotJS = isSourceFileNotJS;
11287     function isInJSFile(node) {
11288         return !!node && !!(node.flags & 131072);
11289     }
11290     ts.isInJSFile = isInJSFile;
11291     function isInJsonFile(node) {
11292         return !!node && !!(node.flags & 33554432);
11293     }
11294     ts.isInJsonFile = isInJsonFile;
11295     function isSourceFileNotJson(file) {
11296         return !isJsonSourceFile(file);
11297     }
11298     ts.isSourceFileNotJson = isSourceFileNotJson;
11299     function isInJSDoc(node) {
11300         return !!node && !!(node.flags & 4194304);
11301     }
11302     ts.isInJSDoc = isInJSDoc;
11303     function isJSDocIndexSignature(node) {
11304         return ts.isTypeReferenceNode(node) &&
11305             ts.isIdentifier(node.typeName) &&
11306             node.typeName.escapedText === "Object" &&
11307             node.typeArguments && node.typeArguments.length === 2 &&
11308             (node.typeArguments[0].kind === 143 || node.typeArguments[0].kind === 140);
11309     }
11310     ts.isJSDocIndexSignature = isJSDocIndexSignature;
11311     function isRequireCall(callExpression, requireStringLiteralLikeArgument) {
11312         if (callExpression.kind !== 196) {
11313             return false;
11314         }
11315         var _a = callExpression, expression = _a.expression, args = _a.arguments;
11316         if (expression.kind !== 75 || expression.escapedText !== "require") {
11317             return false;
11318         }
11319         if (args.length !== 1) {
11320             return false;
11321         }
11322         var arg = args[0];
11323         return !requireStringLiteralLikeArgument || ts.isStringLiteralLike(arg);
11324     }
11325     ts.isRequireCall = isRequireCall;
11326     function isRequireVariableDeclaration(node, requireStringLiteralLikeArgument) {
11327         return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(node.initializer, requireStringLiteralLikeArgument);
11328     }
11329     ts.isRequireVariableDeclaration = isRequireVariableDeclaration;
11330     function isRequireVariableDeclarationStatement(node, requireStringLiteralLikeArgument) {
11331         if (requireStringLiteralLikeArgument === void 0) { requireStringLiteralLikeArgument = true; }
11332         return ts.isVariableStatement(node) && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl, requireStringLiteralLikeArgument); });
11333     }
11334     ts.isRequireVariableDeclarationStatement = isRequireVariableDeclarationStatement;
11335     function isSingleOrDoubleQuote(charCode) {
11336         return charCode === 39 || charCode === 34;
11337     }
11338     ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote;
11339     function isStringDoubleQuoted(str, sourceFile) {
11340         return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34;
11341     }
11342     ts.isStringDoubleQuoted = isStringDoubleQuoted;
11343     function getDeclarationOfExpando(node) {
11344         if (!node.parent) {
11345             return undefined;
11346         }
11347         var name;
11348         var decl;
11349         if (ts.isVariableDeclaration(node.parent) && node.parent.initializer === node) {
11350             if (!isInJSFile(node) && !isVarConst(node.parent)) {
11351                 return undefined;
11352             }
11353             name = node.parent.name;
11354             decl = node.parent;
11355         }
11356         else if (ts.isBinaryExpression(node.parent)) {
11357             var parentNode = node.parent;
11358             var parentNodeOperator = node.parent.operatorToken.kind;
11359             if (parentNodeOperator === 62 && parentNode.right === node) {
11360                 name = parentNode.left;
11361                 decl = name;
11362             }
11363             else if (parentNodeOperator === 56 || parentNodeOperator === 60) {
11364                 if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) {
11365                     name = parentNode.parent.name;
11366                     decl = parentNode.parent;
11367                 }
11368                 else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 && parentNode.parent.right === parentNode) {
11369                     name = parentNode.parent.left;
11370                     decl = name;
11371                 }
11372                 if (!name || !isBindableStaticNameExpression(name) || !isSameEntityName(name, parentNode.left)) {
11373                     return undefined;
11374                 }
11375             }
11376         }
11377         if (!name || !getExpandoInitializer(node, isPrototypeAccess(name))) {
11378             return undefined;
11379         }
11380         return decl;
11381     }
11382     ts.getDeclarationOfExpando = getDeclarationOfExpando;
11383     function isAssignmentDeclaration(decl) {
11384         return ts.isBinaryExpression(decl) || isAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl);
11385     }
11386     ts.isAssignmentDeclaration = isAssignmentDeclaration;
11387     function getEffectiveInitializer(node) {
11388         if (isInJSFile(node) && node.initializer &&
11389             ts.isBinaryExpression(node.initializer) &&
11390             (node.initializer.operatorToken.kind === 56 || node.initializer.operatorToken.kind === 60) &&
11391             node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) {
11392             return node.initializer.right;
11393         }
11394         return node.initializer;
11395     }
11396     ts.getEffectiveInitializer = getEffectiveInitializer;
11397     function getDeclaredExpandoInitializer(node) {
11398         var init = getEffectiveInitializer(node);
11399         return init && getExpandoInitializer(init, isPrototypeAccess(node.name));
11400     }
11401     ts.getDeclaredExpandoInitializer = getDeclaredExpandoInitializer;
11402     function hasExpandoValueProperty(node, isPrototypeAssignment) {
11403         return ts.forEach(node.properties, function (p) {
11404             return ts.isPropertyAssignment(p) &&
11405                 ts.isIdentifier(p.name) &&
11406                 p.name.escapedText === "value" &&
11407                 p.initializer &&
11408                 getExpandoInitializer(p.initializer, isPrototypeAssignment);
11409         });
11410     }
11411     function getAssignedExpandoInitializer(node) {
11412         if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62) {
11413             var isPrototypeAssignment = isPrototypeAccess(node.parent.left);
11414             return getExpandoInitializer(node.parent.right, isPrototypeAssignment) ||
11415                 getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment);
11416         }
11417         if (node && ts.isCallExpression(node) && isBindableObjectDefinePropertyCall(node)) {
11418             var result = hasExpandoValueProperty(node.arguments[2], node.arguments[1].text === "prototype");
11419             if (result) {
11420                 return result;
11421             }
11422         }
11423     }
11424     ts.getAssignedExpandoInitializer = getAssignedExpandoInitializer;
11425     function getExpandoInitializer(initializer, isPrototypeAssignment) {
11426         if (ts.isCallExpression(initializer)) {
11427             var e = skipParentheses(initializer.expression);
11428             return e.kind === 201 || e.kind === 202 ? initializer : undefined;
11429         }
11430         if (initializer.kind === 201 ||
11431             initializer.kind === 214 ||
11432             initializer.kind === 202) {
11433             return initializer;
11434         }
11435         if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) {
11436             return initializer;
11437         }
11438     }
11439     ts.getExpandoInitializer = getExpandoInitializer;
11440     function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) {
11441         var e = ts.isBinaryExpression(initializer)
11442             && (initializer.operatorToken.kind === 56 || initializer.operatorToken.kind === 60)
11443             && getExpandoInitializer(initializer.right, isPrototypeAssignment);
11444         if (e && isSameEntityName(name, initializer.left)) {
11445             return e;
11446         }
11447     }
11448     function isDefaultedExpandoInitializer(node) {
11449         var name = ts.isVariableDeclaration(node.parent) ? node.parent.name :
11450             ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 ? node.parent.left :
11451                 undefined;
11452         return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left);
11453     }
11454     ts.isDefaultedExpandoInitializer = isDefaultedExpandoInitializer;
11455     function getNameOfExpando(node) {
11456         if (ts.isBinaryExpression(node.parent)) {
11457             var parent = ((node.parent.operatorToken.kind === 56 || node.parent.operatorToken.kind === 60) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent;
11458             if (parent.operatorToken.kind === 62 && ts.isIdentifier(parent.left)) {
11459                 return parent.left;
11460             }
11461         }
11462         else if (ts.isVariableDeclaration(node.parent)) {
11463             return node.parent.name;
11464         }
11465     }
11466     ts.getNameOfExpando = getNameOfExpando;
11467     function isSameEntityName(name, initializer) {
11468         if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) {
11469             return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(name);
11470         }
11471         if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) &&
11472             (initializer.expression.kind === 104 ||
11473                 ts.isIdentifier(initializer.expression) &&
11474                     (initializer.expression.escapedText === "window" ||
11475                         initializer.expression.escapedText === "self" ||
11476                         initializer.expression.escapedText === "global"))) {
11477             var nameOrArgument = getNameOrArgument(initializer);
11478             if (ts.isPrivateIdentifier(nameOrArgument)) {
11479                 ts.Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access.");
11480             }
11481             return isSameEntityName(name, nameOrArgument);
11482         }
11483         if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) {
11484             return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer)
11485                 && isSameEntityName(name.expression, initializer.expression);
11486         }
11487         return false;
11488     }
11489     function getRightMostAssignedExpression(node) {
11490         while (isAssignmentExpression(node, true)) {
11491             node = node.right;
11492         }
11493         return node;
11494     }
11495     ts.getRightMostAssignedExpression = getRightMostAssignedExpression;
11496     function isExportsIdentifier(node) {
11497         return ts.isIdentifier(node) && node.escapedText === "exports";
11498     }
11499     ts.isExportsIdentifier = isExportsIdentifier;
11500     function isModuleIdentifier(node) {
11501         return ts.isIdentifier(node) && node.escapedText === "module";
11502     }
11503     ts.isModuleIdentifier = isModuleIdentifier;
11504     function isModuleExportsAccessExpression(node) {
11505         return (ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node))
11506             && isModuleIdentifier(node.expression)
11507             && getElementOrPropertyAccessName(node) === "exports";
11508     }
11509     ts.isModuleExportsAccessExpression = isModuleExportsAccessExpression;
11510     function getAssignmentDeclarationKind(expr) {
11511         var special = getAssignmentDeclarationKindWorker(expr);
11512         return special === 5 || isInJSFile(expr) ? special : 0;
11513     }
11514     ts.getAssignmentDeclarationKind = getAssignmentDeclarationKind;
11515     function isBindableObjectDefinePropertyCall(expr) {
11516         return ts.length(expr.arguments) === 3 &&
11517             ts.isPropertyAccessExpression(expr.expression) &&
11518             ts.isIdentifier(expr.expression.expression) &&
11519             ts.idText(expr.expression.expression) === "Object" &&
11520             ts.idText(expr.expression.name) === "defineProperty" &&
11521             isStringOrNumericLiteralLike(expr.arguments[1]) &&
11522             isBindableStaticNameExpression(expr.arguments[0], true);
11523     }
11524     ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall;
11525     function isLiteralLikeAccess(node) {
11526         return ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node);
11527     }
11528     ts.isLiteralLikeAccess = isLiteralLikeAccess;
11529     function isLiteralLikeElementAccess(node) {
11530         return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) ||
11531             isWellKnownSymbolSyntactically(node.argumentExpression));
11532     }
11533     ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess;
11534     function isBindableStaticAccessExpression(node, excludeThisKeyword) {
11535         return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 104 || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, true))
11536             || isBindableStaticElementAccessExpression(node, excludeThisKeyword);
11537     }
11538     ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression;
11539     function isBindableStaticElementAccessExpression(node, excludeThisKeyword) {
11540         return isLiteralLikeElementAccess(node)
11541             && ((!excludeThisKeyword && node.expression.kind === 104) ||
11542                 isEntityNameExpression(node.expression) ||
11543                 isBindableStaticAccessExpression(node.expression, true));
11544     }
11545     ts.isBindableStaticElementAccessExpression = isBindableStaticElementAccessExpression;
11546     function isBindableStaticNameExpression(node, excludeThisKeyword) {
11547         return isEntityNameExpression(node) || isBindableStaticAccessExpression(node, excludeThisKeyword);
11548     }
11549     ts.isBindableStaticNameExpression = isBindableStaticNameExpression;
11550     function getNameOrArgument(expr) {
11551         if (ts.isPropertyAccessExpression(expr)) {
11552             return expr.name;
11553         }
11554         return expr.argumentExpression;
11555     }
11556     ts.getNameOrArgument = getNameOrArgument;
11557     function getAssignmentDeclarationKindWorker(expr) {
11558         if (ts.isCallExpression(expr)) {
11559             if (!isBindableObjectDefinePropertyCall(expr)) {
11560                 return 0;
11561             }
11562             var entityName = expr.arguments[0];
11563             if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) {
11564                 return 8;
11565             }
11566             if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") {
11567                 return 9;
11568             }
11569             return 7;
11570         }
11571         if (expr.operatorToken.kind !== 62 || !isAccessExpression(expr.left)) {
11572             return 0;
11573         }
11574         if (isBindableStaticNameExpression(expr.left.expression, true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) {
11575             return 6;
11576         }
11577         return getAssignmentDeclarationPropertyAccessKind(expr.left);
11578     }
11579     function getElementOrPropertyAccessArgumentExpressionOrName(node) {
11580         if (ts.isPropertyAccessExpression(node)) {
11581             return node.name;
11582         }
11583         var arg = skipParentheses(node.argumentExpression);
11584         if (ts.isNumericLiteral(arg) || ts.isStringLiteralLike(arg)) {
11585             return arg;
11586         }
11587         return node;
11588     }
11589     ts.getElementOrPropertyAccessArgumentExpressionOrName = getElementOrPropertyAccessArgumentExpressionOrName;
11590     function getElementOrPropertyAccessName(node) {
11591         var name = getElementOrPropertyAccessArgumentExpressionOrName(node);
11592         if (name) {
11593             if (ts.isIdentifier(name)) {
11594                 return name.escapedText;
11595             }
11596             if (ts.isStringLiteralLike(name) || ts.isNumericLiteral(name)) {
11597                 return ts.escapeLeadingUnderscores(name.text);
11598             }
11599         }
11600         if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) {
11601             return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name));
11602         }
11603         return undefined;
11604     }
11605     ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName;
11606     function getAssignmentDeclarationPropertyAccessKind(lhs) {
11607         if (lhs.expression.kind === 104) {
11608             return 4;
11609         }
11610         else if (isModuleExportsAccessExpression(lhs)) {
11611             return 2;
11612         }
11613         else if (isBindableStaticNameExpression(lhs.expression, true)) {
11614             if (isPrototypeAccess(lhs.expression)) {
11615                 return 3;
11616             }
11617             var nextToLast = lhs;
11618             while (!ts.isIdentifier(nextToLast.expression)) {
11619                 nextToLast = nextToLast.expression;
11620             }
11621             var id = nextToLast.expression;
11622             if ((id.escapedText === "exports" ||
11623                 id.escapedText === "module" && getElementOrPropertyAccessName(nextToLast) === "exports") &&
11624                 isBindableStaticAccessExpression(lhs)) {
11625                 return 1;
11626             }
11627             if (isBindableStaticNameExpression(lhs, true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs))) {
11628                 return 5;
11629             }
11630         }
11631         return 0;
11632     }
11633     ts.getAssignmentDeclarationPropertyAccessKind = getAssignmentDeclarationPropertyAccessKind;
11634     function getInitializerOfBinaryExpression(expr) {
11635         while (ts.isBinaryExpression(expr.right)) {
11636             expr = expr.right;
11637         }
11638         return expr.right;
11639     }
11640     ts.getInitializerOfBinaryExpression = getInitializerOfBinaryExpression;
11641     function isPrototypePropertyAssignment(node) {
11642         return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3;
11643     }
11644     ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment;
11645     function isSpecialPropertyDeclaration(expr) {
11646         return isInJSFile(expr) &&
11647             expr.parent && expr.parent.kind === 226 &&
11648             (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) &&
11649             !!ts.getJSDocTypeTag(expr.parent);
11650     }
11651     ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration;
11652     function setValueDeclaration(symbol, node) {
11653         var valueDeclaration = symbol.valueDeclaration;
11654         if (!valueDeclaration ||
11655             !(node.flags & 8388608 && !(valueDeclaration.flags & 8388608)) &&
11656                 (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) ||
11657             (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) {
11658             symbol.valueDeclaration = node;
11659         }
11660     }
11661     ts.setValueDeclaration = setValueDeclaration;
11662     function isFunctionSymbol(symbol) {
11663         if (!symbol || !symbol.valueDeclaration) {
11664             return false;
11665         }
11666         var decl = symbol.valueDeclaration;
11667         return decl.kind === 244 || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer);
11668     }
11669     ts.isFunctionSymbol = isFunctionSymbol;
11670     function importFromModuleSpecifier(node) {
11671         return tryGetImportFromModuleSpecifier(node) || ts.Debug.failBadSyntaxKind(node.parent);
11672     }
11673     ts.importFromModuleSpecifier = importFromModuleSpecifier;
11674     function tryGetImportFromModuleSpecifier(node) {
11675         switch (node.parent.kind) {
11676             case 254:
11677             case 260:
11678                 return node.parent;
11679             case 265:
11680                 return node.parent.parent;
11681             case 196:
11682                 return isImportCall(node.parent) || isRequireCall(node.parent, false) ? node.parent : undefined;
11683             case 187:
11684                 ts.Debug.assert(ts.isStringLiteral(node));
11685                 return ts.tryCast(node.parent.parent, ts.isImportTypeNode);
11686             default:
11687                 return undefined;
11688         }
11689     }
11690     ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier;
11691     function getExternalModuleName(node) {
11692         switch (node.kind) {
11693             case 254:
11694             case 260:
11695                 return node.moduleSpecifier;
11696             case 253:
11697                 return node.moduleReference.kind === 265 ? node.moduleReference.expression : undefined;
11698             case 188:
11699                 return isLiteralImportTypeNode(node) ? node.argument.literal : undefined;
11700             default:
11701                 return ts.Debug.assertNever(node);
11702         }
11703     }
11704     ts.getExternalModuleName = getExternalModuleName;
11705     function getNamespaceDeclarationNode(node) {
11706         switch (node.kind) {
11707             case 254:
11708                 return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport);
11709             case 253:
11710                 return node;
11711             case 260:
11712                 return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport);
11713             default:
11714                 return ts.Debug.assertNever(node);
11715         }
11716     }
11717     ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode;
11718     function isDefaultImport(node) {
11719         return node.kind === 254 && !!node.importClause && !!node.importClause.name;
11720     }
11721     ts.isDefaultImport = isDefaultImport;
11722     function forEachImportClauseDeclaration(node, action) {
11723         if (node.name) {
11724             var result = action(node);
11725             if (result)
11726                 return result;
11727         }
11728         if (node.namedBindings) {
11729             var result = ts.isNamespaceImport(node.namedBindings)
11730                 ? action(node.namedBindings)
11731                 : ts.forEach(node.namedBindings.elements, action);
11732             if (result)
11733                 return result;
11734         }
11735     }
11736     ts.forEachImportClauseDeclaration = forEachImportClauseDeclaration;
11737     function hasQuestionToken(node) {
11738         if (node) {
11739             switch (node.kind) {
11740                 case 156:
11741                 case 161:
11742                 case 160:
11743                 case 282:
11744                 case 281:
11745                 case 159:
11746                 case 158:
11747                     return node.questionToken !== undefined;
11748             }
11749         }
11750         return false;
11751     }
11752     ts.hasQuestionToken = hasQuestionToken;
11753     function isJSDocConstructSignature(node) {
11754         var param = ts.isJSDocFunctionType(node) ? ts.firstOrUndefined(node.parameters) : undefined;
11755         var name = ts.tryCast(param && param.name, ts.isIdentifier);
11756         return !!name && name.escapedText === "new";
11757     }
11758     ts.isJSDocConstructSignature = isJSDocConstructSignature;
11759     function isJSDocTypeAlias(node) {
11760         return node.kind === 322 || node.kind === 315 || node.kind === 316;
11761     }
11762     ts.isJSDocTypeAlias = isJSDocTypeAlias;
11763     function isTypeAlias(node) {
11764         return isJSDocTypeAlias(node) || ts.isTypeAliasDeclaration(node);
11765     }
11766     ts.isTypeAlias = isTypeAlias;
11767     function getSourceOfAssignment(node) {
11768         return ts.isExpressionStatement(node) &&
11769             ts.isBinaryExpression(node.expression) &&
11770             node.expression.operatorToken.kind === 62
11771             ? getRightMostAssignedExpression(node.expression)
11772             : undefined;
11773     }
11774     function getSourceOfDefaultedAssignment(node) {
11775         return ts.isExpressionStatement(node) &&
11776             ts.isBinaryExpression(node.expression) &&
11777             getAssignmentDeclarationKind(node.expression) !== 0 &&
11778             ts.isBinaryExpression(node.expression.right) &&
11779             (node.expression.right.operatorToken.kind === 56 || node.expression.right.operatorToken.kind === 60)
11780             ? node.expression.right.right
11781             : undefined;
11782     }
11783     function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) {
11784         switch (node.kind) {
11785             case 225:
11786                 var v = getSingleVariableOfVariableStatement(node);
11787                 return v && v.initializer;
11788             case 159:
11789                 return node.initializer;
11790             case 281:
11791                 return node.initializer;
11792         }
11793     }
11794     ts.getSingleInitializerOfVariableStatementOrPropertyDeclaration = getSingleInitializerOfVariableStatementOrPropertyDeclaration;
11795     function getSingleVariableOfVariableStatement(node) {
11796         return ts.isVariableStatement(node) ? ts.firstOrUndefined(node.declarationList.declarations) : undefined;
11797     }
11798     function getNestedModuleDeclaration(node) {
11799         return ts.isModuleDeclaration(node) &&
11800             node.body &&
11801             node.body.kind === 249
11802             ? node.body
11803             : undefined;
11804     }
11805     function getJSDocCommentsAndTags(hostNode) {
11806         var result;
11807         if (isVariableLike(hostNode) && ts.hasInitializer(hostNode) && ts.hasJSDocNodes(hostNode.initializer)) {
11808             result = ts.append(result, ts.last(hostNode.initializer.jsDoc));
11809         }
11810         var node = hostNode;
11811         while (node && node.parent) {
11812             if (ts.hasJSDocNodes(node)) {
11813                 result = ts.append(result, ts.last(node.jsDoc));
11814             }
11815             if (node.kind === 156) {
11816                 result = ts.addRange(result, ts.getJSDocParameterTags(node));
11817                 break;
11818             }
11819             if (node.kind === 155) {
11820                 result = ts.addRange(result, ts.getJSDocTypeParameterTags(node));
11821                 break;
11822             }
11823             node = getNextJSDocCommentLocation(node);
11824         }
11825         return result || ts.emptyArray;
11826     }
11827     ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags;
11828     function getNextJSDocCommentLocation(node) {
11829         var parent = node.parent;
11830         if (parent.kind === 281 ||
11831             parent.kind === 259 ||
11832             parent.kind === 159 ||
11833             parent.kind === 226 && node.kind === 194 ||
11834             getNestedModuleDeclaration(parent) ||
11835             ts.isBinaryExpression(node) && node.operatorToken.kind === 62) {
11836             return parent;
11837         }
11838         else if (parent.parent &&
11839             (getSingleVariableOfVariableStatement(parent.parent) === node ||
11840                 ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62)) {
11841             return parent.parent;
11842         }
11843         else if (parent.parent && parent.parent.parent &&
11844             (getSingleVariableOfVariableStatement(parent.parent.parent) ||
11845                 getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node ||
11846                 getSourceOfDefaultedAssignment(parent.parent.parent))) {
11847             return parent.parent.parent;
11848         }
11849     }
11850     function getParameterSymbolFromJSDoc(node) {
11851         if (node.symbol) {
11852             return node.symbol;
11853         }
11854         if (!ts.isIdentifier(node.name)) {
11855             return undefined;
11856         }
11857         var name = node.name.escapedText;
11858         var decl = getHostSignatureFromJSDoc(node);
11859         if (!decl) {
11860             return undefined;
11861         }
11862         var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 75 && p.name.escapedText === name; });
11863         return parameter && parameter.symbol;
11864     }
11865     ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc;
11866     function getHostSignatureFromJSDoc(node) {
11867         var host = getEffectiveJSDocHost(node);
11868         return host && ts.isFunctionLike(host) ? host : undefined;
11869     }
11870     ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
11871     function getEffectiveJSDocHost(node) {
11872         var host = getJSDocHost(node);
11873         var decl = getSourceOfDefaultedAssignment(host) ||
11874             getSourceOfAssignment(host) ||
11875             getSingleInitializerOfVariableStatementOrPropertyDeclaration(host) ||
11876             getSingleVariableOfVariableStatement(host) ||
11877             getNestedModuleDeclaration(host) ||
11878             host;
11879         return decl;
11880     }
11881     ts.getEffectiveJSDocHost = getEffectiveJSDocHost;
11882     function getJSDocHost(node) {
11883         return ts.Debug.checkDefined(findAncestor(node.parent, ts.isJSDoc)).parent;
11884     }
11885     ts.getJSDocHost = getJSDocHost;
11886     function getTypeParameterFromJsDoc(node) {
11887         var name = node.name.escapedText;
11888         var typeParameters = node.parent.parent.parent.typeParameters;
11889         return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; });
11890     }
11891     ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc;
11892     function hasRestParameter(s) {
11893         var last = ts.lastOrUndefined(s.parameters);
11894         return !!last && isRestParameter(last);
11895     }
11896     ts.hasRestParameter = hasRestParameter;
11897     function isRestParameter(node) {
11898         var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type;
11899         return node.dotDotDotToken !== undefined || !!type && type.kind === 301;
11900     }
11901     ts.isRestParameter = isRestParameter;
11902     function hasTypeArguments(node) {
11903         return !!node.typeArguments;
11904     }
11905     ts.hasTypeArguments = hasTypeArguments;
11906     function getAssignmentTargetKind(node) {
11907         var parent = node.parent;
11908         while (true) {
11909             switch (parent.kind) {
11910                 case 209:
11911                     var binaryOperator = parent.operatorToken.kind;
11912                     return isAssignmentOperator(binaryOperator) && parent.left === node ?
11913                         binaryOperator === 62 ? 1 : 2 :
11914                         0;
11915                 case 207:
11916                 case 208:
11917                     var unaryOperator = parent.operator;
11918                     return unaryOperator === 45 || unaryOperator === 46 ? 2 : 0;
11919                 case 231:
11920                 case 232:
11921                     return parent.initializer === node ? 1 : 0;
11922                 case 200:
11923                 case 192:
11924                 case 213:
11925                 case 218:
11926                     node = parent;
11927                     break;
11928                 case 282:
11929                     if (parent.name !== node) {
11930                         return 0;
11931                     }
11932                     node = parent.parent;
11933                     break;
11934                 case 281:
11935                     if (parent.name === node) {
11936                         return 0;
11937                     }
11938                     node = parent.parent;
11939                     break;
11940                 default:
11941                     return 0;
11942             }
11943             parent = node.parent;
11944         }
11945     }
11946     ts.getAssignmentTargetKind = getAssignmentTargetKind;
11947     function isAssignmentTarget(node) {
11948         return getAssignmentTargetKind(node) !== 0;
11949     }
11950     ts.isAssignmentTarget = isAssignmentTarget;
11951     function isNodeWithPossibleHoistedDeclaration(node) {
11952         switch (node.kind) {
11953             case 223:
11954             case 225:
11955             case 236:
11956             case 227:
11957             case 237:
11958             case 251:
11959             case 277:
11960             case 278:
11961             case 238:
11962             case 230:
11963             case 231:
11964             case 232:
11965             case 228:
11966             case 229:
11967             case 240:
11968             case 280:
11969                 return true;
11970         }
11971         return false;
11972     }
11973     ts.isNodeWithPossibleHoistedDeclaration = isNodeWithPossibleHoistedDeclaration;
11974     function isValueSignatureDeclaration(node) {
11975         return ts.isFunctionExpression(node) || ts.isArrowFunction(node) || ts.isMethodOrAccessor(node) || ts.isFunctionDeclaration(node) || ts.isConstructorDeclaration(node);
11976     }
11977     ts.isValueSignatureDeclaration = isValueSignatureDeclaration;
11978     function walkUp(node, kind) {
11979         while (node && node.kind === kind) {
11980             node = node.parent;
11981         }
11982         return node;
11983     }
11984     function walkUpParenthesizedTypes(node) {
11985         return walkUp(node, 182);
11986     }
11987     ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes;
11988     function walkUpParenthesizedExpressions(node) {
11989         return walkUp(node, 200);
11990     }
11991     ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions;
11992     function skipParentheses(node) {
11993         return ts.skipOuterExpressions(node, 1);
11994     }
11995     ts.skipParentheses = skipParentheses;
11996     function skipParenthesesUp(node) {
11997         while (node.kind === 200) {
11998             node = node.parent;
11999         }
12000         return node;
12001     }
12002     function isDeleteTarget(node) {
12003         if (node.kind !== 194 && node.kind !== 195) {
12004             return false;
12005         }
12006         node = walkUpParenthesizedExpressions(node.parent);
12007         return node && node.kind === 203;
12008     }
12009     ts.isDeleteTarget = isDeleteTarget;
12010     function isNodeDescendantOf(node, ancestor) {
12011         while (node) {
12012             if (node === ancestor)
12013                 return true;
12014             node = node.parent;
12015         }
12016         return false;
12017     }
12018     ts.isNodeDescendantOf = isNodeDescendantOf;
12019     function isDeclarationName(name) {
12020         return !ts.isSourceFile(name) && !ts.isBindingPattern(name) && ts.isDeclaration(name.parent) && name.parent.name === name;
12021     }
12022     ts.isDeclarationName = isDeclarationName;
12023     function getDeclarationFromName(name) {
12024         var parent = name.parent;
12025         switch (name.kind) {
12026             case 10:
12027             case 14:
12028             case 8:
12029                 if (ts.isComputedPropertyName(parent))
12030                     return parent.parent;
12031             case 75:
12032                 if (ts.isDeclaration(parent)) {
12033                     return parent.name === name ? parent : undefined;
12034                 }
12035                 else if (ts.isQualifiedName(parent)) {
12036                     var tag = parent.parent;
12037                     return ts.isJSDocParameterTag(tag) && tag.name === parent ? tag : undefined;
12038                 }
12039                 else {
12040                     var binExp = parent.parent;
12041                     return ts.isBinaryExpression(binExp) &&
12042                         getAssignmentDeclarationKind(binExp) !== 0 &&
12043                         (binExp.left.symbol || binExp.symbol) &&
12044                         ts.getNameOfDeclaration(binExp) === name
12045                         ? binExp
12046                         : undefined;
12047                 }
12048             case 76:
12049                 return ts.isDeclaration(parent) && parent.name === name ? parent : undefined;
12050             default:
12051                 return undefined;
12052         }
12053     }
12054     ts.getDeclarationFromName = getDeclarationFromName;
12055     function isLiteralComputedPropertyDeclarationName(node) {
12056         return isStringOrNumericLiteralLike(node) &&
12057             node.parent.kind === 154 &&
12058             ts.isDeclaration(node.parent.parent);
12059     }
12060     ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName;
12061     function isIdentifierName(node) {
12062         var parent = node.parent;
12063         switch (parent.kind) {
12064             case 159:
12065             case 158:
12066             case 161:
12067             case 160:
12068             case 163:
12069             case 164:
12070             case 284:
12071             case 281:
12072             case 194:
12073                 return parent.name === node;
12074             case 153:
12075                 if (parent.right === node) {
12076                     while (parent.kind === 153) {
12077                         parent = parent.parent;
12078                     }
12079                     return parent.kind === 172 || parent.kind === 169;
12080                 }
12081                 return false;
12082             case 191:
12083             case 258:
12084                 return parent.propertyName === node;
12085             case 263:
12086             case 273:
12087                 return true;
12088         }
12089         return false;
12090     }
12091     ts.isIdentifierName = isIdentifierName;
12092     function isAliasSymbolDeclaration(node) {
12093         return node.kind === 253 ||
12094             node.kind === 252 ||
12095             node.kind === 255 && !!node.name ||
12096             node.kind === 256 ||
12097             node.kind === 262 ||
12098             node.kind === 258 ||
12099             node.kind === 263 ||
12100             node.kind === 259 && exportAssignmentIsAlias(node) ||
12101             ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 && exportAssignmentIsAlias(node) ||
12102             ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 && isAliasableExpression(node.parent.right) ||
12103             node.kind === 282 ||
12104             node.kind === 281 && isAliasableExpression(node.initializer);
12105     }
12106     ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration;
12107     function getAliasDeclarationFromName(node) {
12108         switch (node.parent.kind) {
12109             case 255:
12110             case 258:
12111             case 256:
12112             case 263:
12113             case 259:
12114             case 253:
12115                 return node.parent;
12116             case 153:
12117                 do {
12118                     node = node.parent;
12119                 } while (node.parent.kind === 153);
12120                 return getAliasDeclarationFromName(node);
12121         }
12122     }
12123     ts.getAliasDeclarationFromName = getAliasDeclarationFromName;
12124     function isAliasableExpression(e) {
12125         return isEntityNameExpression(e) || ts.isClassExpression(e);
12126     }
12127     ts.isAliasableExpression = isAliasableExpression;
12128     function exportAssignmentIsAlias(node) {
12129         var e = getExportAssignmentExpression(node);
12130         return isAliasableExpression(e);
12131     }
12132     ts.exportAssignmentIsAlias = exportAssignmentIsAlias;
12133     function getExportAssignmentExpression(node) {
12134         return ts.isExportAssignment(node) ? node.expression : node.right;
12135     }
12136     ts.getExportAssignmentExpression = getExportAssignmentExpression;
12137     function getPropertyAssignmentAliasLikeExpression(node) {
12138         return node.kind === 282 ? node.name : node.kind === 281 ? node.initializer :
12139             node.parent.right;
12140     }
12141     ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression;
12142     function getEffectiveBaseTypeNode(node) {
12143         var baseType = getClassExtendsHeritageElement(node);
12144         if (baseType && isInJSFile(node)) {
12145             var tag = ts.getJSDocAugmentsTag(node);
12146             if (tag) {
12147                 return tag.class;
12148             }
12149         }
12150         return baseType;
12151     }
12152     ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode;
12153     function getClassExtendsHeritageElement(node) {
12154         var heritageClause = getHeritageClause(node.heritageClauses, 90);
12155         return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined;
12156     }
12157     ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement;
12158     function getEffectiveImplementsTypeNodes(node) {
12159         if (isInJSFile(node)) {
12160             return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; });
12161         }
12162         else {
12163             var heritageClause = getHeritageClause(node.heritageClauses, 113);
12164             return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types;
12165         }
12166     }
12167     ts.getEffectiveImplementsTypeNodes = getEffectiveImplementsTypeNodes;
12168     function getAllSuperTypeNodes(node) {
12169         return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray :
12170             ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getEffectiveImplementsTypeNodes(node)) || ts.emptyArray :
12171                 ts.emptyArray;
12172     }
12173     ts.getAllSuperTypeNodes = getAllSuperTypeNodes;
12174     function getInterfaceBaseTypeNodes(node) {
12175         var heritageClause = getHeritageClause(node.heritageClauses, 90);
12176         return heritageClause ? heritageClause.types : undefined;
12177     }
12178     ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes;
12179     function getHeritageClause(clauses, kind) {
12180         if (clauses) {
12181             for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) {
12182                 var clause = clauses_1[_i];
12183                 if (clause.token === kind) {
12184                     return clause;
12185                 }
12186             }
12187         }
12188         return undefined;
12189     }
12190     ts.getHeritageClause = getHeritageClause;
12191     function getAncestor(node, kind) {
12192         while (node) {
12193             if (node.kind === kind) {
12194                 return node;
12195             }
12196             node = node.parent;
12197         }
12198         return undefined;
12199     }
12200     ts.getAncestor = getAncestor;
12201     function isKeyword(token) {
12202         return 77 <= token && token <= 152;
12203     }
12204     ts.isKeyword = isKeyword;
12205     function isContextualKeyword(token) {
12206         return 122 <= token && token <= 152;
12207     }
12208     ts.isContextualKeyword = isContextualKeyword;
12209     function isNonContextualKeyword(token) {
12210         return isKeyword(token) && !isContextualKeyword(token);
12211     }
12212     ts.isNonContextualKeyword = isNonContextualKeyword;
12213     function isFutureReservedKeyword(token) {
12214         return 113 <= token && token <= 121;
12215     }
12216     ts.isFutureReservedKeyword = isFutureReservedKeyword;
12217     function isStringANonContextualKeyword(name) {
12218         var token = ts.stringToToken(name);
12219         return token !== undefined && isNonContextualKeyword(token);
12220     }
12221     ts.isStringANonContextualKeyword = isStringANonContextualKeyword;
12222     function isStringAKeyword(name) {
12223         var token = ts.stringToToken(name);
12224         return token !== undefined && isKeyword(token);
12225     }
12226     ts.isStringAKeyword = isStringAKeyword;
12227     function isIdentifierANonContextualKeyword(_a) {
12228         var originalKeywordKind = _a.originalKeywordKind;
12229         return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind);
12230     }
12231     ts.isIdentifierANonContextualKeyword = isIdentifierANonContextualKeyword;
12232     function isTrivia(token) {
12233         return 2 <= token && token <= 7;
12234     }
12235     ts.isTrivia = isTrivia;
12236     function getFunctionFlags(node) {
12237         if (!node) {
12238             return 4;
12239         }
12240         var flags = 0;
12241         switch (node.kind) {
12242             case 244:
12243             case 201:
12244             case 161:
12245                 if (node.asteriskToken) {
12246                     flags |= 1;
12247                 }
12248             case 202:
12249                 if (hasModifier(node, 256)) {
12250                     flags |= 2;
12251                 }
12252                 break;
12253         }
12254         if (!node.body) {
12255             flags |= 4;
12256         }
12257         return flags;
12258     }
12259     ts.getFunctionFlags = getFunctionFlags;
12260     function isAsyncFunction(node) {
12261         switch (node.kind) {
12262             case 244:
12263             case 201:
12264             case 202:
12265             case 161:
12266                 return node.body !== undefined
12267                     && node.asteriskToken === undefined
12268                     && hasModifier(node, 256);
12269         }
12270         return false;
12271     }
12272     ts.isAsyncFunction = isAsyncFunction;
12273     function isStringOrNumericLiteralLike(node) {
12274         return ts.isStringLiteralLike(node) || ts.isNumericLiteral(node);
12275     }
12276     ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike;
12277     function isSignedNumericLiteral(node) {
12278         return ts.isPrefixUnaryExpression(node) && (node.operator === 39 || node.operator === 40) && ts.isNumericLiteral(node.operand);
12279     }
12280     ts.isSignedNumericLiteral = isSignedNumericLiteral;
12281     function hasDynamicName(declaration) {
12282         var name = ts.getNameOfDeclaration(declaration);
12283         return !!name && isDynamicName(name);
12284     }
12285     ts.hasDynamicName = hasDynamicName;
12286     function isDynamicName(name) {
12287         if (!(name.kind === 154 || name.kind === 195)) {
12288             return false;
12289         }
12290         var expr = ts.isElementAccessExpression(name) ? name.argumentExpression : name.expression;
12291         return !isStringOrNumericLiteralLike(expr) &&
12292             !isSignedNumericLiteral(expr) &&
12293             !isWellKnownSymbolSyntactically(expr);
12294     }
12295     ts.isDynamicName = isDynamicName;
12296     function isWellKnownSymbolSyntactically(node) {
12297         return ts.isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression);
12298     }
12299     ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically;
12300     function getPropertyNameForPropertyNameNode(name) {
12301         switch (name.kind) {
12302             case 75:
12303             case 76:
12304                 return name.escapedText;
12305             case 10:
12306             case 8:
12307                 return ts.escapeLeadingUnderscores(name.text);
12308             case 154:
12309                 var nameExpression = name.expression;
12310                 if (isWellKnownSymbolSyntactically(nameExpression)) {
12311                     return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name));
12312                 }
12313                 else if (isStringOrNumericLiteralLike(nameExpression)) {
12314                     return ts.escapeLeadingUnderscores(nameExpression.text);
12315                 }
12316                 return undefined;
12317             default:
12318                 return ts.Debug.assertNever(name);
12319         }
12320     }
12321     ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode;
12322     function isPropertyNameLiteral(node) {
12323         switch (node.kind) {
12324             case 75:
12325             case 10:
12326             case 14:
12327             case 8:
12328                 return true;
12329             default:
12330                 return false;
12331         }
12332     }
12333     ts.isPropertyNameLiteral = isPropertyNameLiteral;
12334     function getTextOfIdentifierOrLiteral(node) {
12335         return ts.isIdentifierOrPrivateIdentifier(node) ? ts.idText(node) : node.text;
12336     }
12337     ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral;
12338     function getEscapedTextOfIdentifierOrLiteral(node) {
12339         return ts.isIdentifierOrPrivateIdentifier(node) ? node.escapedText : ts.escapeLeadingUnderscores(node.text);
12340     }
12341     ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral;
12342     function getPropertyNameForUniqueESSymbol(symbol) {
12343         return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName;
12344     }
12345     ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol;
12346     function getPropertyNameForKnownSymbolName(symbolName) {
12347         return "__@" + symbolName;
12348     }
12349     ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName;
12350     function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) {
12351         return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description;
12352     }
12353     ts.getSymbolNameForPrivateIdentifier = getSymbolNameForPrivateIdentifier;
12354     function isKnownSymbol(symbol) {
12355         return ts.startsWith(symbol.escapedName, "__@");
12356     }
12357     ts.isKnownSymbol = isKnownSymbol;
12358     function isESSymbolIdentifier(node) {
12359         return node.kind === 75 && node.escapedText === "Symbol";
12360     }
12361     ts.isESSymbolIdentifier = isESSymbolIdentifier;
12362     function isPushOrUnshiftIdentifier(node) {
12363         return node.escapedText === "push" || node.escapedText === "unshift";
12364     }
12365     ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier;
12366     function isParameterDeclaration(node) {
12367         var root = getRootDeclaration(node);
12368         return root.kind === 156;
12369     }
12370     ts.isParameterDeclaration = isParameterDeclaration;
12371     function getRootDeclaration(node) {
12372         while (node.kind === 191) {
12373             node = node.parent.parent;
12374         }
12375         return node;
12376     }
12377     ts.getRootDeclaration = getRootDeclaration;
12378     function nodeStartsNewLexicalEnvironment(node) {
12379         var kind = node.kind;
12380         return kind === 162
12381             || kind === 201
12382             || kind === 244
12383             || kind === 202
12384             || kind === 161
12385             || kind === 163
12386             || kind === 164
12387             || kind === 249
12388             || kind === 290;
12389     }
12390     ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment;
12391     function nodeIsSynthesized(range) {
12392         return positionIsSynthesized(range.pos)
12393             || positionIsSynthesized(range.end);
12394     }
12395     ts.nodeIsSynthesized = nodeIsSynthesized;
12396     function getOriginalSourceFile(sourceFile) {
12397         return ts.getParseTreeNode(sourceFile, ts.isSourceFile) || sourceFile;
12398     }
12399     ts.getOriginalSourceFile = getOriginalSourceFile;
12400     function getExpressionAssociativity(expression) {
12401         var operator = getOperator(expression);
12402         var hasArguments = expression.kind === 197 && expression.arguments !== undefined;
12403         return getOperatorAssociativity(expression.kind, operator, hasArguments);
12404     }
12405     ts.getExpressionAssociativity = getExpressionAssociativity;
12406     function getOperatorAssociativity(kind, operator, hasArguments) {
12407         switch (kind) {
12408             case 197:
12409                 return hasArguments ? 0 : 1;
12410             case 207:
12411             case 204:
12412             case 205:
12413             case 203:
12414             case 206:
12415             case 210:
12416             case 212:
12417                 return 1;
12418             case 209:
12419                 switch (operator) {
12420                     case 42:
12421                     case 62:
12422                     case 63:
12423                     case 64:
12424                     case 66:
12425                     case 65:
12426                     case 67:
12427                     case 68:
12428                     case 69:
12429                     case 70:
12430                     case 71:
12431                     case 72:
12432                     case 74:
12433                     case 73:
12434                         return 1;
12435                 }
12436         }
12437         return 0;
12438     }
12439     ts.getOperatorAssociativity = getOperatorAssociativity;
12440     function getExpressionPrecedence(expression) {
12441         var operator = getOperator(expression);
12442         var hasArguments = expression.kind === 197 && expression.arguments !== undefined;
12443         return getOperatorPrecedence(expression.kind, operator, hasArguments);
12444     }
12445     ts.getExpressionPrecedence = getExpressionPrecedence;
12446     function getOperator(expression) {
12447         if (expression.kind === 209) {
12448             return expression.operatorToken.kind;
12449         }
12450         else if (expression.kind === 207 || expression.kind === 208) {
12451             return expression.operator;
12452         }
12453         else {
12454             return expression.kind;
12455         }
12456     }
12457     ts.getOperator = getOperator;
12458     function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) {
12459         switch (nodeKind) {
12460             case 327:
12461                 return 0;
12462             case 213:
12463                 return 1;
12464             case 212:
12465                 return 2;
12466             case 210:
12467                 return 4;
12468             case 209:
12469                 switch (operatorKind) {
12470                     case 27:
12471                         return 0;
12472                     case 62:
12473                     case 63:
12474                     case 64:
12475                     case 66:
12476                     case 65:
12477                     case 67:
12478                     case 68:
12479                     case 69:
12480                     case 70:
12481                     case 71:
12482                     case 72:
12483                     case 74:
12484                     case 73:
12485                         return 3;
12486                     default:
12487                         return getBinaryOperatorPrecedence(operatorKind);
12488                 }
12489             case 207:
12490             case 204:
12491             case 205:
12492             case 203:
12493             case 206:
12494                 return 16;
12495             case 208:
12496                 return 17;
12497             case 196:
12498                 return 18;
12499             case 197:
12500                 return hasArguments ? 19 : 18;
12501             case 198:
12502             case 194:
12503             case 195:
12504                 return 19;
12505             case 104:
12506             case 102:
12507             case 75:
12508             case 100:
12509             case 106:
12510             case 91:
12511             case 8:
12512             case 9:
12513             case 10:
12514             case 192:
12515             case 193:
12516             case 201:
12517             case 202:
12518             case 214:
12519             case 266:
12520             case 267:
12521             case 270:
12522             case 13:
12523             case 14:
12524             case 211:
12525             case 200:
12526             case 215:
12527                 return 20;
12528             default:
12529                 return -1;
12530         }
12531     }
12532     ts.getOperatorPrecedence = getOperatorPrecedence;
12533     function getBinaryOperatorPrecedence(kind) {
12534         switch (kind) {
12535             case 60:
12536                 return 4;
12537             case 56:
12538                 return 5;
12539             case 55:
12540                 return 6;
12541             case 51:
12542                 return 7;
12543             case 52:
12544                 return 8;
12545             case 50:
12546                 return 9;
12547             case 34:
12548             case 35:
12549             case 36:
12550             case 37:
12551                 return 10;
12552             case 29:
12553             case 31:
12554             case 32:
12555             case 33:
12556             case 98:
12557             case 97:
12558             case 123:
12559                 return 11;
12560             case 47:
12561             case 48:
12562             case 49:
12563                 return 12;
12564             case 39:
12565             case 40:
12566                 return 13;
12567             case 41:
12568             case 43:
12569             case 44:
12570                 return 14;
12571             case 42:
12572                 return 15;
12573         }
12574         return -1;
12575     }
12576     ts.getBinaryOperatorPrecedence = getBinaryOperatorPrecedence;
12577     function createDiagnosticCollection() {
12578         var nonFileDiagnostics = [];
12579         var filesWithDiagnostics = [];
12580         var fileDiagnostics = ts.createMap();
12581         var hasReadNonFileDiagnostics = false;
12582         return {
12583             add: add,
12584             lookup: lookup,
12585             getGlobalDiagnostics: getGlobalDiagnostics,
12586             getDiagnostics: getDiagnostics,
12587             reattachFileDiagnostics: reattachFileDiagnostics
12588         };
12589         function reattachFileDiagnostics(newFile) {
12590             ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; });
12591         }
12592         function lookup(diagnostic) {
12593             var diagnostics;
12594             if (diagnostic.file) {
12595                 diagnostics = fileDiagnostics.get(diagnostic.file.fileName);
12596             }
12597             else {
12598                 diagnostics = nonFileDiagnostics;
12599             }
12600             if (!diagnostics) {
12601                 return undefined;
12602             }
12603             var result = ts.binarySearch(diagnostics, diagnostic, ts.identity, compareDiagnosticsSkipRelatedInformation);
12604             if (result >= 0) {
12605                 return diagnostics[result];
12606             }
12607             return undefined;
12608         }
12609         function add(diagnostic) {
12610             var diagnostics;
12611             if (diagnostic.file) {
12612                 diagnostics = fileDiagnostics.get(diagnostic.file.fileName);
12613                 if (!diagnostics) {
12614                     diagnostics = [];
12615                     fileDiagnostics.set(diagnostic.file.fileName, diagnostics);
12616                     ts.insertSorted(filesWithDiagnostics, diagnostic.file.fileName, ts.compareStringsCaseSensitive);
12617                 }
12618             }
12619             else {
12620                 if (hasReadNonFileDiagnostics) {
12621                     hasReadNonFileDiagnostics = false;
12622                     nonFileDiagnostics = nonFileDiagnostics.slice();
12623                 }
12624                 diagnostics = nonFileDiagnostics;
12625             }
12626             ts.insertSorted(diagnostics, diagnostic, compareDiagnostics);
12627         }
12628         function getGlobalDiagnostics() {
12629             hasReadNonFileDiagnostics = true;
12630             return nonFileDiagnostics;
12631         }
12632         function getDiagnostics(fileName) {
12633             if (fileName) {
12634                 return fileDiagnostics.get(fileName) || [];
12635             }
12636             var fileDiags = ts.flatMapToMutable(filesWithDiagnostics, function (f) { return fileDiagnostics.get(f); });
12637             if (!nonFileDiagnostics.length) {
12638                 return fileDiags;
12639             }
12640             fileDiags.unshift.apply(fileDiags, nonFileDiagnostics);
12641             return fileDiags;
12642         }
12643     }
12644     ts.createDiagnosticCollection = createDiagnosticCollection;
12645     var templateSubstitutionRegExp = /\$\{/g;
12646     function escapeTemplateSubstitution(str) {
12647         return str.replace(templateSubstitutionRegExp, "\\${");
12648     }
12649     function hasInvalidEscape(template) {
12650         return template && !!(ts.isNoSubstitutionTemplateLiteral(template)
12651             ? template.templateFlags
12652             : (template.head.templateFlags || ts.some(template.templateSpans, function (span) { return !!span.literal.templateFlags; })));
12653     }
12654     ts.hasInvalidEscape = hasInvalidEscape;
12655     var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
12656     var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
12657     var backtickQuoteEscapedCharsRegExp = /[\\`]/g;
12658     var escapedCharsMap = ts.createMapFromTemplate({
12659         "\t": "\\t",
12660         "\v": "\\v",
12661         "\f": "\\f",
12662         "\b": "\\b",
12663         "\r": "\\r",
12664         "\n": "\\n",
12665         "\\": "\\\\",
12666         "\"": "\\\"",
12667         "\'": "\\\'",
12668         "\`": "\\\`",
12669         "\u2028": "\\u2028",
12670         "\u2029": "\\u2029",
12671         "\u0085": "\\u0085"
12672     });
12673     function encodeUtf16EscapeSequence(charCode) {
12674         var hexCharCode = charCode.toString(16).toUpperCase();
12675         var paddedHexCode = ("0000" + hexCharCode).slice(-4);
12676         return "\\u" + paddedHexCode;
12677     }
12678     function getReplacement(c, offset, input) {
12679         if (c.charCodeAt(0) === 0) {
12680             var lookAhead = input.charCodeAt(offset + c.length);
12681             if (lookAhead >= 48 && lookAhead <= 57) {
12682                 return "\\x00";
12683             }
12684             return "\\0";
12685         }
12686         return escapedCharsMap.get(c) || encodeUtf16EscapeSequence(c.charCodeAt(0));
12687     }
12688     function escapeString(s, quoteChar) {
12689         var escapedCharsRegExp = quoteChar === 96 ? backtickQuoteEscapedCharsRegExp :
12690             quoteChar === 39 ? singleQuoteEscapedCharsRegExp :
12691                 doubleQuoteEscapedCharsRegExp;
12692         return s.replace(escapedCharsRegExp, getReplacement);
12693     }
12694     ts.escapeString = escapeString;
12695     var nonAsciiCharacters = /[^\u0000-\u007F]/g;
12696     function escapeNonAsciiString(s, quoteChar) {
12697         s = escapeString(s, quoteChar);
12698         return nonAsciiCharacters.test(s) ?
12699             s.replace(nonAsciiCharacters, function (c) { return encodeUtf16EscapeSequence(c.charCodeAt(0)); }) :
12700             s;
12701     }
12702     ts.escapeNonAsciiString = escapeNonAsciiString;
12703     var jsxDoubleQuoteEscapedCharsRegExp = /[\"\u0000-\u001f\u2028\u2029\u0085]/g;
12704     var jsxSingleQuoteEscapedCharsRegExp = /[\'\u0000-\u001f\u2028\u2029\u0085]/g;
12705     var jsxEscapedCharsMap = ts.createMapFromTemplate({
12706         "\"": "&quot;",
12707         "\'": "&apos;"
12708     });
12709     function encodeJsxCharacterEntity(charCode) {
12710         var hexCharCode = charCode.toString(16).toUpperCase();
12711         return "&#x" + hexCharCode + ";";
12712     }
12713     function getJsxAttributeStringReplacement(c) {
12714         if (c.charCodeAt(0) === 0) {
12715             return "&#0;";
12716         }
12717         return jsxEscapedCharsMap.get(c) || encodeJsxCharacterEntity(c.charCodeAt(0));
12718     }
12719     function escapeJsxAttributeString(s, quoteChar) {
12720         var escapedCharsRegExp = quoteChar === 39 ? jsxSingleQuoteEscapedCharsRegExp :
12721             jsxDoubleQuoteEscapedCharsRegExp;
12722         return s.replace(escapedCharsRegExp, getJsxAttributeStringReplacement);
12723     }
12724     ts.escapeJsxAttributeString = escapeJsxAttributeString;
12725     function stripQuotes(name) {
12726         var length = name.length;
12727         if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && isQuoteOrBacktick(name.charCodeAt(0))) {
12728             return name.substring(1, length - 1);
12729         }
12730         return name;
12731     }
12732     ts.stripQuotes = stripQuotes;
12733     function isQuoteOrBacktick(charCode) {
12734         return charCode === 39 ||
12735             charCode === 34 ||
12736             charCode === 96;
12737     }
12738     function isIntrinsicJsxName(name) {
12739         var ch = name.charCodeAt(0);
12740         return (ch >= 97 && ch <= 122) || ts.stringContains(name, "-");
12741     }
12742     ts.isIntrinsicJsxName = isIntrinsicJsxName;
12743     var indentStrings = ["", "    "];
12744     function getIndentString(level) {
12745         if (indentStrings[level] === undefined) {
12746             indentStrings[level] = getIndentString(level - 1) + indentStrings[1];
12747         }
12748         return indentStrings[level];
12749     }
12750     ts.getIndentString = getIndentString;
12751     function getIndentSize() {
12752         return indentStrings[1].length;
12753     }
12754     ts.getIndentSize = getIndentSize;
12755     function createTextWriter(newLine) {
12756         var output;
12757         var indent;
12758         var lineStart;
12759         var lineCount;
12760         var linePos;
12761         var hasTrailingComment = false;
12762         function updateLineCountAndPosFor(s) {
12763             var lineStartsOfS = ts.computeLineStarts(s);
12764             if (lineStartsOfS.length > 1) {
12765                 lineCount = lineCount + lineStartsOfS.length - 1;
12766                 linePos = output.length - s.length + ts.last(lineStartsOfS);
12767                 lineStart = (linePos - output.length) === 0;
12768             }
12769             else {
12770                 lineStart = false;
12771             }
12772         }
12773         function writeText(s) {
12774             if (s && s.length) {
12775                 if (lineStart) {
12776                     s = getIndentString(indent) + s;
12777                     lineStart = false;
12778                 }
12779                 output += s;
12780                 updateLineCountAndPosFor(s);
12781             }
12782         }
12783         function write(s) {
12784             if (s)
12785                 hasTrailingComment = false;
12786             writeText(s);
12787         }
12788         function writeComment(s) {
12789             if (s)
12790                 hasTrailingComment = true;
12791             writeText(s);
12792         }
12793         function reset() {
12794             output = "";
12795             indent = 0;
12796             lineStart = true;
12797             lineCount = 0;
12798             linePos = 0;
12799             hasTrailingComment = false;
12800         }
12801         function rawWrite(s) {
12802             if (s !== undefined) {
12803                 output += s;
12804                 updateLineCountAndPosFor(s);
12805                 hasTrailingComment = false;
12806             }
12807         }
12808         function writeLiteral(s) {
12809             if (s && s.length) {
12810                 write(s);
12811             }
12812         }
12813         function writeLine(force) {
12814             if (!lineStart || force) {
12815                 output += newLine;
12816                 lineCount++;
12817                 linePos = output.length;
12818                 lineStart = true;
12819                 hasTrailingComment = false;
12820             }
12821         }
12822         function getTextPosWithWriteLine() {
12823             return lineStart ? output.length : (output.length + newLine.length);
12824         }
12825         reset();
12826         return {
12827             write: write,
12828             rawWrite: rawWrite,
12829             writeLiteral: writeLiteral,
12830             writeLine: writeLine,
12831             increaseIndent: function () { indent++; },
12832             decreaseIndent: function () { indent--; },
12833             getIndent: function () { return indent; },
12834             getTextPos: function () { return output.length; },
12835             getLine: function () { return lineCount; },
12836             getColumn: function () { return lineStart ? indent * getIndentSize() : output.length - linePos; },
12837             getText: function () { return output; },
12838             isAtStartOfLine: function () { return lineStart; },
12839             hasTrailingComment: function () { return hasTrailingComment; },
12840             hasTrailingWhitespace: function () { return !!output.length && ts.isWhiteSpaceLike(output.charCodeAt(output.length - 1)); },
12841             clear: reset,
12842             reportInaccessibleThisError: ts.noop,
12843             reportPrivateInBaseOfClassExpression: ts.noop,
12844             reportInaccessibleUniqueSymbolError: ts.noop,
12845             trackSymbol: ts.noop,
12846             writeKeyword: write,
12847             writeOperator: write,
12848             writeParameter: write,
12849             writeProperty: write,
12850             writePunctuation: write,
12851             writeSpace: write,
12852             writeStringLiteral: write,
12853             writeSymbol: function (s, _) { return write(s); },
12854             writeTrailingSemicolon: write,
12855             writeComment: writeComment,
12856             getTextPosWithWriteLine: getTextPosWithWriteLine
12857         };
12858     }
12859     ts.createTextWriter = createTextWriter;
12860     function getTrailingSemicolonDeferringWriter(writer) {
12861         var pendingTrailingSemicolon = false;
12862         function commitPendingTrailingSemicolon() {
12863             if (pendingTrailingSemicolon) {
12864                 writer.writeTrailingSemicolon(";");
12865                 pendingTrailingSemicolon = false;
12866             }
12867         }
12868         return __assign(__assign({}, writer), { writeTrailingSemicolon: function () {
12869                 pendingTrailingSemicolon = true;
12870             },
12871             writeLiteral: function (s) {
12872                 commitPendingTrailingSemicolon();
12873                 writer.writeLiteral(s);
12874             },
12875             writeStringLiteral: function (s) {
12876                 commitPendingTrailingSemicolon();
12877                 writer.writeStringLiteral(s);
12878             },
12879             writeSymbol: function (s, sym) {
12880                 commitPendingTrailingSemicolon();
12881                 writer.writeSymbol(s, sym);
12882             },
12883             writePunctuation: function (s) {
12884                 commitPendingTrailingSemicolon();
12885                 writer.writePunctuation(s);
12886             },
12887             writeKeyword: function (s) {
12888                 commitPendingTrailingSemicolon();
12889                 writer.writeKeyword(s);
12890             },
12891             writeOperator: function (s) {
12892                 commitPendingTrailingSemicolon();
12893                 writer.writeOperator(s);
12894             },
12895             writeParameter: function (s) {
12896                 commitPendingTrailingSemicolon();
12897                 writer.writeParameter(s);
12898             },
12899             writeSpace: function (s) {
12900                 commitPendingTrailingSemicolon();
12901                 writer.writeSpace(s);
12902             },
12903             writeProperty: function (s) {
12904                 commitPendingTrailingSemicolon();
12905                 writer.writeProperty(s);
12906             },
12907             writeComment: function (s) {
12908                 commitPendingTrailingSemicolon();
12909                 writer.writeComment(s);
12910             },
12911             writeLine: function () {
12912                 commitPendingTrailingSemicolon();
12913                 writer.writeLine();
12914             },
12915             increaseIndent: function () {
12916                 commitPendingTrailingSemicolon();
12917                 writer.increaseIndent();
12918             },
12919             decreaseIndent: function () {
12920                 commitPendingTrailingSemicolon();
12921                 writer.decreaseIndent();
12922             } });
12923     }
12924     ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter;
12925     function hostUsesCaseSensitiveFileNames(host) {
12926         return host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : false;
12927     }
12928     ts.hostUsesCaseSensitiveFileNames = hostUsesCaseSensitiveFileNames;
12929     function hostGetCanonicalFileName(host) {
12930         return ts.createGetCanonicalFileName(hostUsesCaseSensitiveFileNames(host));
12931     }
12932     ts.hostGetCanonicalFileName = hostGetCanonicalFileName;
12933     function getResolvedExternalModuleName(host, file, referenceFile) {
12934         return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName);
12935     }
12936     ts.getResolvedExternalModuleName = getResolvedExternalModuleName;
12937     function getExternalModuleNameFromDeclaration(host, resolver, declaration) {
12938         var file = resolver.getExternalModuleFileFromDeclaration(declaration);
12939         if (!file || file.isDeclarationFile) {
12940             return undefined;
12941         }
12942         return getResolvedExternalModuleName(host, file);
12943     }
12944     ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration;
12945     function getExternalModuleNameFromPath(host, fileName, referencePath) {
12946         var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); };
12947         var dir = ts.toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName);
12948         var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
12949         var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, false);
12950         var extensionless = removeFileExtension(relativePath);
12951         return referencePath ? ts.ensurePathIsNonModuleName(extensionless) : extensionless;
12952     }
12953     ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath;
12954     function getOwnEmitOutputFilePath(fileName, host, extension) {
12955         var compilerOptions = host.getCompilerOptions();
12956         var emitOutputFilePathWithoutExtension;
12957         if (compilerOptions.outDir) {
12958             emitOutputFilePathWithoutExtension = removeFileExtension(getSourceFilePathInNewDir(fileName, host, compilerOptions.outDir));
12959         }
12960         else {
12961             emitOutputFilePathWithoutExtension = removeFileExtension(fileName);
12962         }
12963         return emitOutputFilePathWithoutExtension + extension;
12964     }
12965     ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath;
12966     function getDeclarationEmitOutputFilePath(fileName, host) {
12967         return getDeclarationEmitOutputFilePathWorker(fileName, host.getCompilerOptions(), host.getCurrentDirectory(), host.getCommonSourceDirectory(), function (f) { return host.getCanonicalFileName(f); });
12968     }
12969     ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath;
12970     function getDeclarationEmitOutputFilePathWorker(fileName, options, currentDirectory, commonSourceDirectory, getCanonicalFileName) {
12971         var outputDir = options.declarationDir || options.outDir;
12972         var path = outputDir
12973             ? getSourceFilePathInNewDirWorker(fileName, outputDir, currentDirectory, commonSourceDirectory, getCanonicalFileName)
12974             : fileName;
12975         return removeFileExtension(path) + ".d.ts";
12976     }
12977     ts.getDeclarationEmitOutputFilePathWorker = getDeclarationEmitOutputFilePathWorker;
12978     function getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit) {
12979         var options = host.getCompilerOptions();
12980         if (options.outFile || options.out) {
12981             var moduleKind = getEmitModuleKind(options);
12982             var moduleEmitEnabled_1 = options.emitDeclarationOnly || moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System;
12983             return ts.filter(host.getSourceFiles(), function (sourceFile) {
12984                 return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) &&
12985                     sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit);
12986             });
12987         }
12988         else {
12989             var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile];
12990             return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit); });
12991         }
12992     }
12993     ts.getSourceFilesToEmit = getSourceFilesToEmit;
12994     function sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit) {
12995         var options = host.getCompilerOptions();
12996         return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) &&
12997             !sourceFile.isDeclarationFile &&
12998             !host.isSourceFileFromExternalLibrary(sourceFile) &&
12999             !(isJsonSourceFile(sourceFile) && host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) &&
13000             (forceDtsEmit || !host.isSourceOfProjectReferenceRedirect(sourceFile.fileName));
13001     }
13002     ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted;
13003     function getSourceFilePathInNewDir(fileName, host, newDirPath) {
13004         return getSourceFilePathInNewDirWorker(fileName, newDirPath, host.getCurrentDirectory(), host.getCommonSourceDirectory(), function (f) { return host.getCanonicalFileName(f); });
13005     }
13006     ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir;
13007     function getSourceFilePathInNewDirWorker(fileName, newDirPath, currentDirectory, commonSourceDirectory, getCanonicalFileName) {
13008         var sourceFilePath = ts.getNormalizedAbsolutePath(fileName, currentDirectory);
13009         var isSourceFileInCommonSourceDirectory = getCanonicalFileName(sourceFilePath).indexOf(getCanonicalFileName(commonSourceDirectory)) === 0;
13010         sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath;
13011         return ts.combinePaths(newDirPath, sourceFilePath);
13012     }
13013     ts.getSourceFilePathInNewDirWorker = getSourceFilePathInNewDirWorker;
13014     function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) {
13015         host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) {
13016             diagnostics.add(createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
13017         }, sourceFiles);
13018     }
13019     ts.writeFile = writeFile;
13020     function ensureDirectoriesExist(directoryPath, createDirectory, directoryExists) {
13021         if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) {
13022             var parentDirectory = ts.getDirectoryPath(directoryPath);
13023             ensureDirectoriesExist(parentDirectory, createDirectory, directoryExists);
13024             createDirectory(directoryPath);
13025         }
13026     }
13027     function writeFileEnsuringDirectories(path, data, writeByteOrderMark, writeFile, createDirectory, directoryExists) {
13028         try {
13029             writeFile(path, data, writeByteOrderMark);
13030         }
13031         catch (_a) {
13032             ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(path)), createDirectory, directoryExists);
13033             writeFile(path, data, writeByteOrderMark);
13034         }
13035     }
13036     ts.writeFileEnsuringDirectories = writeFileEnsuringDirectories;
13037     function getLineOfLocalPosition(sourceFile, pos) {
13038         var lineStarts = ts.getLineStarts(sourceFile);
13039         return ts.computeLineOfPosition(lineStarts, pos);
13040     }
13041     ts.getLineOfLocalPosition = getLineOfLocalPosition;
13042     function getLineOfLocalPositionFromLineMap(lineMap, pos) {
13043         return ts.computeLineOfPosition(lineMap, pos);
13044     }
13045     ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap;
13046     function getFirstConstructorWithBody(node) {
13047         return ts.find(node.members, function (member) { return ts.isConstructorDeclaration(member) && nodeIsPresent(member.body); });
13048     }
13049     ts.getFirstConstructorWithBody = getFirstConstructorWithBody;
13050     function getSetAccessorValueParameter(accessor) {
13051         if (accessor && accessor.parameters.length > 0) {
13052             var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]);
13053             return accessor.parameters[hasThis ? 1 : 0];
13054         }
13055     }
13056     ts.getSetAccessorValueParameter = getSetAccessorValueParameter;
13057     function getSetAccessorTypeAnnotationNode(accessor) {
13058         var parameter = getSetAccessorValueParameter(accessor);
13059         return parameter && parameter.type;
13060     }
13061     ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode;
13062     function getThisParameter(signature) {
13063         if (signature.parameters.length && !ts.isJSDocSignature(signature)) {
13064             var thisParameter = signature.parameters[0];
13065             if (parameterIsThisKeyword(thisParameter)) {
13066                 return thisParameter;
13067             }
13068         }
13069     }
13070     ts.getThisParameter = getThisParameter;
13071     function parameterIsThisKeyword(parameter) {
13072         return isThisIdentifier(parameter.name);
13073     }
13074     ts.parameterIsThisKeyword = parameterIsThisKeyword;
13075     function isThisIdentifier(node) {
13076         return !!node && node.kind === 75 && identifierIsThisKeyword(node);
13077     }
13078     ts.isThisIdentifier = isThisIdentifier;
13079     function identifierIsThisKeyword(id) {
13080         return id.originalKeywordKind === 104;
13081     }
13082     ts.identifierIsThisKeyword = identifierIsThisKeyword;
13083     function getAllAccessorDeclarations(declarations, accessor) {
13084         var firstAccessor;
13085         var secondAccessor;
13086         var getAccessor;
13087         var setAccessor;
13088         if (hasDynamicName(accessor)) {
13089             firstAccessor = accessor;
13090             if (accessor.kind === 163) {
13091                 getAccessor = accessor;
13092             }
13093             else if (accessor.kind === 164) {
13094                 setAccessor = accessor;
13095             }
13096             else {
13097                 ts.Debug.fail("Accessor has wrong kind");
13098             }
13099         }
13100         else {
13101             ts.forEach(declarations, function (member) {
13102                 if (ts.isAccessor(member)
13103                     && hasModifier(member, 32) === hasModifier(accessor, 32)) {
13104                     var memberName = getPropertyNameForPropertyNameNode(member.name);
13105                     var accessorName = getPropertyNameForPropertyNameNode(accessor.name);
13106                     if (memberName === accessorName) {
13107                         if (!firstAccessor) {
13108                             firstAccessor = member;
13109                         }
13110                         else if (!secondAccessor) {
13111                             secondAccessor = member;
13112                         }
13113                         if (member.kind === 163 && !getAccessor) {
13114                             getAccessor = member;
13115                         }
13116                         if (member.kind === 164 && !setAccessor) {
13117                             setAccessor = member;
13118                         }
13119                     }
13120                 }
13121             });
13122         }
13123         return {
13124             firstAccessor: firstAccessor,
13125             secondAccessor: secondAccessor,
13126             getAccessor: getAccessor,
13127             setAccessor: setAccessor
13128         };
13129     }
13130     ts.getAllAccessorDeclarations = getAllAccessorDeclarations;
13131     function getEffectiveTypeAnnotationNode(node) {
13132         if (!isInJSFile(node) && ts.isFunctionDeclaration(node))
13133             return undefined;
13134         var type = node.type;
13135         if (type || !isInJSFile(node))
13136             return type;
13137         return ts.isJSDocPropertyLikeTag(node) ? node.typeExpression && node.typeExpression.type : ts.getJSDocType(node);
13138     }
13139     ts.getEffectiveTypeAnnotationNode = getEffectiveTypeAnnotationNode;
13140     function getTypeAnnotationNode(node) {
13141         return node.type;
13142     }
13143     ts.getTypeAnnotationNode = getTypeAnnotationNode;
13144     function getEffectiveReturnTypeNode(node) {
13145         return ts.isJSDocSignature(node) ?
13146             node.type && node.type.typeExpression && node.type.typeExpression.type :
13147             node.type || (isInJSFile(node) ? ts.getJSDocReturnType(node) : undefined);
13148     }
13149     ts.getEffectiveReturnTypeNode = getEffectiveReturnTypeNode;
13150     function getJSDocTypeParameterDeclarations(node) {
13151         return ts.flatMap(ts.getJSDocTags(node), function (tag) { return isNonTypeAliasTemplate(tag) ? tag.typeParameters : undefined; });
13152     }
13153     ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations;
13154     function isNonTypeAliasTemplate(tag) {
13155         return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 303 && tag.parent.tags.some(isJSDocTypeAlias));
13156     }
13157     function getEffectiveSetAccessorTypeAnnotationNode(node) {
13158         var parameter = getSetAccessorValueParameter(node);
13159         return parameter && getEffectiveTypeAnnotationNode(parameter);
13160     }
13161     ts.getEffectiveSetAccessorTypeAnnotationNode = getEffectiveSetAccessorTypeAnnotationNode;
13162     function emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments) {
13163         emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, node.pos, leadingComments);
13164     }
13165     ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments;
13166     function emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, pos, leadingComments) {
13167         if (leadingComments && leadingComments.length && pos !== leadingComments[0].pos &&
13168             getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, leadingComments[0].pos)) {
13169             writer.writeLine();
13170         }
13171     }
13172     ts.emitNewLineBeforeLeadingCommentsOfPosition = emitNewLineBeforeLeadingCommentsOfPosition;
13173     function emitNewLineBeforeLeadingCommentOfPosition(lineMap, writer, pos, commentPos) {
13174         if (pos !== commentPos &&
13175             getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, commentPos)) {
13176             writer.writeLine();
13177         }
13178     }
13179     ts.emitNewLineBeforeLeadingCommentOfPosition = emitNewLineBeforeLeadingCommentOfPosition;
13180     function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) {
13181         if (comments && comments.length > 0) {
13182             if (leadingSeparator) {
13183                 writer.writeSpace(" ");
13184             }
13185             var emitInterveningSeparator = false;
13186             for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) {
13187                 var comment = comments_1[_i];
13188                 if (emitInterveningSeparator) {
13189                     writer.writeSpace(" ");
13190                     emitInterveningSeparator = false;
13191                 }
13192                 writeComment(text, lineMap, writer, comment.pos, comment.end, newLine);
13193                 if (comment.hasTrailingNewLine) {
13194                     writer.writeLine();
13195                 }
13196                 else {
13197                     emitInterveningSeparator = true;
13198                 }
13199             }
13200             if (emitInterveningSeparator && trailingSeparator) {
13201                 writer.writeSpace(" ");
13202             }
13203         }
13204     }
13205     ts.emitComments = emitComments;
13206     function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) {
13207         var leadingComments;
13208         var currentDetachedCommentInfo;
13209         if (removeComments) {
13210             if (node.pos === 0) {
13211                 leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedCommentLocal);
13212             }
13213         }
13214         else {
13215             leadingComments = ts.getLeadingCommentRanges(text, node.pos);
13216         }
13217         if (leadingComments) {
13218             var detachedComments = [];
13219             var lastComment = void 0;
13220             for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) {
13221                 var comment = leadingComments_1[_i];
13222                 if (lastComment) {
13223                     var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end);
13224                     var commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos);
13225                     if (commentLine >= lastCommentLine + 2) {
13226                         break;
13227                     }
13228                 }
13229                 detachedComments.push(comment);
13230                 lastComment = comment;
13231             }
13232             if (detachedComments.length) {
13233                 var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.last(detachedComments).end);
13234                 var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos));
13235                 if (nodeLine >= lastCommentLine + 2) {
13236                     emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments);
13237                     emitComments(text, lineMap, writer, detachedComments, false, true, newLine, writeComment);
13238                     currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.last(detachedComments).end };
13239                 }
13240             }
13241         }
13242         return currentDetachedCommentInfo;
13243         function isPinnedCommentLocal(comment) {
13244             return isPinnedComment(text, comment.pos);
13245         }
13246     }
13247     ts.emitDetachedComments = emitDetachedComments;
13248     function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) {
13249         if (text.charCodeAt(commentPos + 1) === 42) {
13250             var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos);
13251             var lineCount = lineMap.length;
13252             var firstCommentLineIndent = void 0;
13253             for (var pos = commentPos, currentLine = firstCommentLineAndCharacter.line; pos < commentEnd; currentLine++) {
13254                 var nextLineStart = (currentLine + 1) === lineCount
13255                     ? text.length + 1
13256                     : lineMap[currentLine + 1];
13257                 if (pos !== commentPos) {
13258                     if (firstCommentLineIndent === undefined) {
13259                         firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], commentPos);
13260                     }
13261                     var currentWriterIndentSpacing = writer.getIndent() * getIndentSize();
13262                     var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, pos, nextLineStart);
13263                     if (spacesToEmit > 0) {
13264                         var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize();
13265                         var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize());
13266                         writer.rawWrite(indentSizeSpaceString);
13267                         while (numberOfSingleSpacesToEmit) {
13268                             writer.rawWrite(" ");
13269                             numberOfSingleSpacesToEmit--;
13270                         }
13271                     }
13272                     else {
13273                         writer.rawWrite("");
13274                     }
13275                 }
13276                 writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart);
13277                 pos = nextLineStart;
13278             }
13279         }
13280         else {
13281             writer.writeComment(text.substring(commentPos, commentEnd));
13282         }
13283     }
13284     ts.writeCommentRange = writeCommentRange;
13285     function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) {
13286         var end = Math.min(commentEnd, nextLineStart - 1);
13287         var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, "");
13288         if (currentLineText) {
13289             writer.writeComment(currentLineText);
13290             if (end !== commentEnd) {
13291                 writer.writeLine();
13292             }
13293         }
13294         else {
13295             writer.rawWrite(newLine);
13296         }
13297     }
13298     function calculateIndent(text, pos, end) {
13299         var currentLineIndent = 0;
13300         for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) {
13301             if (text.charCodeAt(pos) === 9) {
13302                 currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize());
13303             }
13304             else {
13305                 currentLineIndent++;
13306             }
13307         }
13308         return currentLineIndent;
13309     }
13310     function hasModifiers(node) {
13311         return getModifierFlags(node) !== 0;
13312     }
13313     ts.hasModifiers = hasModifiers;
13314     function hasModifier(node, flags) {
13315         return !!getSelectedModifierFlags(node, flags);
13316     }
13317     ts.hasModifier = hasModifier;
13318     function hasStaticModifier(node) {
13319         return hasModifier(node, 32);
13320     }
13321     ts.hasStaticModifier = hasStaticModifier;
13322     function hasReadonlyModifier(node) {
13323         return hasModifier(node, 64);
13324     }
13325     ts.hasReadonlyModifier = hasReadonlyModifier;
13326     function getSelectedModifierFlags(node, flags) {
13327         return getModifierFlags(node) & flags;
13328     }
13329     ts.getSelectedModifierFlags = getSelectedModifierFlags;
13330     function getModifierFlags(node) {
13331         if (node.kind >= 0 && node.kind <= 152) {
13332             return 0;
13333         }
13334         if (node.modifierFlagsCache & 536870912) {
13335             return node.modifierFlagsCache & ~536870912;
13336         }
13337         var flags = getModifierFlagsNoCache(node);
13338         node.modifierFlagsCache = flags | 536870912;
13339         return flags;
13340     }
13341     ts.getModifierFlags = getModifierFlags;
13342     function getModifierFlagsNoCache(node) {
13343         var flags = 0;
13344         if (node.modifiers) {
13345             for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
13346                 var modifier = _a[_i];
13347                 flags |= modifierToFlag(modifier.kind);
13348             }
13349         }
13350         if (isInJSFile(node) && !!node.parent) {
13351             var tags = (ts.getJSDocPublicTag(node) ? 4 : 0)
13352                 | (ts.getJSDocPrivateTag(node) ? 8 : 0)
13353                 | (ts.getJSDocProtectedTag(node) ? 16 : 0)
13354                 | (ts.getJSDocReadonlyTag(node) ? 64 : 0);
13355             flags |= tags;
13356         }
13357         if (node.flags & 4 || (node.kind === 75 && node.isInJSDocNamespace)) {
13358             flags |= 1;
13359         }
13360         return flags;
13361     }
13362     ts.getModifierFlagsNoCache = getModifierFlagsNoCache;
13363     function modifierToFlag(token) {
13364         switch (token) {
13365             case 120: return 32;
13366             case 119: return 4;
13367             case 118: return 16;
13368             case 117: return 8;
13369             case 122: return 128;
13370             case 89: return 1;
13371             case 130: return 2;
13372             case 81: return 2048;
13373             case 84: return 512;
13374             case 126: return 256;
13375             case 138: return 64;
13376         }
13377         return 0;
13378     }
13379     ts.modifierToFlag = modifierToFlag;
13380     function isLogicalOperator(token) {
13381         return token === 56
13382             || token === 55
13383             || token === 53;
13384     }
13385     ts.isLogicalOperator = isLogicalOperator;
13386     function isAssignmentOperator(token) {
13387         return token >= 62 && token <= 74;
13388     }
13389     ts.isAssignmentOperator = isAssignmentOperator;
13390     function tryGetClassExtendingExpressionWithTypeArguments(node) {
13391         var cls = tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node);
13392         return cls && !cls.isImplements ? cls.class : undefined;
13393     }
13394     ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments;
13395     function tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node) {
13396         return ts.isExpressionWithTypeArguments(node)
13397             && ts.isHeritageClause(node.parent)
13398             && ts.isClassLike(node.parent.parent)
13399             ? { class: node.parent.parent, isImplements: node.parent.token === 113 }
13400             : undefined;
13401     }
13402     ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments;
13403     function isAssignmentExpression(node, excludeCompoundAssignment) {
13404         return ts.isBinaryExpression(node)
13405             && (excludeCompoundAssignment
13406                 ? node.operatorToken.kind === 62
13407                 : isAssignmentOperator(node.operatorToken.kind))
13408             && ts.isLeftHandSideExpression(node.left);
13409     }
13410     ts.isAssignmentExpression = isAssignmentExpression;
13411     function isDestructuringAssignment(node) {
13412         if (isAssignmentExpression(node, true)) {
13413             var kind = node.left.kind;
13414             return kind === 193
13415                 || kind === 192;
13416         }
13417         return false;
13418     }
13419     ts.isDestructuringAssignment = isDestructuringAssignment;
13420     function isExpressionWithTypeArgumentsInClassExtendsClause(node) {
13421         return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined;
13422     }
13423     ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause;
13424     function isEntityNameExpression(node) {
13425         return node.kind === 75 || isPropertyAccessEntityNameExpression(node);
13426     }
13427     ts.isEntityNameExpression = isEntityNameExpression;
13428     function getFirstIdentifier(node) {
13429         switch (node.kind) {
13430             case 75:
13431                 return node;
13432             case 153:
13433                 do {
13434                     node = node.left;
13435                 } while (node.kind !== 75);
13436                 return node;
13437             case 194:
13438                 do {
13439                     node = node.expression;
13440                 } while (node.kind !== 75);
13441                 return node;
13442         }
13443     }
13444     ts.getFirstIdentifier = getFirstIdentifier;
13445     function isDottedName(node) {
13446         return node.kind === 75 || node.kind === 104 || node.kind === 102 ||
13447             node.kind === 194 && isDottedName(node.expression) ||
13448             node.kind === 200 && isDottedName(node.expression);
13449     }
13450     ts.isDottedName = isDottedName;
13451     function isPropertyAccessEntityNameExpression(node) {
13452         return ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.name) && isEntityNameExpression(node.expression);
13453     }
13454     ts.isPropertyAccessEntityNameExpression = isPropertyAccessEntityNameExpression;
13455     function tryGetPropertyAccessOrIdentifierToString(expr) {
13456         if (ts.isPropertyAccessExpression(expr)) {
13457             var baseStr = tryGetPropertyAccessOrIdentifierToString(expr.expression);
13458             if (baseStr !== undefined) {
13459                 return baseStr + "." + expr.name;
13460             }
13461         }
13462         else if (ts.isIdentifier(expr)) {
13463             return ts.unescapeLeadingUnderscores(expr.escapedText);
13464         }
13465         return undefined;
13466     }
13467     ts.tryGetPropertyAccessOrIdentifierToString = tryGetPropertyAccessOrIdentifierToString;
13468     function isPrototypeAccess(node) {
13469         return isBindableStaticAccessExpression(node) && getElementOrPropertyAccessName(node) === "prototype";
13470     }
13471     ts.isPrototypeAccess = isPrototypeAccess;
13472     function isRightSideOfQualifiedNameOrPropertyAccess(node) {
13473         return (node.parent.kind === 153 && node.parent.right === node) ||
13474             (node.parent.kind === 194 && node.parent.name === node);
13475     }
13476     ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess;
13477     function isEmptyObjectLiteral(expression) {
13478         return expression.kind === 193 &&
13479             expression.properties.length === 0;
13480     }
13481     ts.isEmptyObjectLiteral = isEmptyObjectLiteral;
13482     function isEmptyArrayLiteral(expression) {
13483         return expression.kind === 192 &&
13484             expression.elements.length === 0;
13485     }
13486     ts.isEmptyArrayLiteral = isEmptyArrayLiteral;
13487     function getLocalSymbolForExportDefault(symbol) {
13488         return isExportDefaultSymbol(symbol) ? symbol.declarations[0].localSymbol : undefined;
13489     }
13490     ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault;
13491     function isExportDefaultSymbol(symbol) {
13492         return symbol && ts.length(symbol.declarations) > 0 && hasModifier(symbol.declarations[0], 512);
13493     }
13494     function tryExtractTSExtension(fileName) {
13495         return ts.find(ts.supportedTSExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); });
13496     }
13497     ts.tryExtractTSExtension = tryExtractTSExtension;
13498     function getExpandedCharCodes(input) {
13499         var output = [];
13500         var length = input.length;
13501         for (var i = 0; i < length; i++) {
13502             var charCode = input.charCodeAt(i);
13503             if (charCode < 0x80) {
13504                 output.push(charCode);
13505             }
13506             else if (charCode < 0x800) {
13507                 output.push((charCode >> 6) | 192);
13508                 output.push((charCode & 63) | 128);
13509             }
13510             else if (charCode < 0x10000) {
13511                 output.push((charCode >> 12) | 224);
13512                 output.push(((charCode >> 6) & 63) | 128);
13513                 output.push((charCode & 63) | 128);
13514             }
13515             else if (charCode < 0x20000) {
13516                 output.push((charCode >> 18) | 240);
13517                 output.push(((charCode >> 12) & 63) | 128);
13518                 output.push(((charCode >> 6) & 63) | 128);
13519                 output.push((charCode & 63) | 128);
13520             }
13521             else {
13522                 ts.Debug.assert(false, "Unexpected code point");
13523             }
13524         }
13525         return output;
13526     }
13527     var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
13528     function convertToBase64(input) {
13529         var result = "";
13530         var charCodes = getExpandedCharCodes(input);
13531         var i = 0;
13532         var length = charCodes.length;
13533         var byte1, byte2, byte3, byte4;
13534         while (i < length) {
13535             byte1 = charCodes[i] >> 2;
13536             byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4;
13537             byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6;
13538             byte4 = charCodes[i + 2] & 63;
13539             if (i + 1 >= length) {
13540                 byte3 = byte4 = 64;
13541             }
13542             else if (i + 2 >= length) {
13543                 byte4 = 64;
13544             }
13545             result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4);
13546             i += 3;
13547         }
13548         return result;
13549     }
13550     ts.convertToBase64 = convertToBase64;
13551     function getStringFromExpandedCharCodes(codes) {
13552         var output = "";
13553         var i = 0;
13554         var length = codes.length;
13555         while (i < length) {
13556             var charCode = codes[i];
13557             if (charCode < 0x80) {
13558                 output += String.fromCharCode(charCode);
13559                 i++;
13560             }
13561             else if ((charCode & 192) === 192) {
13562                 var value = charCode & 63;
13563                 i++;
13564                 var nextCode = codes[i];
13565                 while ((nextCode & 192) === 128) {
13566                     value = (value << 6) | (nextCode & 63);
13567                     i++;
13568                     nextCode = codes[i];
13569                 }
13570                 output += String.fromCharCode(value);
13571             }
13572             else {
13573                 output += String.fromCharCode(charCode);
13574                 i++;
13575             }
13576         }
13577         return output;
13578     }
13579     function base64encode(host, input) {
13580         if (host && host.base64encode) {
13581             return host.base64encode(input);
13582         }
13583         return convertToBase64(input);
13584     }
13585     ts.base64encode = base64encode;
13586     function base64decode(host, input) {
13587         if (host && host.base64decode) {
13588             return host.base64decode(input);
13589         }
13590         var length = input.length;
13591         var expandedCharCodes = [];
13592         var i = 0;
13593         while (i < length) {
13594             if (input.charCodeAt(i) === base64Digits.charCodeAt(64)) {
13595                 break;
13596             }
13597             var ch1 = base64Digits.indexOf(input[i]);
13598             var ch2 = base64Digits.indexOf(input[i + 1]);
13599             var ch3 = base64Digits.indexOf(input[i + 2]);
13600             var ch4 = base64Digits.indexOf(input[i + 3]);
13601             var code1 = ((ch1 & 63) << 2) | ((ch2 >> 4) & 3);
13602             var code2 = ((ch2 & 15) << 4) | ((ch3 >> 2) & 15);
13603             var code3 = ((ch3 & 3) << 6) | (ch4 & 63);
13604             if (code2 === 0 && ch3 !== 0) {
13605                 expandedCharCodes.push(code1);
13606             }
13607             else if (code3 === 0 && ch4 !== 0) {
13608                 expandedCharCodes.push(code1, code2);
13609             }
13610             else {
13611                 expandedCharCodes.push(code1, code2, code3);
13612             }
13613             i += 4;
13614         }
13615         return getStringFromExpandedCharCodes(expandedCharCodes);
13616     }
13617     ts.base64decode = base64decode;
13618     function readJson(path, host) {
13619         try {
13620             var jsonText = host.readFile(path);
13621             if (!jsonText)
13622                 return {};
13623             var result = ts.parseConfigFileTextToJson(path, jsonText);
13624             if (result.error) {
13625                 return {};
13626             }
13627             return result.config;
13628         }
13629         catch (e) {
13630             return {};
13631         }
13632     }
13633     ts.readJson = readJson;
13634     function directoryProbablyExists(directoryName, host) {
13635         return !host.directoryExists || host.directoryExists(directoryName);
13636     }
13637     ts.directoryProbablyExists = directoryProbablyExists;
13638     var carriageReturnLineFeed = "\r\n";
13639     var lineFeed = "\n";
13640     function getNewLineCharacter(options, getNewLine) {
13641         switch (options.newLine) {
13642             case 0:
13643                 return carriageReturnLineFeed;
13644             case 1:
13645                 return lineFeed;
13646         }
13647         return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed;
13648     }
13649     ts.getNewLineCharacter = getNewLineCharacter;
13650     function createRange(pos, end) {
13651         if (end === void 0) { end = pos; }
13652         ts.Debug.assert(end >= pos || end === -1);
13653         return { pos: pos, end: end };
13654     }
13655     ts.createRange = createRange;
13656     function moveRangeEnd(range, end) {
13657         return createRange(range.pos, end);
13658     }
13659     ts.moveRangeEnd = moveRangeEnd;
13660     function moveRangePos(range, pos) {
13661         return createRange(pos, range.end);
13662     }
13663     ts.moveRangePos = moveRangePos;
13664     function moveRangePastDecorators(node) {
13665         return node.decorators && node.decorators.length > 0
13666             ? moveRangePos(node, node.decorators.end)
13667             : node;
13668     }
13669     ts.moveRangePastDecorators = moveRangePastDecorators;
13670     function moveRangePastModifiers(node) {
13671         return node.modifiers && node.modifiers.length > 0
13672             ? moveRangePos(node, node.modifiers.end)
13673             : moveRangePastDecorators(node);
13674     }
13675     ts.moveRangePastModifiers = moveRangePastModifiers;
13676     function isCollapsedRange(range) {
13677         return range.pos === range.end;
13678     }
13679     ts.isCollapsedRange = isCollapsedRange;
13680     function createTokenRange(pos, token) {
13681         return createRange(pos, pos + ts.tokenToString(token).length);
13682     }
13683     ts.createTokenRange = createTokenRange;
13684     function rangeIsOnSingleLine(range, sourceFile) {
13685         return rangeStartIsOnSameLineAsRangeEnd(range, range, sourceFile);
13686     }
13687     ts.rangeIsOnSingleLine = rangeIsOnSingleLine;
13688     function rangeStartPositionsAreOnSameLine(range1, range2, sourceFile) {
13689         return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile, false), getStartPositionOfRange(range2, sourceFile, false), sourceFile);
13690     }
13691     ts.rangeStartPositionsAreOnSameLine = rangeStartPositionsAreOnSameLine;
13692     function rangeEndPositionsAreOnSameLine(range1, range2, sourceFile) {
13693         return positionsAreOnSameLine(range1.end, range2.end, sourceFile);
13694     }
13695     ts.rangeEndPositionsAreOnSameLine = rangeEndPositionsAreOnSameLine;
13696     function rangeStartIsOnSameLineAsRangeEnd(range1, range2, sourceFile) {
13697         return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile, false), range2.end, sourceFile);
13698     }
13699     ts.rangeStartIsOnSameLineAsRangeEnd = rangeStartIsOnSameLineAsRangeEnd;
13700     function rangeEndIsOnSameLineAsRangeStart(range1, range2, sourceFile) {
13701         return positionsAreOnSameLine(range1.end, getStartPositionOfRange(range2, sourceFile, false), sourceFile);
13702     }
13703     ts.rangeEndIsOnSameLineAsRangeStart = rangeEndIsOnSameLineAsRangeStart;
13704     function getLinesBetweenRangeEndAndRangeStart(range1, range2, sourceFile, includeSecondRangeComments) {
13705         var range2Start = getStartPositionOfRange(range2, sourceFile, includeSecondRangeComments);
13706         return ts.getLinesBetweenPositions(sourceFile, range1.end, range2Start);
13707     }
13708     ts.getLinesBetweenRangeEndAndRangeStart = getLinesBetweenRangeEndAndRangeStart;
13709     function getLinesBetweenRangeEndPositions(range1, range2, sourceFile) {
13710         return ts.getLinesBetweenPositions(sourceFile, range1.end, range2.end);
13711     }
13712     ts.getLinesBetweenRangeEndPositions = getLinesBetweenRangeEndPositions;
13713     function isNodeArrayMultiLine(list, sourceFile) {
13714         return !positionsAreOnSameLine(list.pos, list.end, sourceFile);
13715     }
13716     ts.isNodeArrayMultiLine = isNodeArrayMultiLine;
13717     function positionsAreOnSameLine(pos1, pos2, sourceFile) {
13718         return ts.getLinesBetweenPositions(sourceFile, pos1, pos2) === 0;
13719     }
13720     ts.positionsAreOnSameLine = positionsAreOnSameLine;
13721     function getStartPositionOfRange(range, sourceFile, includeComments) {
13722         return positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos, false, includeComments);
13723     }
13724     ts.getStartPositionOfRange = getStartPositionOfRange;
13725     function getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(pos, stopPos, sourceFile, includeComments) {
13726         var startPos = ts.skipTrivia(sourceFile.text, pos, false, includeComments);
13727         var prevPos = getPreviousNonWhitespacePosition(startPos, stopPos, sourceFile);
13728         return ts.getLinesBetweenPositions(sourceFile, prevPos !== null && prevPos !== void 0 ? prevPos : stopPos, startPos);
13729     }
13730     ts.getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter = getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter;
13731     function getLinesBetweenPositionAndNextNonWhitespaceCharacter(pos, stopPos, sourceFile, includeComments) {
13732         var nextPos = ts.skipTrivia(sourceFile.text, pos, false, includeComments);
13733         return ts.getLinesBetweenPositions(sourceFile, pos, Math.min(stopPos, nextPos));
13734     }
13735     ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter = getLinesBetweenPositionAndNextNonWhitespaceCharacter;
13736     function getPreviousNonWhitespacePosition(pos, stopPos, sourceFile) {
13737         if (stopPos === void 0) { stopPos = 0; }
13738         while (pos-- > stopPos) {
13739             if (!ts.isWhiteSpaceLike(sourceFile.text.charCodeAt(pos))) {
13740                 return pos;
13741             }
13742         }
13743     }
13744     function isDeclarationNameOfEnumOrNamespace(node) {
13745         var parseNode = ts.getParseTreeNode(node);
13746         if (parseNode) {
13747             switch (parseNode.parent.kind) {
13748                 case 248:
13749                 case 249:
13750                     return parseNode === parseNode.parent.name;
13751             }
13752         }
13753         return false;
13754     }
13755     ts.isDeclarationNameOfEnumOrNamespace = isDeclarationNameOfEnumOrNamespace;
13756     function getInitializedVariables(node) {
13757         return ts.filter(node.declarations, isInitializedVariable);
13758     }
13759     ts.getInitializedVariables = getInitializedVariables;
13760     function isInitializedVariable(node) {
13761         return node.initializer !== undefined;
13762     }
13763     function isWatchSet(options) {
13764         return options.watch && options.hasOwnProperty("watch");
13765     }
13766     ts.isWatchSet = isWatchSet;
13767     function closeFileWatcher(watcher) {
13768         watcher.close();
13769     }
13770     ts.closeFileWatcher = closeFileWatcher;
13771     function getCheckFlags(symbol) {
13772         return symbol.flags & 33554432 ? symbol.checkFlags : 0;
13773     }
13774     ts.getCheckFlags = getCheckFlags;
13775     function getDeclarationModifierFlagsFromSymbol(s) {
13776         if (s.valueDeclaration) {
13777             var flags = ts.getCombinedModifierFlags(s.valueDeclaration);
13778             return s.parent && s.parent.flags & 32 ? flags : flags & ~28;
13779         }
13780         if (getCheckFlags(s) & 6) {
13781             var checkFlags = s.checkFlags;
13782             var accessModifier = checkFlags & 1024 ? 8 :
13783                 checkFlags & 256 ? 4 :
13784                     16;
13785             var staticModifier = checkFlags & 2048 ? 32 : 0;
13786             return accessModifier | staticModifier;
13787         }
13788         if (s.flags & 4194304) {
13789             return 4 | 32;
13790         }
13791         return 0;
13792     }
13793     ts.getDeclarationModifierFlagsFromSymbol = getDeclarationModifierFlagsFromSymbol;
13794     function skipAlias(symbol, checker) {
13795         return symbol.flags & 2097152 ? checker.getAliasedSymbol(symbol) : symbol;
13796     }
13797     ts.skipAlias = skipAlias;
13798     function getCombinedLocalAndExportSymbolFlags(symbol) {
13799         return symbol.exportSymbol ? symbol.exportSymbol.flags | symbol.flags : symbol.flags;
13800     }
13801     ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags;
13802     function isWriteOnlyAccess(node) {
13803         return accessKind(node) === 1;
13804     }
13805     ts.isWriteOnlyAccess = isWriteOnlyAccess;
13806     function isWriteAccess(node) {
13807         return accessKind(node) !== 0;
13808     }
13809     ts.isWriteAccess = isWriteAccess;
13810     function accessKind(node) {
13811         var parent = node.parent;
13812         if (!parent)
13813             return 0;
13814         switch (parent.kind) {
13815             case 200:
13816                 return accessKind(parent);
13817             case 208:
13818             case 207:
13819                 var operator = parent.operator;
13820                 return operator === 45 || operator === 46 ? writeOrReadWrite() : 0;
13821             case 209:
13822                 var _a = parent, left = _a.left, operatorToken = _a.operatorToken;
13823                 return left === node && isAssignmentOperator(operatorToken.kind) ?
13824                     operatorToken.kind === 62 ? 1 : writeOrReadWrite()
13825                     : 0;
13826             case 194:
13827                 return parent.name !== node ? 0 : accessKind(parent);
13828             case 281: {
13829                 var parentAccess = accessKind(parent.parent);
13830                 return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess;
13831             }
13832             case 282:
13833                 return node === parent.objectAssignmentInitializer ? 0 : accessKind(parent.parent);
13834             case 192:
13835                 return accessKind(parent);
13836             default:
13837                 return 0;
13838         }
13839         function writeOrReadWrite() {
13840             return parent.parent && skipParenthesesUp(parent.parent).kind === 226 ? 1 : 2;
13841         }
13842     }
13843     function reverseAccessKind(a) {
13844         switch (a) {
13845             case 0:
13846                 return 1;
13847             case 1:
13848                 return 0;
13849             case 2:
13850                 return 2;
13851             default:
13852                 return ts.Debug.assertNever(a);
13853         }
13854     }
13855     function compareDataObjects(dst, src) {
13856         if (!dst || !src || Object.keys(dst).length !== Object.keys(src).length) {
13857             return false;
13858         }
13859         for (var e in dst) {
13860             if (typeof dst[e] === "object") {
13861                 if (!compareDataObjects(dst[e], src[e])) {
13862                     return false;
13863                 }
13864             }
13865             else if (typeof dst[e] !== "function") {
13866                 if (dst[e] !== src[e]) {
13867                     return false;
13868                 }
13869             }
13870         }
13871         return true;
13872     }
13873     ts.compareDataObjects = compareDataObjects;
13874     function clearMap(map, onDeleteValue) {
13875         map.forEach(onDeleteValue);
13876         map.clear();
13877     }
13878     ts.clearMap = clearMap;
13879     function mutateMapSkippingNewValues(map, newMap, options) {
13880         var onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue;
13881         map.forEach(function (existingValue, key) {
13882             var valueInNewMap = newMap.get(key);
13883             if (valueInNewMap === undefined) {
13884                 map.delete(key);
13885                 onDeleteValue(existingValue, key);
13886             }
13887             else if (onExistingValue) {
13888                 onExistingValue(existingValue, valueInNewMap, key);
13889             }
13890         });
13891     }
13892     ts.mutateMapSkippingNewValues = mutateMapSkippingNewValues;
13893     function mutateMap(map, newMap, options) {
13894         mutateMapSkippingNewValues(map, newMap, options);
13895         var createNewValue = options.createNewValue;
13896         newMap.forEach(function (valueInNewMap, key) {
13897             if (!map.has(key)) {
13898                 map.set(key, createNewValue(key, valueInNewMap));
13899             }
13900         });
13901     }
13902     ts.mutateMap = mutateMap;
13903     function isAbstractConstructorType(type) {
13904         return !!(getObjectFlags(type) & 16) && !!type.symbol && isAbstractConstructorSymbol(type.symbol);
13905     }
13906     ts.isAbstractConstructorType = isAbstractConstructorType;
13907     function isAbstractConstructorSymbol(symbol) {
13908         if (symbol.flags & 32) {
13909             var declaration = getClassLikeDeclarationOfSymbol(symbol);
13910             return !!declaration && hasModifier(declaration, 128);
13911         }
13912         return false;
13913     }
13914     ts.isAbstractConstructorSymbol = isAbstractConstructorSymbol;
13915     function getClassLikeDeclarationOfSymbol(symbol) {
13916         return ts.find(symbol.declarations, ts.isClassLike);
13917     }
13918     ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol;
13919     function getObjectFlags(type) {
13920         return type.flags & 3899393 ? type.objectFlags : 0;
13921     }
13922     ts.getObjectFlags = getObjectFlags;
13923     function typeHasCallOrConstructSignatures(type, checker) {
13924         return checker.getSignaturesOfType(type, 0).length !== 0 || checker.getSignaturesOfType(type, 1).length !== 0;
13925     }
13926     ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures;
13927     function forSomeAncestorDirectory(directory, callback) {
13928         return !!ts.forEachAncestorDirectory(directory, function (d) { return callback(d) ? true : undefined; });
13929     }
13930     ts.forSomeAncestorDirectory = forSomeAncestorDirectory;
13931     function isUMDExportSymbol(symbol) {
13932         return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]);
13933     }
13934     ts.isUMDExportSymbol = isUMDExportSymbol;
13935     function showModuleSpecifier(_a) {
13936         var moduleSpecifier = _a.moduleSpecifier;
13937         return ts.isStringLiteral(moduleSpecifier) ? moduleSpecifier.text : getTextOfNode(moduleSpecifier);
13938     }
13939     ts.showModuleSpecifier = showModuleSpecifier;
13940     function getLastChild(node) {
13941         var lastChild;
13942         ts.forEachChild(node, function (child) {
13943             if (nodeIsPresent(child))
13944                 lastChild = child;
13945         }, function (children) {
13946             for (var i = children.length - 1; i >= 0; i--) {
13947                 if (nodeIsPresent(children[i])) {
13948                     lastChild = children[i];
13949                     break;
13950                 }
13951             }
13952         });
13953         return lastChild;
13954     }
13955     ts.getLastChild = getLastChild;
13956     function addToSeen(seen, key, value) {
13957         if (value === void 0) { value = true; }
13958         key = String(key);
13959         if (seen.has(key)) {
13960             return false;
13961         }
13962         seen.set(key, value);
13963         return true;
13964     }
13965     ts.addToSeen = addToSeen;
13966     function isObjectTypeDeclaration(node) {
13967         return ts.isClassLike(node) || ts.isInterfaceDeclaration(node) || ts.isTypeLiteralNode(node);
13968     }
13969     ts.isObjectTypeDeclaration = isObjectTypeDeclaration;
13970     function isTypeNodeKind(kind) {
13971         return (kind >= 168 && kind <= 188)
13972             || kind === 125
13973             || kind === 148
13974             || kind === 140
13975             || kind === 151
13976             || kind === 141
13977             || kind === 128
13978             || kind === 143
13979             || kind === 144
13980             || kind === 104
13981             || kind === 110
13982             || kind === 146
13983             || kind === 100
13984             || kind === 137
13985             || kind === 216
13986             || kind === 295
13987             || kind === 296
13988             || kind === 297
13989             || kind === 298
13990             || kind === 299
13991             || kind === 300
13992             || kind === 301;
13993     }
13994     ts.isTypeNodeKind = isTypeNodeKind;
13995     function isAccessExpression(node) {
13996         return node.kind === 194 || node.kind === 195;
13997     }
13998     ts.isAccessExpression = isAccessExpression;
13999     function getNameOfAccessExpression(node) {
14000         if (node.kind === 194) {
14001             return node.name;
14002         }
14003         ts.Debug.assert(node.kind === 195);
14004         return node.argumentExpression;
14005     }
14006     ts.getNameOfAccessExpression = getNameOfAccessExpression;
14007     function isBundleFileTextLike(section) {
14008         switch (section.kind) {
14009             case "text":
14010             case "internal":
14011                 return true;
14012             default:
14013                 return false;
14014         }
14015     }
14016     ts.isBundleFileTextLike = isBundleFileTextLike;
14017     function isNamedImportsOrExports(node) {
14018         return node.kind === 257 || node.kind === 261;
14019     }
14020     ts.isNamedImportsOrExports = isNamedImportsOrExports;
14021     function Symbol(flags, name) {
14022         this.flags = flags;
14023         this.escapedName = name;
14024         this.declarations = undefined;
14025         this.valueDeclaration = undefined;
14026         this.id = undefined;
14027         this.mergeId = undefined;
14028         this.parent = undefined;
14029     }
14030     function Type(checker, flags) {
14031         this.flags = flags;
14032         if (ts.Debug.isDebugging) {
14033             this.checker = checker;
14034         }
14035     }
14036     function Signature(checker, flags) {
14037         this.flags = flags;
14038         if (ts.Debug.isDebugging) {
14039             this.checker = checker;
14040         }
14041     }
14042     function Node(kind, pos, end) {
14043         this.pos = pos;
14044         this.end = end;
14045         this.kind = kind;
14046         this.id = 0;
14047         this.flags = 0;
14048         this.modifierFlagsCache = 0;
14049         this.transformFlags = 0;
14050         this.parent = undefined;
14051         this.original = undefined;
14052     }
14053     function Token(kind, pos, end) {
14054         this.pos = pos;
14055         this.end = end;
14056         this.kind = kind;
14057         this.id = 0;
14058         this.flags = 0;
14059         this.transformFlags = 0;
14060         this.parent = undefined;
14061     }
14062     function Identifier(kind, pos, end) {
14063         this.pos = pos;
14064         this.end = end;
14065         this.kind = kind;
14066         this.id = 0;
14067         this.flags = 0;
14068         this.transformFlags = 0;
14069         this.parent = undefined;
14070         this.original = undefined;
14071         this.flowNode = undefined;
14072     }
14073     function SourceMapSource(fileName, text, skipTrivia) {
14074         this.fileName = fileName;
14075         this.text = text;
14076         this.skipTrivia = skipTrivia || (function (pos) { return pos; });
14077     }
14078     ts.objectAllocator = {
14079         getNodeConstructor: function () { return Node; },
14080         getTokenConstructor: function () { return Token; },
14081         getIdentifierConstructor: function () { return Identifier; },
14082         getPrivateIdentifierConstructor: function () { return Node; },
14083         getSourceFileConstructor: function () { return Node; },
14084         getSymbolConstructor: function () { return Symbol; },
14085         getTypeConstructor: function () { return Type; },
14086         getSignatureConstructor: function () { return Signature; },
14087         getSourceMapSourceConstructor: function () { return SourceMapSource; },
14088     };
14089     function setObjectAllocator(alloc) {
14090         ts.objectAllocator = alloc;
14091     }
14092     ts.setObjectAllocator = setObjectAllocator;
14093     function formatStringFromArgs(text, args, baseIndex) {
14094         if (baseIndex === void 0) { baseIndex = 0; }
14095         return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.checkDefined(args[+index + baseIndex]); });
14096     }
14097     ts.formatStringFromArgs = formatStringFromArgs;
14098     function setLocalizedDiagnosticMessages(messages) {
14099         ts.localizedDiagnosticMessages = messages;
14100     }
14101     ts.setLocalizedDiagnosticMessages = setLocalizedDiagnosticMessages;
14102     function getLocaleSpecificMessage(message) {
14103         return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message;
14104     }
14105     ts.getLocaleSpecificMessage = getLocaleSpecificMessage;
14106     function createFileDiagnostic(file, start, length, message) {
14107         ts.Debug.assertGreaterThanOrEqual(start, 0);
14108         ts.Debug.assertGreaterThanOrEqual(length, 0);
14109         if (file) {
14110             ts.Debug.assertLessThanOrEqual(start, file.text.length);
14111             ts.Debug.assertLessThanOrEqual(start + length, file.text.length);
14112         }
14113         var text = getLocaleSpecificMessage(message);
14114         if (arguments.length > 4) {
14115             text = formatStringFromArgs(text, arguments, 4);
14116         }
14117         return {
14118             file: file,
14119             start: start,
14120             length: length,
14121             messageText: text,
14122             category: message.category,
14123             code: message.code,
14124             reportsUnnecessary: message.reportsUnnecessary,
14125         };
14126     }
14127     ts.createFileDiagnostic = createFileDiagnostic;
14128     function formatMessage(_dummy, message) {
14129         var text = getLocaleSpecificMessage(message);
14130         if (arguments.length > 2) {
14131             text = formatStringFromArgs(text, arguments, 2);
14132         }
14133         return text;
14134     }
14135     ts.formatMessage = formatMessage;
14136     function createCompilerDiagnostic(message) {
14137         var text = getLocaleSpecificMessage(message);
14138         if (arguments.length > 1) {
14139             text = formatStringFromArgs(text, arguments, 1);
14140         }
14141         return {
14142             file: undefined,
14143             start: undefined,
14144             length: undefined,
14145             messageText: text,
14146             category: message.category,
14147             code: message.code,
14148             reportsUnnecessary: message.reportsUnnecessary,
14149         };
14150     }
14151     ts.createCompilerDiagnostic = createCompilerDiagnostic;
14152     function createCompilerDiagnosticFromMessageChain(chain) {
14153         return {
14154             file: undefined,
14155             start: undefined,
14156             length: undefined,
14157             code: chain.code,
14158             category: chain.category,
14159             messageText: chain.next ? chain : chain.messageText,
14160         };
14161     }
14162     ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain;
14163     function chainDiagnosticMessages(details, message) {
14164         var text = getLocaleSpecificMessage(message);
14165         if (arguments.length > 2) {
14166             text = formatStringFromArgs(text, arguments, 2);
14167         }
14168         return {
14169             messageText: text,
14170             category: message.category,
14171             code: message.code,
14172             next: details === undefined || Array.isArray(details) ? details : [details]
14173         };
14174     }
14175     ts.chainDiagnosticMessages = chainDiagnosticMessages;
14176     function concatenateDiagnosticMessageChains(headChain, tailChain) {
14177         var lastChain = headChain;
14178         while (lastChain.next) {
14179             lastChain = lastChain.next[0];
14180         }
14181         lastChain.next = [tailChain];
14182     }
14183     ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains;
14184     function getDiagnosticFilePath(diagnostic) {
14185         return diagnostic.file ? diagnostic.file.path : undefined;
14186     }
14187     function compareDiagnostics(d1, d2) {
14188         return compareDiagnosticsSkipRelatedInformation(d1, d2) ||
14189             compareRelatedInformation(d1, d2) ||
14190             0;
14191     }
14192     ts.compareDiagnostics = compareDiagnostics;
14193     function compareDiagnosticsSkipRelatedInformation(d1, d2) {
14194         return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) ||
14195             ts.compareValues(d1.start, d2.start) ||
14196             ts.compareValues(d1.length, d2.length) ||
14197             ts.compareValues(d1.code, d2.code) ||
14198             compareMessageText(d1.messageText, d2.messageText) ||
14199             0;
14200     }
14201     ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation;
14202     function compareRelatedInformation(d1, d2) {
14203         if (!d1.relatedInformation && !d2.relatedInformation) {
14204             return 0;
14205         }
14206         if (d1.relatedInformation && d2.relatedInformation) {
14207             return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) {
14208                 var d2i = d2.relatedInformation[index];
14209                 return compareDiagnostics(d1i, d2i);
14210             }) || 0;
14211         }
14212         return d1.relatedInformation ? -1 : 1;
14213     }
14214     function compareMessageText(t1, t2) {
14215         if (typeof t1 === "string" && typeof t2 === "string") {
14216             return ts.compareStringsCaseSensitive(t1, t2);
14217         }
14218         else if (typeof t1 === "string") {
14219             return -1;
14220         }
14221         else if (typeof t2 === "string") {
14222             return 1;
14223         }
14224         var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText);
14225         if (res) {
14226             return res;
14227         }
14228         if (!t1.next && !t2.next) {
14229             return 0;
14230         }
14231         if (!t1.next) {
14232             return -1;
14233         }
14234         if (!t2.next) {
14235             return 1;
14236         }
14237         var len = Math.min(t1.next.length, t2.next.length);
14238         for (var i = 0; i < len; i++) {
14239             res = compareMessageText(t1.next[i], t2.next[i]);
14240             if (res) {
14241                 return res;
14242             }
14243         }
14244         if (t1.next.length < t2.next.length) {
14245             return -1;
14246         }
14247         else if (t1.next.length > t2.next.length) {
14248             return 1;
14249         }
14250         return 0;
14251     }
14252     function getEmitScriptTarget(compilerOptions) {
14253         return compilerOptions.target || 0;
14254     }
14255     ts.getEmitScriptTarget = getEmitScriptTarget;
14256     function getEmitModuleKind(compilerOptions) {
14257         return typeof compilerOptions.module === "number" ?
14258             compilerOptions.module :
14259             getEmitScriptTarget(compilerOptions) >= 2 ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS;
14260     }
14261     ts.getEmitModuleKind = getEmitModuleKind;
14262     function getEmitModuleResolutionKind(compilerOptions) {
14263         var moduleResolution = compilerOptions.moduleResolution;
14264         if (moduleResolution === undefined) {
14265             moduleResolution = getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic;
14266         }
14267         return moduleResolution;
14268     }
14269     ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
14270     function hasJsonModuleEmitEnabled(options) {
14271         switch (getEmitModuleKind(options)) {
14272             case ts.ModuleKind.CommonJS:
14273             case ts.ModuleKind.AMD:
14274             case ts.ModuleKind.ES2015:
14275             case ts.ModuleKind.ES2020:
14276             case ts.ModuleKind.ESNext:
14277                 return true;
14278             default:
14279                 return false;
14280         }
14281     }
14282     ts.hasJsonModuleEmitEnabled = hasJsonModuleEmitEnabled;
14283     function unreachableCodeIsError(options) {
14284         return options.allowUnreachableCode === false;
14285     }
14286     ts.unreachableCodeIsError = unreachableCodeIsError;
14287     function unusedLabelIsError(options) {
14288         return options.allowUnusedLabels === false;
14289     }
14290     ts.unusedLabelIsError = unusedLabelIsError;
14291     function getAreDeclarationMapsEnabled(options) {
14292         return !!(getEmitDeclarations(options) && options.declarationMap);
14293     }
14294     ts.getAreDeclarationMapsEnabled = getAreDeclarationMapsEnabled;
14295     function getAllowSyntheticDefaultImports(compilerOptions) {
14296         var moduleKind = getEmitModuleKind(compilerOptions);
14297         return compilerOptions.allowSyntheticDefaultImports !== undefined
14298             ? compilerOptions.allowSyntheticDefaultImports
14299             : compilerOptions.esModuleInterop ||
14300                 moduleKind === ts.ModuleKind.System;
14301     }
14302     ts.getAllowSyntheticDefaultImports = getAllowSyntheticDefaultImports;
14303     function getEmitDeclarations(compilerOptions) {
14304         return !!(compilerOptions.declaration || compilerOptions.composite);
14305     }
14306     ts.getEmitDeclarations = getEmitDeclarations;
14307     function isIncrementalCompilation(options) {
14308         return !!(options.incremental || options.composite);
14309     }
14310     ts.isIncrementalCompilation = isIncrementalCompilation;
14311     function getStrictOptionValue(compilerOptions, flag) {
14312         return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag];
14313     }
14314     ts.getStrictOptionValue = getStrictOptionValue;
14315     function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) {
14316         return oldOptions !== newOptions &&
14317             ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); });
14318     }
14319     ts.compilerOptionsAffectSemanticDiagnostics = compilerOptionsAffectSemanticDiagnostics;
14320     function compilerOptionsAffectEmit(newOptions, oldOptions) {
14321         return oldOptions !== newOptions &&
14322             ts.affectsEmitOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); });
14323     }
14324     ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit;
14325     function getCompilerOptionValue(options, option) {
14326         return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name];
14327     }
14328     ts.getCompilerOptionValue = getCompilerOptionValue;
14329     function hasZeroOrOneAsteriskCharacter(str) {
14330         var seenAsterisk = false;
14331         for (var i = 0; i < str.length; i++) {
14332             if (str.charCodeAt(i) === 42) {
14333                 if (!seenAsterisk) {
14334                     seenAsterisk = true;
14335                 }
14336                 else {
14337                     return false;
14338                 }
14339             }
14340         }
14341         return true;
14342     }
14343     ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter;
14344     function discoverProbableSymlinks(files, getCanonicalFileName, cwd) {
14345         var result = ts.createMap();
14346         var symlinks = ts.flatten(ts.mapDefined(files, function (sf) {
14347             return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) {
14348                 return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined;
14349             })));
14350         }));
14351         for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) {
14352             var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1];
14353             var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1];
14354             result.set(commonOriginal, commonResolved);
14355         }
14356         return result;
14357     }
14358     ts.discoverProbableSymlinks = discoverProbableSymlinks;
14359     function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) {
14360         var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName));
14361         var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName));
14362         while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) &&
14363             !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) &&
14364             getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) {
14365             aParts.pop();
14366             bParts.pop();
14367         }
14368         return [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)];
14369     }
14370     function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) {
14371         return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@");
14372     }
14373     function stripLeadingDirectorySeparator(s) {
14374         return ts.isAnyDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined;
14375     }
14376     function tryRemoveDirectoryPrefix(path, dirPath, getCanonicalFileName) {
14377         var withoutPrefix = ts.tryRemovePrefix(path, dirPath, getCanonicalFileName);
14378         return withoutPrefix === undefined ? undefined : stripLeadingDirectorySeparator(withoutPrefix);
14379     }
14380     ts.tryRemoveDirectoryPrefix = tryRemoveDirectoryPrefix;
14381     var reservedCharacterPattern = /[^\w\s\/]/g;
14382     function regExpEscape(text) {
14383         return text.replace(reservedCharacterPattern, escapeRegExpCharacter);
14384     }
14385     ts.regExpEscape = regExpEscape;
14386     function escapeRegExpCharacter(match) {
14387         return "\\" + match;
14388     }
14389     var wildcardCharCodes = [42, 63];
14390     ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"];
14391     var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))";
14392     var filesMatcher = {
14393         singleAsteriskRegexFragment: "([^./]|(\\.(?!min\\.js$))?)*",
14394         doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?",
14395         replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); }
14396     };
14397     var directoriesMatcher = {
14398         singleAsteriskRegexFragment: "[^/]*",
14399         doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?",
14400         replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); }
14401     };
14402     var excludeMatcher = {
14403         singleAsteriskRegexFragment: "[^/]*",
14404         doubleAsteriskRegexFragment: "(/.+?)?",
14405         replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, excludeMatcher.singleAsteriskRegexFragment); }
14406     };
14407     var wildcardMatchers = {
14408         files: filesMatcher,
14409         directories: directoriesMatcher,
14410         exclude: excludeMatcher
14411     };
14412     function getRegularExpressionForWildcard(specs, basePath, usage) {
14413         var patterns = getRegularExpressionsForWildcards(specs, basePath, usage);
14414         if (!patterns || !patterns.length) {
14415             return undefined;
14416         }
14417         var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|");
14418         var terminator = usage === "exclude" ? "($|/)" : "$";
14419         return "^(" + pattern + ")" + terminator;
14420     }
14421     ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard;
14422     function getRegularExpressionsForWildcards(specs, basePath, usage) {
14423         if (specs === undefined || specs.length === 0) {
14424             return undefined;
14425         }
14426         return ts.flatMap(specs, function (spec) {
14427             return spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]);
14428         });
14429     }
14430     ts.getRegularExpressionsForWildcards = getRegularExpressionsForWildcards;
14431     function isImplicitGlob(lastPathComponent) {
14432         return !/[.*?]/.test(lastPathComponent);
14433     }
14434     ts.isImplicitGlob = isImplicitGlob;
14435     function getSubPatternFromSpec(spec, basePath, usage, _a) {
14436         var singleAsteriskRegexFragment = _a.singleAsteriskRegexFragment, doubleAsteriskRegexFragment = _a.doubleAsteriskRegexFragment, replaceWildcardCharacter = _a.replaceWildcardCharacter;
14437         var subpattern = "";
14438         var hasWrittenComponent = false;
14439         var components = ts.getNormalizedPathComponents(spec, basePath);
14440         var lastComponent = ts.last(components);
14441         if (usage !== "exclude" && lastComponent === "**") {
14442             return undefined;
14443         }
14444         components[0] = ts.removeTrailingDirectorySeparator(components[0]);
14445         if (isImplicitGlob(lastComponent)) {
14446             components.push("**", "*");
14447         }
14448         var optionalCount = 0;
14449         for (var _i = 0, components_1 = components; _i < components_1.length; _i++) {
14450             var component = components_1[_i];
14451             if (component === "**") {
14452                 subpattern += doubleAsteriskRegexFragment;
14453             }
14454             else {
14455                 if (usage === "directories") {
14456                     subpattern += "(";
14457                     optionalCount++;
14458                 }
14459                 if (hasWrittenComponent) {
14460                     subpattern += ts.directorySeparator;
14461                 }
14462                 if (usage !== "exclude") {
14463                     var componentPattern = "";
14464                     if (component.charCodeAt(0) === 42) {
14465                         componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?";
14466                         component = component.substr(1);
14467                     }
14468                     else if (component.charCodeAt(0) === 63) {
14469                         componentPattern += "[^./]";
14470                         component = component.substr(1);
14471                     }
14472                     componentPattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter);
14473                     if (componentPattern !== component) {
14474                         subpattern += implicitExcludePathRegexPattern;
14475                     }
14476                     subpattern += componentPattern;
14477                 }
14478                 else {
14479                     subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter);
14480                 }
14481             }
14482             hasWrittenComponent = true;
14483         }
14484         while (optionalCount > 0) {
14485             subpattern += ")?";
14486             optionalCount--;
14487         }
14488         return subpattern;
14489     }
14490     function replaceWildcardCharacter(match, singleAsteriskRegexFragment) {
14491         return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match;
14492     }
14493     function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) {
14494         path = ts.normalizePath(path);
14495         currentDirectory = ts.normalizePath(currentDirectory);
14496         var absolutePath = ts.combinePaths(currentDirectory, path);
14497         return {
14498             includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }),
14499             includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"),
14500             includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"),
14501             excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"),
14502             basePaths: getBasePaths(path, includes, useCaseSensitiveFileNames)
14503         };
14504     }
14505     ts.getFileMatcherPatterns = getFileMatcherPatterns;
14506     function getRegexFromPattern(pattern, useCaseSensitiveFileNames) {
14507         return new RegExp(pattern, useCaseSensitiveFileNames ? "" : "i");
14508     }
14509     ts.getRegexFromPattern = getRegexFromPattern;
14510     function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath) {
14511         path = ts.normalizePath(path);
14512         currentDirectory = ts.normalizePath(currentDirectory);
14513         var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory);
14514         var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return getRegexFromPattern(pattern, useCaseSensitiveFileNames); });
14515         var includeDirectoryRegex = patterns.includeDirectoryPattern && getRegexFromPattern(patterns.includeDirectoryPattern, useCaseSensitiveFileNames);
14516         var excludeRegex = patterns.excludePattern && getRegexFromPattern(patterns.excludePattern, useCaseSensitiveFileNames);
14517         var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]];
14518         var visited = ts.createMap();
14519         var toCanonical = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
14520         for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) {
14521             var basePath = _a[_i];
14522             visitDirectory(basePath, ts.combinePaths(currentDirectory, basePath), depth);
14523         }
14524         return ts.flatten(results);
14525         function visitDirectory(path, absolutePath, depth) {
14526             var canonicalPath = toCanonical(realpath(absolutePath));
14527             if (visited.has(canonicalPath))
14528                 return;
14529             visited.set(canonicalPath, true);
14530             var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories;
14531             var _loop_1 = function (current) {
14532                 var name = ts.combinePaths(path, current);
14533                 var absoluteName = ts.combinePaths(absolutePath, current);
14534                 if (extensions && !ts.fileExtensionIsOneOf(name, extensions))
14535                     return "continue";
14536                 if (excludeRegex && excludeRegex.test(absoluteName))
14537                     return "continue";
14538                 if (!includeFileRegexes) {
14539                     results[0].push(name);
14540                 }
14541                 else {
14542                     var includeIndex = ts.findIndex(includeFileRegexes, function (re) { return re.test(absoluteName); });
14543                     if (includeIndex !== -1) {
14544                         results[includeIndex].push(name);
14545                     }
14546                 }
14547             };
14548             for (var _i = 0, _b = ts.sort(files, ts.compareStringsCaseSensitive); _i < _b.length; _i++) {
14549                 var current = _b[_i];
14550                 _loop_1(current);
14551             }
14552             if (depth !== undefined) {
14553                 depth--;
14554                 if (depth === 0) {
14555                     return;
14556                 }
14557             }
14558             for (var _c = 0, _d = ts.sort(directories, ts.compareStringsCaseSensitive); _c < _d.length; _c++) {
14559                 var current = _d[_c];
14560                 var name = ts.combinePaths(path, current);
14561                 var absoluteName = ts.combinePaths(absolutePath, current);
14562                 if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) &&
14563                     (!excludeRegex || !excludeRegex.test(absoluteName))) {
14564                     visitDirectory(name, absoluteName, depth);
14565                 }
14566             }
14567         }
14568     }
14569     ts.matchFiles = matchFiles;
14570     function getBasePaths(path, includes, useCaseSensitiveFileNames) {
14571         var basePaths = [path];
14572         if (includes) {
14573             var includeBasePaths = [];
14574             for (var _i = 0, includes_1 = includes; _i < includes_1.length; _i++) {
14575                 var include = includes_1[_i];
14576                 var absolute = ts.isRootedDiskPath(include) ? include : ts.normalizePath(ts.combinePaths(path, include));
14577                 includeBasePaths.push(getIncludeBasePath(absolute));
14578             }
14579             includeBasePaths.sort(ts.getStringComparer(!useCaseSensitiveFileNames));
14580             var _loop_2 = function (includeBasePath) {
14581                 if (ts.every(basePaths, function (basePath) { return !ts.containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) {
14582                     basePaths.push(includeBasePath);
14583                 }
14584             };
14585             for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) {
14586                 var includeBasePath = includeBasePaths_1[_a];
14587                 _loop_2(includeBasePath);
14588             }
14589         }
14590         return basePaths;
14591     }
14592     function getIncludeBasePath(absolute) {
14593         var wildcardOffset = ts.indexOfAnyCharCode(absolute, wildcardCharCodes);
14594         if (wildcardOffset < 0) {
14595             return !ts.hasExtension(absolute)
14596                 ? absolute
14597                 : ts.removeTrailingDirectorySeparator(ts.getDirectoryPath(absolute));
14598         }
14599         return absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset));
14600     }
14601     function ensureScriptKind(fileName, scriptKind) {
14602         return scriptKind || getScriptKindFromFileName(fileName) || 3;
14603     }
14604     ts.ensureScriptKind = ensureScriptKind;
14605     function getScriptKindFromFileName(fileName) {
14606         var ext = fileName.substr(fileName.lastIndexOf("."));
14607         switch (ext.toLowerCase()) {
14608             case ".js":
14609                 return 1;
14610             case ".jsx":
14611                 return 2;
14612             case ".ts":
14613                 return 3;
14614             case ".tsx":
14615                 return 4;
14616             case ".json":
14617                 return 6;
14618             default:
14619                 return 0;
14620         }
14621     }
14622     ts.getScriptKindFromFileName = getScriptKindFromFileName;
14623     ts.supportedTSExtensions = [".ts", ".tsx", ".d.ts"];
14624     ts.supportedTSExtensionsWithJson = [".ts", ".tsx", ".d.ts", ".json"];
14625     ts.supportedTSExtensionsForExtractExtension = [".d.ts", ".ts", ".tsx"];
14626     ts.supportedJSExtensions = [".js", ".jsx"];
14627     ts.supportedJSAndJsonExtensions = [".js", ".jsx", ".json"];
14628     var allSupportedExtensions = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions);
14629     var allSupportedExtensionsWithJson = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions, [".json"]);
14630     function getSupportedExtensions(options, extraFileExtensions) {
14631         var needJsExtensions = options && options.allowJs;
14632         if (!extraFileExtensions || extraFileExtensions.length === 0) {
14633             return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions;
14634         }
14635         var extensions = __spreadArrays(needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions, ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; }));
14636         return ts.deduplicate(extensions, ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive);
14637     }
14638     ts.getSupportedExtensions = getSupportedExtensions;
14639     function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions) {
14640         if (!options || !options.resolveJsonModule) {
14641             return supportedExtensions;
14642         }
14643         if (supportedExtensions === allSupportedExtensions) {
14644             return allSupportedExtensionsWithJson;
14645         }
14646         if (supportedExtensions === ts.supportedTSExtensions) {
14647             return ts.supportedTSExtensionsWithJson;
14648         }
14649         return __spreadArrays(supportedExtensions, [".json"]);
14650     }
14651     ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule;
14652     function isJSLike(scriptKind) {
14653         return scriptKind === 1 || scriptKind === 2;
14654     }
14655     function hasJSFileExtension(fileName) {
14656         return ts.some(ts.supportedJSExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); });
14657     }
14658     ts.hasJSFileExtension = hasJSFileExtension;
14659     function hasTSFileExtension(fileName) {
14660         return ts.some(ts.supportedTSExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); });
14661     }
14662     ts.hasTSFileExtension = hasTSFileExtension;
14663     function isSupportedSourceFileName(fileName, compilerOptions, extraFileExtensions) {
14664         if (!fileName) {
14665             return false;
14666         }
14667         var supportedExtensions = getSupportedExtensions(compilerOptions, extraFileExtensions);
14668         for (var _i = 0, _a = getSuppoertedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions); _i < _a.length; _i++) {
14669             var extension = _a[_i];
14670             if (ts.fileExtensionIs(fileName, extension)) {
14671                 return true;
14672             }
14673         }
14674         return false;
14675     }
14676     ts.isSupportedSourceFileName = isSupportedSourceFileName;
14677     function getExtensionPriority(path, supportedExtensions) {
14678         for (var i = supportedExtensions.length - 1; i >= 0; i--) {
14679             if (ts.fileExtensionIs(path, supportedExtensions[i])) {
14680                 return adjustExtensionPriority(i, supportedExtensions);
14681             }
14682         }
14683         return 0;
14684     }
14685     ts.getExtensionPriority = getExtensionPriority;
14686     function adjustExtensionPriority(extensionPriority, supportedExtensions) {
14687         if (extensionPriority < 2) {
14688             return 0;
14689         }
14690         else if (extensionPriority < supportedExtensions.length) {
14691             return 2;
14692         }
14693         else {
14694             return supportedExtensions.length;
14695         }
14696     }
14697     ts.adjustExtensionPriority = adjustExtensionPriority;
14698     function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) {
14699         if (extensionPriority < 2) {
14700             return 2;
14701         }
14702         else {
14703             return supportedExtensions.length;
14704         }
14705     }
14706     ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority;
14707     var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx", ".json"];
14708     function removeFileExtension(path) {
14709         for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) {
14710             var ext = extensionsToRemove_1[_i];
14711             var extensionless = tryRemoveExtension(path, ext);
14712             if (extensionless !== undefined) {
14713                 return extensionless;
14714             }
14715         }
14716         return path;
14717     }
14718     ts.removeFileExtension = removeFileExtension;
14719     function tryRemoveExtension(path, extension) {
14720         return ts.fileExtensionIs(path, extension) ? removeExtension(path, extension) : undefined;
14721     }
14722     ts.tryRemoveExtension = tryRemoveExtension;
14723     function removeExtension(path, extension) {
14724         return path.substring(0, path.length - extension.length);
14725     }
14726     ts.removeExtension = removeExtension;
14727     function changeExtension(path, newExtension) {
14728         return ts.changeAnyExtension(path, newExtension, extensionsToRemove, false);
14729     }
14730     ts.changeExtension = changeExtension;
14731     function tryParsePattern(pattern) {
14732         ts.Debug.assert(hasZeroOrOneAsteriskCharacter(pattern));
14733         var indexOfStar = pattern.indexOf("*");
14734         return indexOfStar === -1 ? undefined : {
14735             prefix: pattern.substr(0, indexOfStar),
14736             suffix: pattern.substr(indexOfStar + 1)
14737         };
14738     }
14739     ts.tryParsePattern = tryParsePattern;
14740     function positionIsSynthesized(pos) {
14741         return !(pos >= 0);
14742     }
14743     ts.positionIsSynthesized = positionIsSynthesized;
14744     function extensionIsTS(ext) {
14745         return ext === ".ts" || ext === ".tsx" || ext === ".d.ts";
14746     }
14747     ts.extensionIsTS = extensionIsTS;
14748     function resolutionExtensionIsTSOrJson(ext) {
14749         return extensionIsTS(ext) || ext === ".json";
14750     }
14751     ts.resolutionExtensionIsTSOrJson = resolutionExtensionIsTSOrJson;
14752     function extensionFromPath(path) {
14753         var ext = tryGetExtensionFromPath(path);
14754         return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension.");
14755     }
14756     ts.extensionFromPath = extensionFromPath;
14757     function isAnySupportedFileExtension(path) {
14758         return tryGetExtensionFromPath(path) !== undefined;
14759     }
14760     ts.isAnySupportedFileExtension = isAnySupportedFileExtension;
14761     function tryGetExtensionFromPath(path) {
14762         return ts.find(extensionsToRemove, function (e) { return ts.fileExtensionIs(path, e); });
14763     }
14764     ts.tryGetExtensionFromPath = tryGetExtensionFromPath;
14765     function isCheckJsEnabledForFile(sourceFile, compilerOptions) {
14766         return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs;
14767     }
14768     ts.isCheckJsEnabledForFile = isCheckJsEnabledForFile;
14769     ts.emptyFileSystemEntries = {
14770         files: ts.emptyArray,
14771         directories: ts.emptyArray
14772     };
14773     function matchPatternOrExact(patternStrings, candidate) {
14774         var patterns = [];
14775         for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) {
14776             var patternString = patternStrings_1[_i];
14777             if (!hasZeroOrOneAsteriskCharacter(patternString))
14778                 continue;
14779             var pattern = tryParsePattern(patternString);
14780             if (pattern) {
14781                 patterns.push(pattern);
14782             }
14783             else if (patternString === candidate) {
14784                 return patternString;
14785             }
14786         }
14787         return ts.findBestPatternMatch(patterns, function (_) { return _; }, candidate);
14788     }
14789     ts.matchPatternOrExact = matchPatternOrExact;
14790     function sliceAfter(arr, value) {
14791         var index = arr.indexOf(value);
14792         ts.Debug.assert(index !== -1);
14793         return arr.slice(index);
14794     }
14795     ts.sliceAfter = sliceAfter;
14796     function addRelatedInfo(diagnostic) {
14797         var _a;
14798         var relatedInformation = [];
14799         for (var _i = 1; _i < arguments.length; _i++) {
14800             relatedInformation[_i - 1] = arguments[_i];
14801         }
14802         if (!relatedInformation.length) {
14803             return diagnostic;
14804         }
14805         if (!diagnostic.relatedInformation) {
14806             diagnostic.relatedInformation = [];
14807         }
14808         (_a = diagnostic.relatedInformation).push.apply(_a, relatedInformation);
14809         return diagnostic;
14810     }
14811     ts.addRelatedInfo = addRelatedInfo;
14812     function minAndMax(arr, getValue) {
14813         ts.Debug.assert(arr.length !== 0);
14814         var min = getValue(arr[0]);
14815         var max = min;
14816         for (var i = 1; i < arr.length; i++) {
14817             var value = getValue(arr[i]);
14818             if (value < min) {
14819                 min = value;
14820             }
14821             else if (value > max) {
14822                 max = value;
14823             }
14824         }
14825         return { min: min, max: max };
14826     }
14827     ts.minAndMax = minAndMax;
14828     var NodeSet = (function () {
14829         function NodeSet() {
14830             this.map = ts.createMap();
14831         }
14832         NodeSet.prototype.add = function (node) {
14833             this.map.set(String(ts.getNodeId(node)), node);
14834         };
14835         NodeSet.prototype.tryAdd = function (node) {
14836             if (this.has(node))
14837                 return false;
14838             this.add(node);
14839             return true;
14840         };
14841         NodeSet.prototype.has = function (node) {
14842             return this.map.has(String(ts.getNodeId(node)));
14843         };
14844         NodeSet.prototype.forEach = function (cb) {
14845             this.map.forEach(cb);
14846         };
14847         NodeSet.prototype.some = function (pred) {
14848             return forEachEntry(this.map, pred) || false;
14849         };
14850         return NodeSet;
14851     }());
14852     ts.NodeSet = NodeSet;
14853     var NodeMap = (function () {
14854         function NodeMap() {
14855             this.map = ts.createMap();
14856         }
14857         NodeMap.prototype.get = function (node) {
14858             var res = this.map.get(String(ts.getNodeId(node)));
14859             return res && res.value;
14860         };
14861         NodeMap.prototype.getOrUpdate = function (node, setValue) {
14862             var res = this.get(node);
14863             if (res)
14864                 return res;
14865             var value = setValue();
14866             this.set(node, value);
14867             return value;
14868         };
14869         NodeMap.prototype.set = function (node, value) {
14870             this.map.set(String(ts.getNodeId(node)), { node: node, value: value });
14871         };
14872         NodeMap.prototype.has = function (node) {
14873             return this.map.has(String(ts.getNodeId(node)));
14874         };
14875         NodeMap.prototype.forEach = function (cb) {
14876             this.map.forEach(function (_a) {
14877                 var node = _a.node, value = _a.value;
14878                 return cb(value, node);
14879             });
14880         };
14881         return NodeMap;
14882     }());
14883     ts.NodeMap = NodeMap;
14884     function rangeOfNode(node) {
14885         return { pos: getTokenPosOfNode(node), end: node.end };
14886     }
14887     ts.rangeOfNode = rangeOfNode;
14888     function rangeOfTypeParameters(typeParameters) {
14889         return { pos: typeParameters.pos - 1, end: typeParameters.end + 1 };
14890     }
14891     ts.rangeOfTypeParameters = rangeOfTypeParameters;
14892     function skipTypeChecking(sourceFile, options, host) {
14893         return (options.skipLibCheck && sourceFile.isDeclarationFile ||
14894             options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) ||
14895             host.isSourceOfProjectReferenceRedirect(sourceFile.fileName);
14896     }
14897     ts.skipTypeChecking = skipTypeChecking;
14898     function isJsonEqual(a, b) {
14899         return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && ts.equalOwnProperties(a, b, isJsonEqual);
14900     }
14901     ts.isJsonEqual = isJsonEqual;
14902     function getOrUpdate(map, key, getDefault) {
14903         var got = map.get(key);
14904         if (got === undefined) {
14905             var value = getDefault();
14906             map.set(key, value);
14907             return value;
14908         }
14909         else {
14910             return got;
14911         }
14912     }
14913     ts.getOrUpdate = getOrUpdate;
14914     function parsePseudoBigInt(stringValue) {
14915         var log2Base;
14916         switch (stringValue.charCodeAt(1)) {
14917             case 98:
14918             case 66:
14919                 log2Base = 1;
14920                 break;
14921             case 111:
14922             case 79:
14923                 log2Base = 3;
14924                 break;
14925             case 120:
14926             case 88:
14927                 log2Base = 4;
14928                 break;
14929             default:
14930                 var nIndex = stringValue.length - 1;
14931                 var nonZeroStart = 0;
14932                 while (stringValue.charCodeAt(nonZeroStart) === 48) {
14933                     nonZeroStart++;
14934                 }
14935                 return stringValue.slice(nonZeroStart, nIndex) || "0";
14936         }
14937         var startIndex = 2, endIndex = stringValue.length - 1;
14938         var bitsNeeded = (endIndex - startIndex) * log2Base;
14939         var segments = new Uint16Array((bitsNeeded >>> 4) + (bitsNeeded & 15 ? 1 : 0));
14940         for (var i = endIndex - 1, bitOffset = 0; i >= startIndex; i--, bitOffset += log2Base) {
14941             var segment = bitOffset >>> 4;
14942             var digitChar = stringValue.charCodeAt(i);
14943             var digit = digitChar <= 57
14944                 ? digitChar - 48
14945                 : 10 + digitChar -
14946                     (digitChar <= 70 ? 65 : 97);
14947             var shiftedDigit = digit << (bitOffset & 15);
14948             segments[segment] |= shiftedDigit;
14949             var residual = shiftedDigit >>> 16;
14950             if (residual)
14951                 segments[segment + 1] |= residual;
14952         }
14953         var base10Value = "";
14954         var firstNonzeroSegment = segments.length - 1;
14955         var segmentsRemaining = true;
14956         while (segmentsRemaining) {
14957             var mod10 = 0;
14958             segmentsRemaining = false;
14959             for (var segment = firstNonzeroSegment; segment >= 0; segment--) {
14960                 var newSegment = mod10 << 16 | segments[segment];
14961                 var segmentValue = (newSegment / 10) | 0;
14962                 segments[segment] = segmentValue;
14963                 mod10 = newSegment - segmentValue * 10;
14964                 if (segmentValue && !segmentsRemaining) {
14965                     firstNonzeroSegment = segment;
14966                     segmentsRemaining = true;
14967                 }
14968             }
14969             base10Value = mod10 + base10Value;
14970         }
14971         return base10Value;
14972     }
14973     ts.parsePseudoBigInt = parsePseudoBigInt;
14974     function pseudoBigIntToString(_a) {
14975         var negative = _a.negative, base10Value = _a.base10Value;
14976         return (negative && base10Value !== "0" ? "-" : "") + base10Value;
14977     }
14978     ts.pseudoBigIntToString = pseudoBigIntToString;
14979     function isValidTypeOnlyAliasUseSite(useSite) {
14980         return !!(useSite.flags & 8388608)
14981             || isPartOfTypeQuery(useSite)
14982             || isIdentifierInNonEmittingHeritageClause(useSite)
14983             || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite)
14984             || !isExpressionNode(useSite);
14985     }
14986     ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite;
14987     function typeOnlyDeclarationIsExport(typeOnlyDeclaration) {
14988         return typeOnlyDeclaration.kind === 263;
14989     }
14990     ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport;
14991     function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) {
14992         while (node.kind === 75 || node.kind === 194) {
14993             node = node.parent;
14994         }
14995         if (node.kind !== 154) {
14996             return false;
14997         }
14998         if (hasModifier(node.parent, 128)) {
14999             return true;
15000         }
15001         var containerKind = node.parent.parent.kind;
15002         return containerKind === 246 || containerKind === 173;
15003     }
15004     function isIdentifierInNonEmittingHeritageClause(node) {
15005         if (node.kind !== 75)
15006             return false;
15007         var heritageClause = findAncestor(node.parent, function (parent) {
15008             switch (parent.kind) {
15009                 case 279:
15010                     return true;
15011                 case 194:
15012                 case 216:
15013                     return false;
15014                 default:
15015                     return "quit";
15016             }
15017         });
15018         return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 113 || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 246;
15019     }
15020     function isIdentifierTypeReference(node) {
15021         return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName);
15022     }
15023     ts.isIdentifierTypeReference = isIdentifierTypeReference;
15024     function arrayIsHomogeneous(array, comparer) {
15025         if (comparer === void 0) { comparer = ts.equateValues; }
15026         if (array.length < 2)
15027             return true;
15028         var first = array[0];
15029         for (var i = 1, length_1 = array.length; i < length_1; i++) {
15030             var target = array[i];
15031             if (!comparer(first, target))
15032                 return false;
15033         }
15034         return true;
15035     }
15036     ts.arrayIsHomogeneous = arrayIsHomogeneous;
15037 })(ts || (ts = {}));
15038 var ts;
15039 (function (ts) {
15040     var NodeConstructor;
15041     var TokenConstructor;
15042     var IdentifierConstructor;
15043     var PrivateIdentifierConstructor;
15044     var SourceFileConstructor;
15045     function createNode(kind, pos, end) {
15046         if (kind === 290) {
15047             return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end);
15048         }
15049         else if (kind === 75) {
15050             return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end);
15051         }
15052         else if (kind === 76) {
15053             return new (PrivateIdentifierConstructor || (PrivateIdentifierConstructor = ts.objectAllocator.getPrivateIdentifierConstructor()))(kind, pos, end);
15054         }
15055         else if (!ts.isNodeKind(kind)) {
15056             return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end);
15057         }
15058         else {
15059             return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, pos, end);
15060         }
15061     }
15062     ts.createNode = createNode;
15063     function visitNode(cbNode, node) {
15064         return node && cbNode(node);
15065     }
15066     function visitNodes(cbNode, cbNodes, nodes) {
15067         if (nodes) {
15068             if (cbNodes) {
15069                 return cbNodes(nodes);
15070             }
15071             for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
15072                 var node = nodes_1[_i];
15073                 var result = cbNode(node);
15074                 if (result) {
15075                     return result;
15076                 }
15077             }
15078         }
15079     }
15080     function isJSDocLikeText(text, start) {
15081         return text.charCodeAt(start + 1) === 42 &&
15082             text.charCodeAt(start + 2) === 42 &&
15083             text.charCodeAt(start + 3) !== 47;
15084     }
15085     ts.isJSDocLikeText = isJSDocLikeText;
15086     function forEachChild(node, cbNode, cbNodes) {
15087         if (!node || node.kind <= 152) {
15088             return;
15089         }
15090         switch (node.kind) {
15091             case 153:
15092                 return visitNode(cbNode, node.left) ||
15093                     visitNode(cbNode, node.right);
15094             case 155:
15095                 return visitNode(cbNode, node.name) ||
15096                     visitNode(cbNode, node.constraint) ||
15097                     visitNode(cbNode, node.default) ||
15098                     visitNode(cbNode, node.expression);
15099             case 282:
15100                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15101                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15102                     visitNode(cbNode, node.name) ||
15103                     visitNode(cbNode, node.questionToken) ||
15104                     visitNode(cbNode, node.exclamationToken) ||
15105                     visitNode(cbNode, node.equalsToken) ||
15106                     visitNode(cbNode, node.objectAssignmentInitializer);
15107             case 283:
15108                 return visitNode(cbNode, node.expression);
15109             case 156:
15110                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15111                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15112                     visitNode(cbNode, node.dotDotDotToken) ||
15113                     visitNode(cbNode, node.name) ||
15114                     visitNode(cbNode, node.questionToken) ||
15115                     visitNode(cbNode, node.type) ||
15116                     visitNode(cbNode, node.initializer);
15117             case 159:
15118                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15119                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15120                     visitNode(cbNode, node.name) ||
15121                     visitNode(cbNode, node.questionToken) ||
15122                     visitNode(cbNode, node.exclamationToken) ||
15123                     visitNode(cbNode, node.type) ||
15124                     visitNode(cbNode, node.initializer);
15125             case 158:
15126                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15127                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15128                     visitNode(cbNode, node.name) ||
15129                     visitNode(cbNode, node.questionToken) ||
15130                     visitNode(cbNode, node.type) ||
15131                     visitNode(cbNode, node.initializer);
15132             case 281:
15133                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15134                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15135                     visitNode(cbNode, node.name) ||
15136                     visitNode(cbNode, node.questionToken) ||
15137                     visitNode(cbNode, node.initializer);
15138             case 242:
15139                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15140                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15141                     visitNode(cbNode, node.name) ||
15142                     visitNode(cbNode, node.exclamationToken) ||
15143                     visitNode(cbNode, node.type) ||
15144                     visitNode(cbNode, node.initializer);
15145             case 191:
15146                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15147                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15148                     visitNode(cbNode, node.dotDotDotToken) ||
15149                     visitNode(cbNode, node.propertyName) ||
15150                     visitNode(cbNode, node.name) ||
15151                     visitNode(cbNode, node.initializer);
15152             case 170:
15153             case 171:
15154             case 165:
15155             case 166:
15156             case 167:
15157                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15158                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15159                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
15160                     visitNodes(cbNode, cbNodes, node.parameters) ||
15161                     visitNode(cbNode, node.type);
15162             case 161:
15163             case 160:
15164             case 162:
15165             case 163:
15166             case 164:
15167             case 201:
15168             case 244:
15169             case 202:
15170                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15171                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15172                     visitNode(cbNode, node.asteriskToken) ||
15173                     visitNode(cbNode, node.name) ||
15174                     visitNode(cbNode, node.questionToken) ||
15175                     visitNode(cbNode, node.exclamationToken) ||
15176                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
15177                     visitNodes(cbNode, cbNodes, node.parameters) ||
15178                     visitNode(cbNode, node.type) ||
15179                     visitNode(cbNode, node.equalsGreaterThanToken) ||
15180                     visitNode(cbNode, node.body);
15181             case 169:
15182                 return visitNode(cbNode, node.typeName) ||
15183                     visitNodes(cbNode, cbNodes, node.typeArguments);
15184             case 168:
15185                 return visitNode(cbNode, node.assertsModifier) ||
15186                     visitNode(cbNode, node.parameterName) ||
15187                     visitNode(cbNode, node.type);
15188             case 172:
15189                 return visitNode(cbNode, node.exprName);
15190             case 173:
15191                 return visitNodes(cbNode, cbNodes, node.members);
15192             case 174:
15193                 return visitNode(cbNode, node.elementType);
15194             case 175:
15195                 return visitNodes(cbNode, cbNodes, node.elementTypes);
15196             case 178:
15197             case 179:
15198                 return visitNodes(cbNode, cbNodes, node.types);
15199             case 180:
15200                 return visitNode(cbNode, node.checkType) ||
15201                     visitNode(cbNode, node.extendsType) ||
15202                     visitNode(cbNode, node.trueType) ||
15203                     visitNode(cbNode, node.falseType);
15204             case 181:
15205                 return visitNode(cbNode, node.typeParameter);
15206             case 188:
15207                 return visitNode(cbNode, node.argument) ||
15208                     visitNode(cbNode, node.qualifier) ||
15209                     visitNodes(cbNode, cbNodes, node.typeArguments);
15210             case 182:
15211             case 184:
15212                 return visitNode(cbNode, node.type);
15213             case 185:
15214                 return visitNode(cbNode, node.objectType) ||
15215                     visitNode(cbNode, node.indexType);
15216             case 186:
15217                 return visitNode(cbNode, node.readonlyToken) ||
15218                     visitNode(cbNode, node.typeParameter) ||
15219                     visitNode(cbNode, node.questionToken) ||
15220                     visitNode(cbNode, node.type);
15221             case 187:
15222                 return visitNode(cbNode, node.literal);
15223             case 189:
15224             case 190:
15225                 return visitNodes(cbNode, cbNodes, node.elements);
15226             case 192:
15227                 return visitNodes(cbNode, cbNodes, node.elements);
15228             case 193:
15229                 return visitNodes(cbNode, cbNodes, node.properties);
15230             case 194:
15231                 return visitNode(cbNode, node.expression) ||
15232                     visitNode(cbNode, node.questionDotToken) ||
15233                     visitNode(cbNode, node.name);
15234             case 195:
15235                 return visitNode(cbNode, node.expression) ||
15236                     visitNode(cbNode, node.questionDotToken) ||
15237                     visitNode(cbNode, node.argumentExpression);
15238             case 196:
15239             case 197:
15240                 return visitNode(cbNode, node.expression) ||
15241                     visitNode(cbNode, node.questionDotToken) ||
15242                     visitNodes(cbNode, cbNodes, node.typeArguments) ||
15243                     visitNodes(cbNode, cbNodes, node.arguments);
15244             case 198:
15245                 return visitNode(cbNode, node.tag) ||
15246                     visitNode(cbNode, node.questionDotToken) ||
15247                     visitNodes(cbNode, cbNodes, node.typeArguments) ||
15248                     visitNode(cbNode, node.template);
15249             case 199:
15250                 return visitNode(cbNode, node.type) ||
15251                     visitNode(cbNode, node.expression);
15252             case 200:
15253                 return visitNode(cbNode, node.expression);
15254             case 203:
15255                 return visitNode(cbNode, node.expression);
15256             case 204:
15257                 return visitNode(cbNode, node.expression);
15258             case 205:
15259                 return visitNode(cbNode, node.expression);
15260             case 207:
15261                 return visitNode(cbNode, node.operand);
15262             case 212:
15263                 return visitNode(cbNode, node.asteriskToken) ||
15264                     visitNode(cbNode, node.expression);
15265             case 206:
15266                 return visitNode(cbNode, node.expression);
15267             case 208:
15268                 return visitNode(cbNode, node.operand);
15269             case 209:
15270                 return visitNode(cbNode, node.left) ||
15271                     visitNode(cbNode, node.operatorToken) ||
15272                     visitNode(cbNode, node.right);
15273             case 217:
15274                 return visitNode(cbNode, node.expression) ||
15275                     visitNode(cbNode, node.type);
15276             case 218:
15277                 return visitNode(cbNode, node.expression);
15278             case 219:
15279                 return visitNode(cbNode, node.name);
15280             case 210:
15281                 return visitNode(cbNode, node.condition) ||
15282                     visitNode(cbNode, node.questionToken) ||
15283                     visitNode(cbNode, node.whenTrue) ||
15284                     visitNode(cbNode, node.colonToken) ||
15285                     visitNode(cbNode, node.whenFalse);
15286             case 213:
15287                 return visitNode(cbNode, node.expression);
15288             case 223:
15289             case 250:
15290                 return visitNodes(cbNode, cbNodes, node.statements);
15291             case 290:
15292                 return visitNodes(cbNode, cbNodes, node.statements) ||
15293                     visitNode(cbNode, node.endOfFileToken);
15294             case 225:
15295                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15296                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15297                     visitNode(cbNode, node.declarationList);
15298             case 243:
15299                 return visitNodes(cbNode, cbNodes, node.declarations);
15300             case 226:
15301                 return visitNode(cbNode, node.expression);
15302             case 227:
15303                 return visitNode(cbNode, node.expression) ||
15304                     visitNode(cbNode, node.thenStatement) ||
15305                     visitNode(cbNode, node.elseStatement);
15306             case 228:
15307                 return visitNode(cbNode, node.statement) ||
15308                     visitNode(cbNode, node.expression);
15309             case 229:
15310                 return visitNode(cbNode, node.expression) ||
15311                     visitNode(cbNode, node.statement);
15312             case 230:
15313                 return visitNode(cbNode, node.initializer) ||
15314                     visitNode(cbNode, node.condition) ||
15315                     visitNode(cbNode, node.incrementor) ||
15316                     visitNode(cbNode, node.statement);
15317             case 231:
15318                 return visitNode(cbNode, node.initializer) ||
15319                     visitNode(cbNode, node.expression) ||
15320                     visitNode(cbNode, node.statement);
15321             case 232:
15322                 return visitNode(cbNode, node.awaitModifier) ||
15323                     visitNode(cbNode, node.initializer) ||
15324                     visitNode(cbNode, node.expression) ||
15325                     visitNode(cbNode, node.statement);
15326             case 233:
15327             case 234:
15328                 return visitNode(cbNode, node.label);
15329             case 235:
15330                 return visitNode(cbNode, node.expression);
15331             case 236:
15332                 return visitNode(cbNode, node.expression) ||
15333                     visitNode(cbNode, node.statement);
15334             case 237:
15335                 return visitNode(cbNode, node.expression) ||
15336                     visitNode(cbNode, node.caseBlock);
15337             case 251:
15338                 return visitNodes(cbNode, cbNodes, node.clauses);
15339             case 277:
15340                 return visitNode(cbNode, node.expression) ||
15341                     visitNodes(cbNode, cbNodes, node.statements);
15342             case 278:
15343                 return visitNodes(cbNode, cbNodes, node.statements);
15344             case 238:
15345                 return visitNode(cbNode, node.label) ||
15346                     visitNode(cbNode, node.statement);
15347             case 239:
15348                 return visitNode(cbNode, node.expression);
15349             case 240:
15350                 return visitNode(cbNode, node.tryBlock) ||
15351                     visitNode(cbNode, node.catchClause) ||
15352                     visitNode(cbNode, node.finallyBlock);
15353             case 280:
15354                 return visitNode(cbNode, node.variableDeclaration) ||
15355                     visitNode(cbNode, node.block);
15356             case 157:
15357                 return visitNode(cbNode, node.expression);
15358             case 245:
15359             case 214:
15360                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15361                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15362                     visitNode(cbNode, node.name) ||
15363                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
15364                     visitNodes(cbNode, cbNodes, node.heritageClauses) ||
15365                     visitNodes(cbNode, cbNodes, node.members);
15366             case 246:
15367                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15368                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15369                     visitNode(cbNode, node.name) ||
15370                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
15371                     visitNodes(cbNode, cbNodes, node.heritageClauses) ||
15372                     visitNodes(cbNode, cbNodes, node.members);
15373             case 247:
15374                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15375                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15376                     visitNode(cbNode, node.name) ||
15377                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
15378                     visitNode(cbNode, node.type);
15379             case 248:
15380                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15381                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15382                     visitNode(cbNode, node.name) ||
15383                     visitNodes(cbNode, cbNodes, node.members);
15384             case 284:
15385                 return visitNode(cbNode, node.name) ||
15386                     visitNode(cbNode, node.initializer);
15387             case 249:
15388                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15389                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15390                     visitNode(cbNode, node.name) ||
15391                     visitNode(cbNode, node.body);
15392             case 253:
15393                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15394                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15395                     visitNode(cbNode, node.name) ||
15396                     visitNode(cbNode, node.moduleReference);
15397             case 254:
15398                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15399                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15400                     visitNode(cbNode, node.importClause) ||
15401                     visitNode(cbNode, node.moduleSpecifier);
15402             case 255:
15403                 return visitNode(cbNode, node.name) ||
15404                     visitNode(cbNode, node.namedBindings);
15405             case 252:
15406                 return visitNode(cbNode, node.name);
15407             case 256:
15408                 return visitNode(cbNode, node.name);
15409             case 262:
15410                 return visitNode(cbNode, node.name);
15411             case 257:
15412             case 261:
15413                 return visitNodes(cbNode, cbNodes, node.elements);
15414             case 260:
15415                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15416                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15417                     visitNode(cbNode, node.exportClause) ||
15418                     visitNode(cbNode, node.moduleSpecifier);
15419             case 258:
15420             case 263:
15421                 return visitNode(cbNode, node.propertyName) ||
15422                     visitNode(cbNode, node.name);
15423             case 259:
15424                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15425                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15426                     visitNode(cbNode, node.expression);
15427             case 211:
15428                 return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans);
15429             case 221:
15430                 return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal);
15431             case 154:
15432                 return visitNode(cbNode, node.expression);
15433             case 279:
15434                 return visitNodes(cbNode, cbNodes, node.types);
15435             case 216:
15436                 return visitNode(cbNode, node.expression) ||
15437                     visitNodes(cbNode, cbNodes, node.typeArguments);
15438             case 265:
15439                 return visitNode(cbNode, node.expression);
15440             case 264:
15441                 return visitNodes(cbNode, cbNodes, node.decorators);
15442             case 327:
15443                 return visitNodes(cbNode, cbNodes, node.elements);
15444             case 266:
15445                 return visitNode(cbNode, node.openingElement) ||
15446                     visitNodes(cbNode, cbNodes, node.children) ||
15447                     visitNode(cbNode, node.closingElement);
15448             case 270:
15449                 return visitNode(cbNode, node.openingFragment) ||
15450                     visitNodes(cbNode, cbNodes, node.children) ||
15451                     visitNode(cbNode, node.closingFragment);
15452             case 267:
15453             case 268:
15454                 return visitNode(cbNode, node.tagName) ||
15455                     visitNodes(cbNode, cbNodes, node.typeArguments) ||
15456                     visitNode(cbNode, node.attributes);
15457             case 274:
15458                 return visitNodes(cbNode, cbNodes, node.properties);
15459             case 273:
15460                 return visitNode(cbNode, node.name) ||
15461                     visitNode(cbNode, node.initializer);
15462             case 275:
15463                 return visitNode(cbNode, node.expression);
15464             case 276:
15465                 return visitNode(cbNode, node.dotDotDotToken) ||
15466                     visitNode(cbNode, node.expression);
15467             case 269:
15468                 return visitNode(cbNode, node.tagName);
15469             case 176:
15470             case 177:
15471             case 294:
15472             case 298:
15473             case 297:
15474             case 299:
15475             case 301:
15476                 return visitNode(cbNode, node.type);
15477             case 300:
15478                 return visitNodes(cbNode, cbNodes, node.parameters) ||
15479                     visitNode(cbNode, node.type);
15480             case 303:
15481                 return visitNodes(cbNode, cbNodes, node.tags);
15482             case 317:
15483             case 323:
15484                 return visitNode(cbNode, node.tagName) ||
15485                     (node.isNameFirst
15486                         ? visitNode(cbNode, node.name) ||
15487                             visitNode(cbNode, node.typeExpression)
15488                         : visitNode(cbNode, node.typeExpression) ||
15489                             visitNode(cbNode, node.name));
15490             case 309:
15491                 return visitNode(cbNode, node.tagName);
15492             case 308:
15493                 return visitNode(cbNode, node.tagName) ||
15494                     visitNode(cbNode, node.class);
15495             case 307:
15496                 return visitNode(cbNode, node.tagName) ||
15497                     visitNode(cbNode, node.class);
15498             case 321:
15499                 return visitNode(cbNode, node.tagName) ||
15500                     visitNode(cbNode, node.constraint) ||
15501                     visitNodes(cbNode, cbNodes, node.typeParameters);
15502             case 322:
15503                 return visitNode(cbNode, node.tagName) ||
15504                     (node.typeExpression &&
15505                         node.typeExpression.kind === 294
15506                         ? visitNode(cbNode, node.typeExpression) ||
15507                             visitNode(cbNode, node.fullName)
15508                         : visitNode(cbNode, node.fullName) ||
15509                             visitNode(cbNode, node.typeExpression));
15510             case 315:
15511                 return visitNode(cbNode, node.tagName) ||
15512                     visitNode(cbNode, node.fullName) ||
15513                     visitNode(cbNode, node.typeExpression);
15514             case 318:
15515             case 320:
15516             case 319:
15517             case 316:
15518                 return visitNode(cbNode, node.tagName) ||
15519                     visitNode(cbNode, node.typeExpression);
15520             case 305:
15521                 return ts.forEach(node.typeParameters, cbNode) ||
15522                     ts.forEach(node.parameters, cbNode) ||
15523                     visitNode(cbNode, node.type);
15524             case 304:
15525                 return ts.forEach(node.jsDocPropertyTags, cbNode);
15526             case 306:
15527             case 310:
15528             case 311:
15529             case 312:
15530             case 313:
15531             case 314:
15532                 return visitNode(cbNode, node.tagName);
15533             case 326:
15534                 return visitNode(cbNode, node.expression);
15535         }
15536     }
15537     ts.forEachChild = forEachChild;
15538     function forEachChildRecursively(rootNode, cbNode, cbNodes) {
15539         var stack = [rootNode];
15540         while (stack.length) {
15541             var parent = stack.pop();
15542             var res = visitAllPossibleChildren(parent, gatherPossibleChildren(parent));
15543             if (res) {
15544                 return res;
15545             }
15546         }
15547         return;
15548         function gatherPossibleChildren(node) {
15549             var children = [];
15550             forEachChild(node, addWorkItem, addWorkItem);
15551             return children;
15552             function addWorkItem(n) {
15553                 children.unshift(n);
15554             }
15555         }
15556         function visitAllPossibleChildren(parent, children) {
15557             for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
15558                 var child = children_1[_i];
15559                 if (ts.isArray(child)) {
15560                     if (cbNodes) {
15561                         var res = cbNodes(child, parent);
15562                         if (res) {
15563                             if (res === "skip")
15564                                 continue;
15565                             return res;
15566                         }
15567                     }
15568                     for (var i = child.length - 1; i >= 0; i--) {
15569                         var realChild = child[i];
15570                         var res = cbNode(realChild, parent);
15571                         if (res) {
15572                             if (res === "skip")
15573                                 continue;
15574                             return res;
15575                         }
15576                         stack.push(realChild);
15577                     }
15578                 }
15579                 else {
15580                     stack.push(child);
15581                     var res = cbNode(child, parent);
15582                     if (res) {
15583                         if (res === "skip")
15584                             continue;
15585                         return res;
15586                     }
15587                 }
15588             }
15589         }
15590     }
15591     ts.forEachChildRecursively = forEachChildRecursively;
15592     function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) {
15593         if (setParentNodes === void 0) { setParentNodes = false; }
15594         ts.performance.mark("beforeParse");
15595         var result;
15596         ts.perfLogger.logStartParseSourceFile(fileName);
15597         if (languageVersion === 100) {
15598             result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes, 6);
15599         }
15600         else {
15601             result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes, scriptKind);
15602         }
15603         ts.perfLogger.logStopParseSourceFile();
15604         ts.performance.mark("afterParse");
15605         ts.performance.measure("Parse", "beforeParse", "afterParse");
15606         return result;
15607     }
15608     ts.createSourceFile = createSourceFile;
15609     function parseIsolatedEntityName(text, languageVersion) {
15610         return Parser.parseIsolatedEntityName(text, languageVersion);
15611     }
15612     ts.parseIsolatedEntityName = parseIsolatedEntityName;
15613     function parseJsonText(fileName, sourceText) {
15614         return Parser.parseJsonText(fileName, sourceText);
15615     }
15616     ts.parseJsonText = parseJsonText;
15617     function isExternalModule(file) {
15618         return file.externalModuleIndicator !== undefined;
15619     }
15620     ts.isExternalModule = isExternalModule;
15621     function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) {
15622         if (aggressiveChecks === void 0) { aggressiveChecks = false; }
15623         var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
15624         newSourceFile.flags |= (sourceFile.flags & 3145728);
15625         return newSourceFile;
15626     }
15627     ts.updateSourceFile = updateSourceFile;
15628     function parseIsolatedJSDocComment(content, start, length) {
15629         var result = Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length);
15630         if (result && result.jsDoc) {
15631             Parser.fixupParentReferences(result.jsDoc);
15632         }
15633         return result;
15634     }
15635     ts.parseIsolatedJSDocComment = parseIsolatedJSDocComment;
15636     function parseJSDocTypeExpressionForTests(content, start, length) {
15637         return Parser.JSDocParser.parseJSDocTypeExpressionForTests(content, start, length);
15638     }
15639     ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests;
15640     var Parser;
15641     (function (Parser) {
15642         var scanner = ts.createScanner(99, true);
15643         var disallowInAndDecoratorContext = 4096 | 16384;
15644         var NodeConstructor;
15645         var TokenConstructor;
15646         var IdentifierConstructor;
15647         var PrivateIdentifierConstructor;
15648         var SourceFileConstructor;
15649         var sourceFile;
15650         var parseDiagnostics;
15651         var syntaxCursor;
15652         var currentToken;
15653         var sourceText;
15654         var nodeCount;
15655         var identifiers;
15656         var privateIdentifiers;
15657         var identifierCount;
15658         var parsingContext;
15659         var notParenthesizedArrow;
15660         var contextFlags;
15661         var parseErrorBeforeNextFinishedNode = false;
15662         function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) {
15663             if (setParentNodes === void 0) { setParentNodes = false; }
15664             scriptKind = ts.ensureScriptKind(fileName, scriptKind);
15665             if (scriptKind === 6) {
15666                 var result_2 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes);
15667                 ts.convertToObjectWorker(result_2, result_2.parseDiagnostics, false, undefined, undefined);
15668                 result_2.referencedFiles = ts.emptyArray;
15669                 result_2.typeReferenceDirectives = ts.emptyArray;
15670                 result_2.libReferenceDirectives = ts.emptyArray;
15671                 result_2.amdDependencies = ts.emptyArray;
15672                 result_2.hasNoDefaultLib = false;
15673                 result_2.pragmas = ts.emptyMap;
15674                 return result_2;
15675             }
15676             initializeState(sourceText, languageVersion, syntaxCursor, scriptKind);
15677             var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind);
15678             clearState();
15679             return result;
15680         }
15681         Parser.parseSourceFile = parseSourceFile;
15682         function parseIsolatedEntityName(content, languageVersion) {
15683             initializeState(content, languageVersion, undefined, 1);
15684             nextToken();
15685             var entityName = parseEntityName(true);
15686             var isInvalid = token() === 1 && !parseDiagnostics.length;
15687             clearState();
15688             return isInvalid ? entityName : undefined;
15689         }
15690         Parser.parseIsolatedEntityName = parseIsolatedEntityName;
15691         function parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes) {
15692             if (languageVersion === void 0) { languageVersion = 2; }
15693             initializeState(sourceText, languageVersion, syntaxCursor, 6);
15694             sourceFile = createSourceFile(fileName, 2, 6, false);
15695             sourceFile.flags = contextFlags;
15696             nextToken();
15697             var pos = getNodePos();
15698             if (token() === 1) {
15699                 sourceFile.statements = createNodeArray([], pos, pos);
15700                 sourceFile.endOfFileToken = parseTokenNode();
15701             }
15702             else {
15703                 var statement = createNode(226);
15704                 switch (token()) {
15705                     case 22:
15706                         statement.expression = parseArrayLiteralExpression();
15707                         break;
15708                     case 106:
15709                     case 91:
15710                     case 100:
15711                         statement.expression = parseTokenNode();
15712                         break;
15713                     case 40:
15714                         if (lookAhead(function () { return nextToken() === 8 && nextToken() !== 58; })) {
15715                             statement.expression = parsePrefixUnaryExpression();
15716                         }
15717                         else {
15718                             statement.expression = parseObjectLiteralExpression();
15719                         }
15720                         break;
15721                     case 8:
15722                     case 10:
15723                         if (lookAhead(function () { return nextToken() !== 58; })) {
15724                             statement.expression = parseLiteralNode();
15725                             break;
15726                         }
15727                     default:
15728                         statement.expression = parseObjectLiteralExpression();
15729                         break;
15730                 }
15731                 finishNode(statement);
15732                 sourceFile.statements = createNodeArray([statement], pos);
15733                 sourceFile.endOfFileToken = parseExpectedToken(1, ts.Diagnostics.Unexpected_token);
15734             }
15735             if (setParentNodes) {
15736                 fixupParentReferences(sourceFile);
15737             }
15738             sourceFile.nodeCount = nodeCount;
15739             sourceFile.identifierCount = identifierCount;
15740             sourceFile.identifiers = identifiers;
15741             sourceFile.parseDiagnostics = parseDiagnostics;
15742             var result = sourceFile;
15743             clearState();
15744             return result;
15745         }
15746         Parser.parseJsonText = parseJsonText;
15747         function getLanguageVariant(scriptKind) {
15748             return scriptKind === 4 || scriptKind === 2 || scriptKind === 1 || scriptKind === 6 ? 1 : 0;
15749         }
15750         function initializeState(_sourceText, languageVersion, _syntaxCursor, scriptKind) {
15751             NodeConstructor = ts.objectAllocator.getNodeConstructor();
15752             TokenConstructor = ts.objectAllocator.getTokenConstructor();
15753             IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor();
15754             PrivateIdentifierConstructor = ts.objectAllocator.getPrivateIdentifierConstructor();
15755             SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor();
15756             sourceText = _sourceText;
15757             syntaxCursor = _syntaxCursor;
15758             parseDiagnostics = [];
15759             parsingContext = 0;
15760             identifiers = ts.createMap();
15761             privateIdentifiers = ts.createMap();
15762             identifierCount = 0;
15763             nodeCount = 0;
15764             switch (scriptKind) {
15765                 case 1:
15766                 case 2:
15767                     contextFlags = 131072;
15768                     break;
15769                 case 6:
15770                     contextFlags = 131072 | 33554432;
15771                     break;
15772                 default:
15773                     contextFlags = 0;
15774                     break;
15775             }
15776             parseErrorBeforeNextFinishedNode = false;
15777             scanner.setText(sourceText);
15778             scanner.setOnError(scanError);
15779             scanner.setScriptTarget(languageVersion);
15780             scanner.setLanguageVariant(getLanguageVariant(scriptKind));
15781         }
15782         function clearState() {
15783             scanner.clearCommentDirectives();
15784             scanner.setText("");
15785             scanner.setOnError(undefined);
15786             parseDiagnostics = undefined;
15787             sourceFile = undefined;
15788             identifiers = undefined;
15789             syntaxCursor = undefined;
15790             sourceText = undefined;
15791             notParenthesizedArrow = undefined;
15792         }
15793         function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) {
15794             var isDeclarationFile = isDeclarationFileName(fileName);
15795             if (isDeclarationFile) {
15796                 contextFlags |= 8388608;
15797             }
15798             sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile);
15799             sourceFile.flags = contextFlags;
15800             nextToken();
15801             processCommentPragmas(sourceFile, sourceText);
15802             processPragmasIntoFields(sourceFile, reportPragmaDiagnostic);
15803             sourceFile.statements = parseList(0, parseStatement);
15804             ts.Debug.assert(token() === 1);
15805             sourceFile.endOfFileToken = addJSDocComment(parseTokenNode());
15806             setExternalModuleIndicator(sourceFile);
15807             sourceFile.commentDirectives = scanner.getCommentDirectives();
15808             sourceFile.nodeCount = nodeCount;
15809             sourceFile.identifierCount = identifierCount;
15810             sourceFile.identifiers = identifiers;
15811             sourceFile.parseDiagnostics = parseDiagnostics;
15812             if (setParentNodes) {
15813                 fixupParentReferences(sourceFile);
15814             }
15815             return sourceFile;
15816             function reportPragmaDiagnostic(pos, end, diagnostic) {
15817                 parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, pos, end, diagnostic));
15818             }
15819         }
15820         function addJSDocComment(node) {
15821             ts.Debug.assert(!node.jsDoc);
15822             var jsDoc = ts.mapDefined(ts.getJSDocCommentRanges(node, sourceFile.text), function (comment) { return JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); });
15823             if (jsDoc.length)
15824                 node.jsDoc = jsDoc;
15825             return node;
15826         }
15827         function fixupParentReferences(rootNode) {
15828             forEachChildRecursively(rootNode, bindParentToChild);
15829             function bindParentToChild(child, parent) {
15830                 child.parent = parent;
15831                 if (ts.hasJSDocNodes(child)) {
15832                     for (var _i = 0, _a = child.jsDoc; _i < _a.length; _i++) {
15833                         var doc = _a[_i];
15834                         bindParentToChild(doc, child);
15835                         forEachChildRecursively(doc, bindParentToChild);
15836                     }
15837                 }
15838             }
15839         }
15840         Parser.fixupParentReferences = fixupParentReferences;
15841         function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) {
15842             var sourceFile = new SourceFileConstructor(290, 0, sourceText.length);
15843             nodeCount++;
15844             sourceFile.text = sourceText;
15845             sourceFile.bindDiagnostics = [];
15846             sourceFile.bindSuggestionDiagnostics = undefined;
15847             sourceFile.languageVersion = languageVersion;
15848             sourceFile.fileName = ts.normalizePath(fileName);
15849             sourceFile.languageVariant = getLanguageVariant(scriptKind);
15850             sourceFile.isDeclarationFile = isDeclarationFile;
15851             sourceFile.scriptKind = scriptKind;
15852             return sourceFile;
15853         }
15854         function setContextFlag(val, flag) {
15855             if (val) {
15856                 contextFlags |= flag;
15857             }
15858             else {
15859                 contextFlags &= ~flag;
15860             }
15861         }
15862         function setDisallowInContext(val) {
15863             setContextFlag(val, 4096);
15864         }
15865         function setYieldContext(val) {
15866             setContextFlag(val, 8192);
15867         }
15868         function setDecoratorContext(val) {
15869             setContextFlag(val, 16384);
15870         }
15871         function setAwaitContext(val) {
15872             setContextFlag(val, 32768);
15873         }
15874         function doOutsideOfContext(context, func) {
15875             var contextFlagsToClear = context & contextFlags;
15876             if (contextFlagsToClear) {
15877                 setContextFlag(false, contextFlagsToClear);
15878                 var result = func();
15879                 setContextFlag(true, contextFlagsToClear);
15880                 return result;
15881             }
15882             return func();
15883         }
15884         function doInsideOfContext(context, func) {
15885             var contextFlagsToSet = context & ~contextFlags;
15886             if (contextFlagsToSet) {
15887                 setContextFlag(true, contextFlagsToSet);
15888                 var result = func();
15889                 setContextFlag(false, contextFlagsToSet);
15890                 return result;
15891             }
15892             return func();
15893         }
15894         function allowInAnd(func) {
15895             return doOutsideOfContext(4096, func);
15896         }
15897         function disallowInAnd(func) {
15898             return doInsideOfContext(4096, func);
15899         }
15900         function doInYieldContext(func) {
15901             return doInsideOfContext(8192, func);
15902         }
15903         function doInDecoratorContext(func) {
15904             return doInsideOfContext(16384, func);
15905         }
15906         function doInAwaitContext(func) {
15907             return doInsideOfContext(32768, func);
15908         }
15909         function doOutsideOfAwaitContext(func) {
15910             return doOutsideOfContext(32768, func);
15911         }
15912         function doInYieldAndAwaitContext(func) {
15913             return doInsideOfContext(8192 | 32768, func);
15914         }
15915         function doOutsideOfYieldAndAwaitContext(func) {
15916             return doOutsideOfContext(8192 | 32768, func);
15917         }
15918         function inContext(flags) {
15919             return (contextFlags & flags) !== 0;
15920         }
15921         function inYieldContext() {
15922             return inContext(8192);
15923         }
15924         function inDisallowInContext() {
15925             return inContext(4096);
15926         }
15927         function inDecoratorContext() {
15928             return inContext(16384);
15929         }
15930         function inAwaitContext() {
15931             return inContext(32768);
15932         }
15933         function parseErrorAtCurrentToken(message, arg0) {
15934             parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
15935         }
15936         function parseErrorAtPosition(start, length, message, arg0) {
15937             var lastError = ts.lastOrUndefined(parseDiagnostics);
15938             if (!lastError || start !== lastError.start) {
15939                 parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, start, length, message, arg0));
15940             }
15941             parseErrorBeforeNextFinishedNode = true;
15942         }
15943         function parseErrorAt(start, end, message, arg0) {
15944             parseErrorAtPosition(start, end - start, message, arg0);
15945         }
15946         function parseErrorAtRange(range, message, arg0) {
15947             parseErrorAt(range.pos, range.end, message, arg0);
15948         }
15949         function scanError(message, length) {
15950             parseErrorAtPosition(scanner.getTextPos(), length, message);
15951         }
15952         function getNodePos() {
15953             return scanner.getStartPos();
15954         }
15955         function token() {
15956             return currentToken;
15957         }
15958         function nextTokenWithoutCheck() {
15959             return currentToken = scanner.scan();
15960         }
15961         function nextToken() {
15962             if (ts.isKeyword(currentToken) && (scanner.hasUnicodeEscape() || scanner.hasExtendedUnicodeEscape())) {
15963                 parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), ts.Diagnostics.Keywords_cannot_contain_escape_characters);
15964             }
15965             return nextTokenWithoutCheck();
15966         }
15967         function nextTokenJSDoc() {
15968             return currentToken = scanner.scanJsDocToken();
15969         }
15970         function reScanGreaterToken() {
15971             return currentToken = scanner.reScanGreaterToken();
15972         }
15973         function reScanSlashToken() {
15974             return currentToken = scanner.reScanSlashToken();
15975         }
15976         function reScanTemplateToken(isTaggedTemplate) {
15977             return currentToken = scanner.reScanTemplateToken(isTaggedTemplate);
15978         }
15979         function reScanTemplateHeadOrNoSubstitutionTemplate() {
15980             return currentToken = scanner.reScanTemplateHeadOrNoSubstitutionTemplate();
15981         }
15982         function reScanLessThanToken() {
15983             return currentToken = scanner.reScanLessThanToken();
15984         }
15985         function scanJsxIdentifier() {
15986             return currentToken = scanner.scanJsxIdentifier();
15987         }
15988         function scanJsxText() {
15989             return currentToken = scanner.scanJsxToken();
15990         }
15991         function scanJsxAttributeValue() {
15992             return currentToken = scanner.scanJsxAttributeValue();
15993         }
15994         function speculationHelper(callback, isLookAhead) {
15995             var saveToken = currentToken;
15996             var saveParseDiagnosticsLength = parseDiagnostics.length;
15997             var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
15998             var saveContextFlags = contextFlags;
15999             var result = isLookAhead
16000                 ? scanner.lookAhead(callback)
16001                 : scanner.tryScan(callback);
16002             ts.Debug.assert(saveContextFlags === contextFlags);
16003             if (!result || isLookAhead) {
16004                 currentToken = saveToken;
16005                 parseDiagnostics.length = saveParseDiagnosticsLength;
16006                 parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode;
16007             }
16008             return result;
16009         }
16010         function lookAhead(callback) {
16011             return speculationHelper(callback, true);
16012         }
16013         function tryParse(callback) {
16014             return speculationHelper(callback, false);
16015         }
16016         function isIdentifier() {
16017             if (token() === 75) {
16018                 return true;
16019             }
16020             if (token() === 121 && inYieldContext()) {
16021                 return false;
16022             }
16023             if (token() === 127 && inAwaitContext()) {
16024                 return false;
16025             }
16026             return token() > 112;
16027         }
16028         function parseExpected(kind, diagnosticMessage, shouldAdvance) {
16029             if (shouldAdvance === void 0) { shouldAdvance = true; }
16030             if (token() === kind) {
16031                 if (shouldAdvance) {
16032                     nextToken();
16033                 }
16034                 return true;
16035             }
16036             if (diagnosticMessage) {
16037                 parseErrorAtCurrentToken(diagnosticMessage);
16038             }
16039             else {
16040                 parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind));
16041             }
16042             return false;
16043         }
16044         function parseExpectedJSDoc(kind) {
16045             if (token() === kind) {
16046                 nextTokenJSDoc();
16047                 return true;
16048             }
16049             parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind));
16050             return false;
16051         }
16052         function parseOptional(t) {
16053             if (token() === t) {
16054                 nextToken();
16055                 return true;
16056             }
16057             return false;
16058         }
16059         function parseOptionalToken(t) {
16060             if (token() === t) {
16061                 return parseTokenNode();
16062             }
16063             return undefined;
16064         }
16065         function parseOptionalTokenJSDoc(t) {
16066             if (token() === t) {
16067                 return parseTokenNodeJSDoc();
16068             }
16069             return undefined;
16070         }
16071         function parseExpectedToken(t, diagnosticMessage, arg0) {
16072             return parseOptionalToken(t) ||
16073                 createMissingNode(t, false, diagnosticMessage || ts.Diagnostics._0_expected, arg0 || ts.tokenToString(t));
16074         }
16075         function parseExpectedTokenJSDoc(t) {
16076             return parseOptionalTokenJSDoc(t) ||
16077                 createMissingNode(t, false, ts.Diagnostics._0_expected, ts.tokenToString(t));
16078         }
16079         function parseTokenNode() {
16080             var node = createNode(token());
16081             nextToken();
16082             return finishNode(node);
16083         }
16084         function parseTokenNodeJSDoc() {
16085             var node = createNode(token());
16086             nextTokenJSDoc();
16087             return finishNode(node);
16088         }
16089         function canParseSemicolon() {
16090             if (token() === 26) {
16091                 return true;
16092             }
16093             return token() === 19 || token() === 1 || scanner.hasPrecedingLineBreak();
16094         }
16095         function parseSemicolon() {
16096             if (canParseSemicolon()) {
16097                 if (token() === 26) {
16098                     nextToken();
16099                 }
16100                 return true;
16101             }
16102             else {
16103                 return parseExpected(26);
16104             }
16105         }
16106         function createNode(kind, pos) {
16107             nodeCount++;
16108             var p = pos >= 0 ? pos : scanner.getStartPos();
16109             return ts.isNodeKind(kind) || kind === 0 ? new NodeConstructor(kind, p, p) :
16110                 kind === 75 ? new IdentifierConstructor(kind, p, p) :
16111                     kind === 76 ? new PrivateIdentifierConstructor(kind, p, p) :
16112                         new TokenConstructor(kind, p, p);
16113         }
16114         function createNodeWithJSDoc(kind, pos) {
16115             var node = createNode(kind, pos);
16116             if (scanner.getTokenFlags() & 2 && (kind !== 226 || token() !== 20)) {
16117                 addJSDocComment(node);
16118             }
16119             return node;
16120         }
16121         function createNodeArray(elements, pos, end) {
16122             var length = elements.length;
16123             var array = (length >= 1 && length <= 4 ? elements.slice() : elements);
16124             array.pos = pos;
16125             array.end = end === undefined ? scanner.getStartPos() : end;
16126             return array;
16127         }
16128         function finishNode(node, end) {
16129             node.end = end === undefined ? scanner.getStartPos() : end;
16130             if (contextFlags) {
16131                 node.flags |= contextFlags;
16132             }
16133             if (parseErrorBeforeNextFinishedNode) {
16134                 parseErrorBeforeNextFinishedNode = false;
16135                 node.flags |= 65536;
16136             }
16137             return node;
16138         }
16139         function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, arg0) {
16140             if (reportAtCurrentPosition) {
16141                 parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0);
16142             }
16143             else if (diagnosticMessage) {
16144                 parseErrorAtCurrentToken(diagnosticMessage, arg0);
16145             }
16146             var result = createNode(kind);
16147             if (kind === 75) {
16148                 result.escapedText = "";
16149             }
16150             else if (ts.isLiteralKind(kind) || ts.isTemplateLiteralKind(kind)) {
16151                 result.text = "";
16152             }
16153             return finishNode(result);
16154         }
16155         function internIdentifier(text) {
16156             var identifier = identifiers.get(text);
16157             if (identifier === undefined) {
16158                 identifiers.set(text, identifier = text);
16159             }
16160             return identifier;
16161         }
16162         function createIdentifier(isIdentifier, diagnosticMessage, privateIdentifierDiagnosticMessage) {
16163             identifierCount++;
16164             if (isIdentifier) {
16165                 var node = createNode(75);
16166                 if (token() !== 75) {
16167                     node.originalKeywordKind = token();
16168                 }
16169                 node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue()));
16170                 nextTokenWithoutCheck();
16171                 return finishNode(node);
16172             }
16173             if (token() === 76) {
16174                 parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
16175                 return createIdentifier(true);
16176             }
16177             var reportAtCurrentPosition = token() === 1;
16178             var isReservedWord = scanner.isReservedWord();
16179             var msgArg = scanner.getTokenText();
16180             var defaultMessage = isReservedWord ?
16181                 ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here :
16182                 ts.Diagnostics.Identifier_expected;
16183             return createMissingNode(75, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg);
16184         }
16185         function parseIdentifier(diagnosticMessage, privateIdentifierDiagnosticMessage) {
16186             return createIdentifier(isIdentifier(), diagnosticMessage, privateIdentifierDiagnosticMessage);
16187         }
16188         function parseIdentifierName(diagnosticMessage) {
16189             return createIdentifier(ts.tokenIsIdentifierOrKeyword(token()), diagnosticMessage);
16190         }
16191         function isLiteralPropertyName() {
16192             return ts.tokenIsIdentifierOrKeyword(token()) ||
16193                 token() === 10 ||
16194                 token() === 8;
16195         }
16196         function parsePropertyNameWorker(allowComputedPropertyNames) {
16197             if (token() === 10 || token() === 8) {
16198                 var node = parseLiteralNode();
16199                 node.text = internIdentifier(node.text);
16200                 return node;
16201             }
16202             if (allowComputedPropertyNames && token() === 22) {
16203                 return parseComputedPropertyName();
16204             }
16205             if (token() === 76) {
16206                 return parsePrivateIdentifier();
16207             }
16208             return parseIdentifierName();
16209         }
16210         function parsePropertyName() {
16211             return parsePropertyNameWorker(true);
16212         }
16213         function parseComputedPropertyName() {
16214             var node = createNode(154);
16215             parseExpected(22);
16216             node.expression = allowInAnd(parseExpression);
16217             parseExpected(23);
16218             return finishNode(node);
16219         }
16220         function internPrivateIdentifier(text) {
16221             var privateIdentifier = privateIdentifiers.get(text);
16222             if (privateIdentifier === undefined) {
16223                 privateIdentifiers.set(text, privateIdentifier = text);
16224             }
16225             return privateIdentifier;
16226         }
16227         function parsePrivateIdentifier() {
16228             var node = createNode(76);
16229             node.escapedText = ts.escapeLeadingUnderscores(internPrivateIdentifier(scanner.getTokenText()));
16230             nextToken();
16231             return finishNode(node);
16232         }
16233         function parseContextualModifier(t) {
16234             return token() === t && tryParse(nextTokenCanFollowModifier);
16235         }
16236         function nextTokenIsOnSameLineAndCanFollowModifier() {
16237             nextToken();
16238             if (scanner.hasPrecedingLineBreak()) {
16239                 return false;
16240             }
16241             return canFollowModifier();
16242         }
16243         function nextTokenCanFollowModifier() {
16244             switch (token()) {
16245                 case 81:
16246                     return nextToken() === 88;
16247                 case 89:
16248                     nextToken();
16249                     if (token() === 84) {
16250                         return lookAhead(nextTokenCanFollowDefaultKeyword);
16251                     }
16252                     if (token() === 145) {
16253                         return lookAhead(nextTokenCanFollowExportModifier);
16254                     }
16255                     return canFollowExportModifier();
16256                 case 84:
16257                     return nextTokenCanFollowDefaultKeyword();
16258                 case 120:
16259                 case 131:
16260                 case 142:
16261                     nextToken();
16262                     return canFollowModifier();
16263                 default:
16264                     return nextTokenIsOnSameLineAndCanFollowModifier();
16265             }
16266         }
16267         function canFollowExportModifier() {
16268             return token() !== 41
16269                 && token() !== 123
16270                 && token() !== 18
16271                 && canFollowModifier();
16272         }
16273         function nextTokenCanFollowExportModifier() {
16274             nextToken();
16275             return canFollowExportModifier();
16276         }
16277         function parseAnyContextualModifier() {
16278             return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier);
16279         }
16280         function canFollowModifier() {
16281             return token() === 22
16282                 || token() === 18
16283                 || token() === 41
16284                 || token() === 25
16285                 || isLiteralPropertyName();
16286         }
16287         function nextTokenCanFollowDefaultKeyword() {
16288             nextToken();
16289             return token() === 80 || token() === 94 ||
16290                 token() === 114 ||
16291                 (token() === 122 && lookAhead(nextTokenIsClassKeywordOnSameLine)) ||
16292                 (token() === 126 && lookAhead(nextTokenIsFunctionKeywordOnSameLine));
16293         }
16294         function isListElement(parsingContext, inErrorRecovery) {
16295             var node = currentNode(parsingContext);
16296             if (node) {
16297                 return true;
16298             }
16299             switch (parsingContext) {
16300                 case 0:
16301                 case 1:
16302                 case 3:
16303                     return !(token() === 26 && inErrorRecovery) && isStartOfStatement();
16304                 case 2:
16305                     return token() === 78 || token() === 84;
16306                 case 4:
16307                     return lookAhead(isTypeMemberStart);
16308                 case 5:
16309                     return lookAhead(isClassMemberStart) || (token() === 26 && !inErrorRecovery);
16310                 case 6:
16311                     return token() === 22 || isLiteralPropertyName();
16312                 case 12:
16313                     switch (token()) {
16314                         case 22:
16315                         case 41:
16316                         case 25:
16317                         case 24:
16318                             return true;
16319                         default:
16320                             return isLiteralPropertyName();
16321                     }
16322                 case 18:
16323                     return isLiteralPropertyName();
16324                 case 9:
16325                     return token() === 22 || token() === 25 || isLiteralPropertyName();
16326                 case 7:
16327                     if (token() === 18) {
16328                         return lookAhead(isValidHeritageClauseObjectLiteral);
16329                     }
16330                     if (!inErrorRecovery) {
16331                         return isStartOfLeftHandSideExpression() && !isHeritageClauseExtendsOrImplementsKeyword();
16332                     }
16333                     else {
16334                         return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword();
16335                     }
16336                 case 8:
16337                     return isIdentifierOrPrivateIdentifierOrPattern();
16338                 case 10:
16339                     return token() === 27 || token() === 25 || isIdentifierOrPrivateIdentifierOrPattern();
16340                 case 19:
16341                     return isIdentifier();
16342                 case 15:
16343                     switch (token()) {
16344                         case 27:
16345                         case 24:
16346                             return true;
16347                     }
16348                 case 11:
16349                     return token() === 25 || isStartOfExpression();
16350                 case 16:
16351                     return isStartOfParameter(false);
16352                 case 17:
16353                     return isStartOfParameter(true);
16354                 case 20:
16355                 case 21:
16356                     return token() === 27 || isStartOfType();
16357                 case 22:
16358                     return isHeritageClause();
16359                 case 23:
16360                     return ts.tokenIsIdentifierOrKeyword(token());
16361                 case 13:
16362                     return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18;
16363                 case 14:
16364                     return true;
16365             }
16366             return ts.Debug.fail("Non-exhaustive case in 'isListElement'.");
16367         }
16368         function isValidHeritageClauseObjectLiteral() {
16369             ts.Debug.assert(token() === 18);
16370             if (nextToken() === 19) {
16371                 var next = nextToken();
16372                 return next === 27 || next === 18 || next === 90 || next === 113;
16373             }
16374             return true;
16375         }
16376         function nextTokenIsIdentifier() {
16377             nextToken();
16378             return isIdentifier();
16379         }
16380         function nextTokenIsIdentifierOrKeyword() {
16381             nextToken();
16382             return ts.tokenIsIdentifierOrKeyword(token());
16383         }
16384         function nextTokenIsIdentifierOrKeywordOrGreaterThan() {
16385             nextToken();
16386             return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token());
16387         }
16388         function isHeritageClauseExtendsOrImplementsKeyword() {
16389             if (token() === 113 ||
16390                 token() === 90) {
16391                 return lookAhead(nextTokenIsStartOfExpression);
16392             }
16393             return false;
16394         }
16395         function nextTokenIsStartOfExpression() {
16396             nextToken();
16397             return isStartOfExpression();
16398         }
16399         function nextTokenIsStartOfType() {
16400             nextToken();
16401             return isStartOfType();
16402         }
16403         function isListTerminator(kind) {
16404             if (token() === 1) {
16405                 return true;
16406             }
16407             switch (kind) {
16408                 case 1:
16409                 case 2:
16410                 case 4:
16411                 case 5:
16412                 case 6:
16413                 case 12:
16414                 case 9:
16415                 case 23:
16416                     return token() === 19;
16417                 case 3:
16418                     return token() === 19 || token() === 78 || token() === 84;
16419                 case 7:
16420                     return token() === 18 || token() === 90 || token() === 113;
16421                 case 8:
16422                     return isVariableDeclaratorListTerminator();
16423                 case 19:
16424                     return token() === 31 || token() === 20 || token() === 18 || token() === 90 || token() === 113;
16425                 case 11:
16426                     return token() === 21 || token() === 26;
16427                 case 15:
16428                 case 21:
16429                 case 10:
16430                     return token() === 23;
16431                 case 17:
16432                 case 16:
16433                 case 18:
16434                     return token() === 21 || token() === 23;
16435                 case 20:
16436                     return token() !== 27;
16437                 case 22:
16438                     return token() === 18 || token() === 19;
16439                 case 13:
16440                     return token() === 31 || token() === 43;
16441                 case 14:
16442                     return token() === 29 && lookAhead(nextTokenIsSlash);
16443                 default:
16444                     return false;
16445             }
16446         }
16447         function isVariableDeclaratorListTerminator() {
16448             if (canParseSemicolon()) {
16449                 return true;
16450             }
16451             if (isInOrOfKeyword(token())) {
16452                 return true;
16453             }
16454             if (token() === 38) {
16455                 return true;
16456             }
16457             return false;
16458         }
16459         function isInSomeParsingContext() {
16460             for (var kind = 0; kind < 24; kind++) {
16461                 if (parsingContext & (1 << kind)) {
16462                     if (isListElement(kind, true) || isListTerminator(kind)) {
16463                         return true;
16464                     }
16465                 }
16466             }
16467             return false;
16468         }
16469         function parseList(kind, parseElement) {
16470             var saveParsingContext = parsingContext;
16471             parsingContext |= 1 << kind;
16472             var list = [];
16473             var listPos = getNodePos();
16474             while (!isListTerminator(kind)) {
16475                 if (isListElement(kind, false)) {
16476                     var element = parseListElement(kind, parseElement);
16477                     list.push(element);
16478                     continue;
16479                 }
16480                 if (abortParsingListOrMoveToNextToken(kind)) {
16481                     break;
16482                 }
16483             }
16484             parsingContext = saveParsingContext;
16485             return createNodeArray(list, listPos);
16486         }
16487         function parseListElement(parsingContext, parseElement) {
16488             var node = currentNode(parsingContext);
16489             if (node) {
16490                 return consumeNode(node);
16491             }
16492             return parseElement();
16493         }
16494         function currentNode(parsingContext) {
16495             if (!syntaxCursor || !isReusableParsingContext(parsingContext) || parseErrorBeforeNextFinishedNode) {
16496                 return undefined;
16497             }
16498             var node = syntaxCursor.currentNode(scanner.getStartPos());
16499             if (ts.nodeIsMissing(node) || node.intersectsChange || ts.containsParseError(node)) {
16500                 return undefined;
16501             }
16502             var nodeContextFlags = node.flags & 25358336;
16503             if (nodeContextFlags !== contextFlags) {
16504                 return undefined;
16505             }
16506             if (!canReuseNode(node, parsingContext)) {
16507                 return undefined;
16508             }
16509             if (node.jsDocCache) {
16510                 node.jsDocCache = undefined;
16511             }
16512             return node;
16513         }
16514         function consumeNode(node) {
16515             scanner.setTextPos(node.end);
16516             nextToken();
16517             return node;
16518         }
16519         function isReusableParsingContext(parsingContext) {
16520             switch (parsingContext) {
16521                 case 5:
16522                 case 2:
16523                 case 0:
16524                 case 1:
16525                 case 3:
16526                 case 6:
16527                 case 4:
16528                 case 8:
16529                 case 17:
16530                 case 16:
16531                     return true;
16532             }
16533             return false;
16534         }
16535         function canReuseNode(node, parsingContext) {
16536             switch (parsingContext) {
16537                 case 5:
16538                     return isReusableClassMember(node);
16539                 case 2:
16540                     return isReusableSwitchClause(node);
16541                 case 0:
16542                 case 1:
16543                 case 3:
16544                     return isReusableStatement(node);
16545                 case 6:
16546                     return isReusableEnumMember(node);
16547                 case 4:
16548                     return isReusableTypeMember(node);
16549                 case 8:
16550                     return isReusableVariableDeclaration(node);
16551                 case 17:
16552                 case 16:
16553                     return isReusableParameter(node);
16554             }
16555             return false;
16556         }
16557         function isReusableClassMember(node) {
16558             if (node) {
16559                 switch (node.kind) {
16560                     case 162:
16561                     case 167:
16562                     case 163:
16563                     case 164:
16564                     case 159:
16565                     case 222:
16566                         return true;
16567                     case 161:
16568                         var methodDeclaration = node;
16569                         var nameIsConstructor = methodDeclaration.name.kind === 75 &&
16570                             methodDeclaration.name.originalKeywordKind === 129;
16571                         return !nameIsConstructor;
16572                 }
16573             }
16574             return false;
16575         }
16576         function isReusableSwitchClause(node) {
16577             if (node) {
16578                 switch (node.kind) {
16579                     case 277:
16580                     case 278:
16581                         return true;
16582                 }
16583             }
16584             return false;
16585         }
16586         function isReusableStatement(node) {
16587             if (node) {
16588                 switch (node.kind) {
16589                     case 244:
16590                     case 225:
16591                     case 223:
16592                     case 227:
16593                     case 226:
16594                     case 239:
16595                     case 235:
16596                     case 237:
16597                     case 234:
16598                     case 233:
16599                     case 231:
16600                     case 232:
16601                     case 230:
16602                     case 229:
16603                     case 236:
16604                     case 224:
16605                     case 240:
16606                     case 238:
16607                     case 228:
16608                     case 241:
16609                     case 254:
16610                     case 253:
16611                     case 260:
16612                     case 259:
16613                     case 249:
16614                     case 245:
16615                     case 246:
16616                     case 248:
16617                     case 247:
16618                         return true;
16619                 }
16620             }
16621             return false;
16622         }
16623         function isReusableEnumMember(node) {
16624             return node.kind === 284;
16625         }
16626         function isReusableTypeMember(node) {
16627             if (node) {
16628                 switch (node.kind) {
16629                     case 166:
16630                     case 160:
16631                     case 167:
16632                     case 158:
16633                     case 165:
16634                         return true;
16635                 }
16636             }
16637             return false;
16638         }
16639         function isReusableVariableDeclaration(node) {
16640             if (node.kind !== 242) {
16641                 return false;
16642             }
16643             var variableDeclarator = node;
16644             return variableDeclarator.initializer === undefined;
16645         }
16646         function isReusableParameter(node) {
16647             if (node.kind !== 156) {
16648                 return false;
16649             }
16650             var parameter = node;
16651             return parameter.initializer === undefined;
16652         }
16653         function abortParsingListOrMoveToNextToken(kind) {
16654             parseErrorAtCurrentToken(parsingContextErrors(kind));
16655             if (isInSomeParsingContext()) {
16656                 return true;
16657             }
16658             nextToken();
16659             return false;
16660         }
16661         function parsingContextErrors(context) {
16662             switch (context) {
16663                 case 0: return ts.Diagnostics.Declaration_or_statement_expected;
16664                 case 1: return ts.Diagnostics.Declaration_or_statement_expected;
16665                 case 2: return ts.Diagnostics.case_or_default_expected;
16666                 case 3: return ts.Diagnostics.Statement_expected;
16667                 case 18:
16668                 case 4: return ts.Diagnostics.Property_or_signature_expected;
16669                 case 5: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected;
16670                 case 6: return ts.Diagnostics.Enum_member_expected;
16671                 case 7: return ts.Diagnostics.Expression_expected;
16672                 case 8: return ts.Diagnostics.Variable_declaration_expected;
16673                 case 9: return ts.Diagnostics.Property_destructuring_pattern_expected;
16674                 case 10: return ts.Diagnostics.Array_element_destructuring_pattern_expected;
16675                 case 11: return ts.Diagnostics.Argument_expression_expected;
16676                 case 12: return ts.Diagnostics.Property_assignment_expected;
16677                 case 15: return ts.Diagnostics.Expression_or_comma_expected;
16678                 case 17: return ts.Diagnostics.Parameter_declaration_expected;
16679                 case 16: return ts.Diagnostics.Parameter_declaration_expected;
16680                 case 19: return ts.Diagnostics.Type_parameter_declaration_expected;
16681                 case 20: return ts.Diagnostics.Type_argument_expected;
16682                 case 21: return ts.Diagnostics.Type_expected;
16683                 case 22: return ts.Diagnostics.Unexpected_token_expected;
16684                 case 23: return ts.Diagnostics.Identifier_expected;
16685                 case 13: return ts.Diagnostics.Identifier_expected;
16686                 case 14: return ts.Diagnostics.Identifier_expected;
16687                 default: return undefined;
16688             }
16689         }
16690         function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) {
16691             var saveParsingContext = parsingContext;
16692             parsingContext |= 1 << kind;
16693             var list = [];
16694             var listPos = getNodePos();
16695             var commaStart = -1;
16696             while (true) {
16697                 if (isListElement(kind, false)) {
16698                     var startPos = scanner.getStartPos();
16699                     list.push(parseListElement(kind, parseElement));
16700                     commaStart = scanner.getTokenPos();
16701                     if (parseOptional(27)) {
16702                         continue;
16703                     }
16704                     commaStart = -1;
16705                     if (isListTerminator(kind)) {
16706                         break;
16707                     }
16708                     parseExpected(27, getExpectedCommaDiagnostic(kind));
16709                     if (considerSemicolonAsDelimiter && token() === 26 && !scanner.hasPrecedingLineBreak()) {
16710                         nextToken();
16711                     }
16712                     if (startPos === scanner.getStartPos()) {
16713                         nextToken();
16714                     }
16715                     continue;
16716                 }
16717                 if (isListTerminator(kind)) {
16718                     break;
16719                 }
16720                 if (abortParsingListOrMoveToNextToken(kind)) {
16721                     break;
16722                 }
16723             }
16724             parsingContext = saveParsingContext;
16725             var result = createNodeArray(list, listPos);
16726             if (commaStart >= 0) {
16727                 result.hasTrailingComma = true;
16728             }
16729             return result;
16730         }
16731         function getExpectedCommaDiagnostic(kind) {
16732             return kind === 6 ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined;
16733         }
16734         function createMissingList() {
16735             var list = createNodeArray([], getNodePos());
16736             list.isMissingList = true;
16737             return list;
16738         }
16739         function isMissingList(arr) {
16740             return !!arr.isMissingList;
16741         }
16742         function parseBracketedList(kind, parseElement, open, close) {
16743             if (parseExpected(open)) {
16744                 var result = parseDelimitedList(kind, parseElement);
16745                 parseExpected(close);
16746                 return result;
16747             }
16748             return createMissingList();
16749         }
16750         function parseEntityName(allowReservedWords, diagnosticMessage) {
16751             var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage);
16752             var dotPos = scanner.getStartPos();
16753             while (parseOptional(24)) {
16754                 if (token() === 29) {
16755                     entity.jsdocDotPos = dotPos;
16756                     break;
16757                 }
16758                 dotPos = scanner.getStartPos();
16759                 entity = createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, false));
16760             }
16761             return entity;
16762         }
16763         function createQualifiedName(entity, name) {
16764             var node = createNode(153, entity.pos);
16765             node.left = entity;
16766             node.right = name;
16767             return finishNode(node);
16768         }
16769         function parseRightSideOfDot(allowIdentifierNames, allowPrivateIdentifiers) {
16770             if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token())) {
16771                 var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
16772                 if (matchesPattern) {
16773                     return createMissingNode(75, true, ts.Diagnostics.Identifier_expected);
16774                 }
16775             }
16776             if (token() === 76) {
16777                 var node = parsePrivateIdentifier();
16778                 return allowPrivateIdentifiers ? node : createMissingNode(75, true, ts.Diagnostics.Identifier_expected);
16779             }
16780             return allowIdentifierNames ? parseIdentifierName() : parseIdentifier();
16781         }
16782         function parseTemplateExpression(isTaggedTemplate) {
16783             var template = createNode(211);
16784             template.head = parseTemplateHead(isTaggedTemplate);
16785             ts.Debug.assert(template.head.kind === 15, "Template head has wrong token kind");
16786             var list = [];
16787             var listPos = getNodePos();
16788             do {
16789                 list.push(parseTemplateSpan(isTaggedTemplate));
16790             } while (ts.last(list).literal.kind === 16);
16791             template.templateSpans = createNodeArray(list, listPos);
16792             return finishNode(template);
16793         }
16794         function parseTemplateSpan(isTaggedTemplate) {
16795             var span = createNode(221);
16796             span.expression = allowInAnd(parseExpression);
16797             var literal;
16798             if (token() === 19) {
16799                 reScanTemplateToken(isTaggedTemplate);
16800                 literal = parseTemplateMiddleOrTemplateTail();
16801             }
16802             else {
16803                 literal = parseExpectedToken(17, ts.Diagnostics._0_expected, ts.tokenToString(19));
16804             }
16805             span.literal = literal;
16806             return finishNode(span);
16807         }
16808         function parseLiteralNode() {
16809             return parseLiteralLikeNode(token());
16810         }
16811         function parseTemplateHead(isTaggedTemplate) {
16812             if (isTaggedTemplate) {
16813                 reScanTemplateHeadOrNoSubstitutionTemplate();
16814             }
16815             var fragment = parseLiteralLikeNode(token());
16816             ts.Debug.assert(fragment.kind === 15, "Template head has wrong token kind");
16817             return fragment;
16818         }
16819         function parseTemplateMiddleOrTemplateTail() {
16820             var fragment = parseLiteralLikeNode(token());
16821             ts.Debug.assert(fragment.kind === 16 || fragment.kind === 17, "Template fragment has wrong token kind");
16822             return fragment;
16823         }
16824         function parseLiteralLikeNode(kind) {
16825             var node = createNode(kind);
16826             node.text = scanner.getTokenValue();
16827             switch (kind) {
16828                 case 14:
16829                 case 15:
16830                 case 16:
16831                 case 17:
16832                     var isLast = kind === 14 || kind === 17;
16833                     var tokenText = scanner.getTokenText();
16834                     node.rawText = tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2));
16835                     break;
16836             }
16837             if (scanner.hasExtendedUnicodeEscape()) {
16838                 node.hasExtendedUnicodeEscape = true;
16839             }
16840             if (scanner.isUnterminated()) {
16841                 node.isUnterminated = true;
16842             }
16843             if (node.kind === 8) {
16844                 node.numericLiteralFlags = scanner.getTokenFlags() & 1008;
16845             }
16846             if (ts.isTemplateLiteralKind(node.kind)) {
16847                 node.templateFlags = scanner.getTokenFlags() & 2048;
16848             }
16849             nextToken();
16850             finishNode(node);
16851             return node;
16852         }
16853         function parseTypeReference() {
16854             var node = createNode(169);
16855             node.typeName = parseEntityName(true, ts.Diagnostics.Type_expected);
16856             if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29) {
16857                 node.typeArguments = parseBracketedList(20, parseType, 29, 31);
16858             }
16859             return finishNode(node);
16860         }
16861         function typeHasArrowFunctionBlockingParseError(node) {
16862             switch (node.kind) {
16863                 case 169:
16864                     return ts.nodeIsMissing(node.typeName);
16865                 case 170:
16866                 case 171: {
16867                     var _a = node, parameters = _a.parameters, type = _a.type;
16868                     return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type);
16869                 }
16870                 case 182:
16871                     return typeHasArrowFunctionBlockingParseError(node.type);
16872                 default:
16873                     return false;
16874             }
16875         }
16876         function parseThisTypePredicate(lhs) {
16877             nextToken();
16878             var node = createNode(168, lhs.pos);
16879             node.parameterName = lhs;
16880             node.type = parseType();
16881             return finishNode(node);
16882         }
16883         function parseThisTypeNode() {
16884             var node = createNode(183);
16885             nextToken();
16886             return finishNode(node);
16887         }
16888         function parseJSDocAllType(postFixEquals) {
16889             var result = createNode(295);
16890             if (postFixEquals) {
16891                 return createPostfixType(299, result);
16892             }
16893             else {
16894                 nextToken();
16895             }
16896             return finishNode(result);
16897         }
16898         function parseJSDocNonNullableType() {
16899             var result = createNode(298);
16900             nextToken();
16901             result.type = parseNonArrayType();
16902             return finishNode(result);
16903         }
16904         function parseJSDocUnknownOrNullableType() {
16905             var pos = scanner.getStartPos();
16906             nextToken();
16907             if (token() === 27 ||
16908                 token() === 19 ||
16909                 token() === 21 ||
16910                 token() === 31 ||
16911                 token() === 62 ||
16912                 token() === 51) {
16913                 var result = createNode(296, pos);
16914                 return finishNode(result);
16915             }
16916             else {
16917                 var result = createNode(297, pos);
16918                 result.type = parseType();
16919                 return finishNode(result);
16920             }
16921         }
16922         function parseJSDocFunctionType() {
16923             if (lookAhead(nextTokenIsOpenParen)) {
16924                 var result = createNodeWithJSDoc(300);
16925                 nextToken();
16926                 fillSignature(58, 4 | 32, result);
16927                 return finishNode(result);
16928             }
16929             var node = createNode(169);
16930             node.typeName = parseIdentifierName();
16931             return finishNode(node);
16932         }
16933         function parseJSDocParameter() {
16934             var parameter = createNode(156);
16935             if (token() === 104 || token() === 99) {
16936                 parameter.name = parseIdentifierName();
16937                 parseExpected(58);
16938             }
16939             parameter.type = parseJSDocType();
16940             return finishNode(parameter);
16941         }
16942         function parseJSDocType() {
16943             scanner.setInJSDocType(true);
16944             var moduleSpecifier = parseOptionalToken(135);
16945             if (moduleSpecifier) {
16946                 var moduleTag = createNode(302, moduleSpecifier.pos);
16947                 terminate: while (true) {
16948                     switch (token()) {
16949                         case 19:
16950                         case 1:
16951                         case 27:
16952                         case 5:
16953                             break terminate;
16954                         default:
16955                             nextTokenJSDoc();
16956                     }
16957                 }
16958                 scanner.setInJSDocType(false);
16959                 return finishNode(moduleTag);
16960             }
16961             var dotdotdot = parseOptionalToken(25);
16962             var type = parseTypeOrTypePredicate();
16963             scanner.setInJSDocType(false);
16964             if (dotdotdot) {
16965                 var variadic = createNode(301, dotdotdot.pos);
16966                 variadic.type = type;
16967                 type = finishNode(variadic);
16968             }
16969             if (token() === 62) {
16970                 return createPostfixType(299, type);
16971             }
16972             return type;
16973         }
16974         function parseTypeQuery() {
16975             var node = createNode(172);
16976             parseExpected(108);
16977             node.exprName = parseEntityName(true);
16978             return finishNode(node);
16979         }
16980         function parseTypeParameter() {
16981             var node = createNode(155);
16982             node.name = parseIdentifier();
16983             if (parseOptional(90)) {
16984                 if (isStartOfType() || !isStartOfExpression()) {
16985                     node.constraint = parseType();
16986                 }
16987                 else {
16988                     node.expression = parseUnaryExpressionOrHigher();
16989                 }
16990             }
16991             if (parseOptional(62)) {
16992                 node.default = parseType();
16993             }
16994             return finishNode(node);
16995         }
16996         function parseTypeParameters() {
16997             if (token() === 29) {
16998                 return parseBracketedList(19, parseTypeParameter, 29, 31);
16999             }
17000         }
17001         function parseParameterType() {
17002             if (parseOptional(58)) {
17003                 return parseType();
17004             }
17005             return undefined;
17006         }
17007         function isStartOfParameter(isJSDocParameter) {
17008             return token() === 25 ||
17009                 isIdentifierOrPrivateIdentifierOrPattern() ||
17010                 ts.isModifierKind(token()) ||
17011                 token() === 59 ||
17012                 isStartOfType(!isJSDocParameter);
17013         }
17014         function parseParameter() {
17015             var node = createNodeWithJSDoc(156);
17016             if (token() === 104) {
17017                 node.name = createIdentifier(true);
17018                 node.type = parseParameterType();
17019                 return finishNode(node);
17020             }
17021             node.decorators = parseDecorators();
17022             node.modifiers = parseModifiers();
17023             node.dotDotDotToken = parseOptionalToken(25);
17024             node.name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_cannot_be_used_as_parameters);
17025             if (ts.getFullWidth(node.name) === 0 && !node.modifiers && ts.isModifierKind(token())) {
17026                 nextToken();
17027             }
17028             node.questionToken = parseOptionalToken(57);
17029             node.type = parseParameterType();
17030             node.initializer = parseInitializer();
17031             return finishNode(node);
17032         }
17033         function fillSignature(returnToken, flags, signature) {
17034             if (!(flags & 32)) {
17035                 signature.typeParameters = parseTypeParameters();
17036             }
17037             var parametersParsedSuccessfully = parseParameterList(signature, flags);
17038             if (shouldParseReturnType(returnToken, !!(flags & 4))) {
17039                 signature.type = parseTypeOrTypePredicate();
17040                 if (typeHasArrowFunctionBlockingParseError(signature.type))
17041                     return false;
17042             }
17043             return parametersParsedSuccessfully;
17044         }
17045         function shouldParseReturnType(returnToken, isType) {
17046             if (returnToken === 38) {
17047                 parseExpected(returnToken);
17048                 return true;
17049             }
17050             else if (parseOptional(58)) {
17051                 return true;
17052             }
17053             else if (isType && token() === 38) {
17054                 parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58));
17055                 nextToken();
17056                 return true;
17057             }
17058             return false;
17059         }
17060         function parseParameterList(signature, flags) {
17061             if (!parseExpected(20)) {
17062                 signature.parameters = createMissingList();
17063                 return false;
17064             }
17065             var savedYieldContext = inYieldContext();
17066             var savedAwaitContext = inAwaitContext();
17067             setYieldContext(!!(flags & 1));
17068             setAwaitContext(!!(flags & 2));
17069             signature.parameters = flags & 32 ?
17070                 parseDelimitedList(17, parseJSDocParameter) :
17071                 parseDelimitedList(16, parseParameter);
17072             setYieldContext(savedYieldContext);
17073             setAwaitContext(savedAwaitContext);
17074             return parseExpected(21);
17075         }
17076         function parseTypeMemberSemicolon() {
17077             if (parseOptional(27)) {
17078                 return;
17079             }
17080             parseSemicolon();
17081         }
17082         function parseSignatureMember(kind) {
17083             var node = createNodeWithJSDoc(kind);
17084             if (kind === 166) {
17085                 parseExpected(99);
17086             }
17087             fillSignature(58, 4, node);
17088             parseTypeMemberSemicolon();
17089             return finishNode(node);
17090         }
17091         function isIndexSignature() {
17092             return token() === 22 && lookAhead(isUnambiguouslyIndexSignature);
17093         }
17094         function isUnambiguouslyIndexSignature() {
17095             nextToken();
17096             if (token() === 25 || token() === 23) {
17097                 return true;
17098             }
17099             if (ts.isModifierKind(token())) {
17100                 nextToken();
17101                 if (isIdentifier()) {
17102                     return true;
17103                 }
17104             }
17105             else if (!isIdentifier()) {
17106                 return false;
17107             }
17108             else {
17109                 nextToken();
17110             }
17111             if (token() === 58 || token() === 27) {
17112                 return true;
17113             }
17114             if (token() !== 57) {
17115                 return false;
17116             }
17117             nextToken();
17118             return token() === 58 || token() === 27 || token() === 23;
17119         }
17120         function parseIndexSignatureDeclaration(node) {
17121             node.kind = 167;
17122             node.parameters = parseBracketedList(16, parseParameter, 22, 23);
17123             node.type = parseTypeAnnotation();
17124             parseTypeMemberSemicolon();
17125             return finishNode(node);
17126         }
17127         function parsePropertyOrMethodSignature(node) {
17128             node.name = parsePropertyName();
17129             node.questionToken = parseOptionalToken(57);
17130             if (token() === 20 || token() === 29) {
17131                 node.kind = 160;
17132                 fillSignature(58, 4, node);
17133             }
17134             else {
17135                 node.kind = 158;
17136                 node.type = parseTypeAnnotation();
17137                 if (token() === 62) {
17138                     node.initializer = parseInitializer();
17139                 }
17140             }
17141             parseTypeMemberSemicolon();
17142             return finishNode(node);
17143         }
17144         function isTypeMemberStart() {
17145             if (token() === 20 || token() === 29) {
17146                 return true;
17147             }
17148             var idToken = false;
17149             while (ts.isModifierKind(token())) {
17150                 idToken = true;
17151                 nextToken();
17152             }
17153             if (token() === 22) {
17154                 return true;
17155             }
17156             if (isLiteralPropertyName()) {
17157                 idToken = true;
17158                 nextToken();
17159             }
17160             if (idToken) {
17161                 return token() === 20 ||
17162                     token() === 29 ||
17163                     token() === 57 ||
17164                     token() === 58 ||
17165                     token() === 27 ||
17166                     canParseSemicolon();
17167             }
17168             return false;
17169         }
17170         function parseTypeMember() {
17171             if (token() === 20 || token() === 29) {
17172                 return parseSignatureMember(165);
17173             }
17174             if (token() === 99 && lookAhead(nextTokenIsOpenParenOrLessThan)) {
17175                 return parseSignatureMember(166);
17176             }
17177             var node = createNodeWithJSDoc(0);
17178             node.modifiers = parseModifiers();
17179             if (isIndexSignature()) {
17180                 return parseIndexSignatureDeclaration(node);
17181             }
17182             return parsePropertyOrMethodSignature(node);
17183         }
17184         function nextTokenIsOpenParenOrLessThan() {
17185             nextToken();
17186             return token() === 20 || token() === 29;
17187         }
17188         function nextTokenIsDot() {
17189             return nextToken() === 24;
17190         }
17191         function nextTokenIsOpenParenOrLessThanOrDot() {
17192             switch (nextToken()) {
17193                 case 20:
17194                 case 29:
17195                 case 24:
17196                     return true;
17197             }
17198             return false;
17199         }
17200         function parseTypeLiteral() {
17201             var node = createNode(173);
17202             node.members = parseObjectTypeMembers();
17203             return finishNode(node);
17204         }
17205         function parseObjectTypeMembers() {
17206             var members;
17207             if (parseExpected(18)) {
17208                 members = parseList(4, parseTypeMember);
17209                 parseExpected(19);
17210             }
17211             else {
17212                 members = createMissingList();
17213             }
17214             return members;
17215         }
17216         function isStartOfMappedType() {
17217             nextToken();
17218             if (token() === 39 || token() === 40) {
17219                 return nextToken() === 138;
17220             }
17221             if (token() === 138) {
17222                 nextToken();
17223             }
17224             return token() === 22 && nextTokenIsIdentifier() && nextToken() === 97;
17225         }
17226         function parseMappedTypeParameter() {
17227             var node = createNode(155);
17228             node.name = parseIdentifier();
17229             parseExpected(97);
17230             node.constraint = parseType();
17231             return finishNode(node);
17232         }
17233         function parseMappedType() {
17234             var node = createNode(186);
17235             parseExpected(18);
17236             if (token() === 138 || token() === 39 || token() === 40) {
17237                 node.readonlyToken = parseTokenNode();
17238                 if (node.readonlyToken.kind !== 138) {
17239                     parseExpectedToken(138);
17240                 }
17241             }
17242             parseExpected(22);
17243             node.typeParameter = parseMappedTypeParameter();
17244             parseExpected(23);
17245             if (token() === 57 || token() === 39 || token() === 40) {
17246                 node.questionToken = parseTokenNode();
17247                 if (node.questionToken.kind !== 57) {
17248                     parseExpectedToken(57);
17249                 }
17250             }
17251             node.type = parseTypeAnnotation();
17252             parseSemicolon();
17253             parseExpected(19);
17254             return finishNode(node);
17255         }
17256         function parseTupleElementType() {
17257             var pos = getNodePos();
17258             if (parseOptional(25)) {
17259                 var node = createNode(177, pos);
17260                 node.type = parseType();
17261                 return finishNode(node);
17262             }
17263             var type = parseType();
17264             if (!(contextFlags & 4194304) && type.kind === 297 && type.pos === type.type.pos) {
17265                 type.kind = 176;
17266             }
17267             return type;
17268         }
17269         function parseTupleType() {
17270             var node = createNode(175);
17271             node.elementTypes = parseBracketedList(21, parseTupleElementType, 22, 23);
17272             return finishNode(node);
17273         }
17274         function parseParenthesizedType() {
17275             var node = createNode(182);
17276             parseExpected(20);
17277             node.type = parseType();
17278             parseExpected(21);
17279             return finishNode(node);
17280         }
17281         function parseFunctionOrConstructorType() {
17282             var pos = getNodePos();
17283             var kind = parseOptional(99) ? 171 : 170;
17284             var node = createNodeWithJSDoc(kind, pos);
17285             fillSignature(38, 4, node);
17286             return finishNode(node);
17287         }
17288         function parseKeywordAndNoDot() {
17289             var node = parseTokenNode();
17290             return token() === 24 ? undefined : node;
17291         }
17292         function parseLiteralTypeNode(negative) {
17293             var node = createNode(187);
17294             var unaryMinusExpression;
17295             if (negative) {
17296                 unaryMinusExpression = createNode(207);
17297                 unaryMinusExpression.operator = 40;
17298                 nextToken();
17299             }
17300             var expression = token() === 106 || token() === 91
17301                 ? parseTokenNode()
17302                 : parseLiteralLikeNode(token());
17303             if (negative) {
17304                 unaryMinusExpression.operand = expression;
17305                 finishNode(unaryMinusExpression);
17306                 expression = unaryMinusExpression;
17307             }
17308             node.literal = expression;
17309             return finishNode(node);
17310         }
17311         function isStartOfTypeOfImportType() {
17312             nextToken();
17313             return token() === 96;
17314         }
17315         function parseImportType() {
17316             sourceFile.flags |= 1048576;
17317             var node = createNode(188);
17318             if (parseOptional(108)) {
17319                 node.isTypeOf = true;
17320             }
17321             parseExpected(96);
17322             parseExpected(20);
17323             node.argument = parseType();
17324             parseExpected(21);
17325             if (parseOptional(24)) {
17326                 node.qualifier = parseEntityName(true, ts.Diagnostics.Type_expected);
17327             }
17328             if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29) {
17329                 node.typeArguments = parseBracketedList(20, parseType, 29, 31);
17330             }
17331             return finishNode(node);
17332         }
17333         function nextTokenIsNumericOrBigIntLiteral() {
17334             nextToken();
17335             return token() === 8 || token() === 9;
17336         }
17337         function parseNonArrayType() {
17338             switch (token()) {
17339                 case 125:
17340                 case 148:
17341                 case 143:
17342                 case 140:
17343                 case 151:
17344                 case 144:
17345                 case 128:
17346                 case 146:
17347                 case 137:
17348                 case 141:
17349                     return tryParse(parseKeywordAndNoDot) || parseTypeReference();
17350                 case 41:
17351                     return parseJSDocAllType(false);
17352                 case 65:
17353                     return parseJSDocAllType(true);
17354                 case 60:
17355                     scanner.reScanQuestionToken();
17356                 case 57:
17357                     return parseJSDocUnknownOrNullableType();
17358                 case 94:
17359                     return parseJSDocFunctionType();
17360                 case 53:
17361                     return parseJSDocNonNullableType();
17362                 case 14:
17363                 case 10:
17364                 case 8:
17365                 case 9:
17366                 case 106:
17367                 case 91:
17368                     return parseLiteralTypeNode();
17369                 case 40:
17370                     return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(true) : parseTypeReference();
17371                 case 110:
17372                 case 100:
17373                     return parseTokenNode();
17374                 case 104: {
17375                     var thisKeyword = parseThisTypeNode();
17376                     if (token() === 133 && !scanner.hasPrecedingLineBreak()) {
17377                         return parseThisTypePredicate(thisKeyword);
17378                     }
17379                     else {
17380                         return thisKeyword;
17381                     }
17382                 }
17383                 case 108:
17384                     return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery();
17385                 case 18:
17386                     return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral();
17387                 case 22:
17388                     return parseTupleType();
17389                 case 20:
17390                     return parseParenthesizedType();
17391                 case 96:
17392                     return parseImportType();
17393                 case 124:
17394                     return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference();
17395                 default:
17396                     return parseTypeReference();
17397             }
17398         }
17399         function isStartOfType(inStartOfParameter) {
17400             switch (token()) {
17401                 case 125:
17402                 case 148:
17403                 case 143:
17404                 case 140:
17405                 case 151:
17406                 case 128:
17407                 case 138:
17408                 case 144:
17409                 case 147:
17410                 case 110:
17411                 case 146:
17412                 case 100:
17413                 case 104:
17414                 case 108:
17415                 case 137:
17416                 case 18:
17417                 case 22:
17418                 case 29:
17419                 case 51:
17420                 case 50:
17421                 case 99:
17422                 case 10:
17423                 case 8:
17424                 case 9:
17425                 case 106:
17426                 case 91:
17427                 case 141:
17428                 case 41:
17429                 case 57:
17430                 case 53:
17431                 case 25:
17432                 case 132:
17433                 case 96:
17434                 case 124:
17435                     return true;
17436                 case 94:
17437                     return !inStartOfParameter;
17438                 case 40:
17439                     return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral);
17440                 case 20:
17441                     return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType);
17442                 default:
17443                     return isIdentifier();
17444             }
17445         }
17446         function isStartOfParenthesizedOrFunctionType() {
17447             nextToken();
17448             return token() === 21 || isStartOfParameter(false) || isStartOfType();
17449         }
17450         function parsePostfixTypeOrHigher() {
17451             var type = parseNonArrayType();
17452             while (!scanner.hasPrecedingLineBreak()) {
17453                 switch (token()) {
17454                     case 53:
17455                         type = createPostfixType(298, type);
17456                         break;
17457                     case 57:
17458                         if (!(contextFlags & 4194304) && lookAhead(nextTokenIsStartOfType)) {
17459                             return type;
17460                         }
17461                         type = createPostfixType(297, type);
17462                         break;
17463                     case 22:
17464                         parseExpected(22);
17465                         if (isStartOfType()) {
17466                             var node = createNode(185, type.pos);
17467                             node.objectType = type;
17468                             node.indexType = parseType();
17469                             parseExpected(23);
17470                             type = finishNode(node);
17471                         }
17472                         else {
17473                             var node = createNode(174, type.pos);
17474                             node.elementType = type;
17475                             parseExpected(23);
17476                             type = finishNode(node);
17477                         }
17478                         break;
17479                     default:
17480                         return type;
17481                 }
17482             }
17483             return type;
17484         }
17485         function createPostfixType(kind, type) {
17486             nextToken();
17487             var postfix = createNode(kind, type.pos);
17488             postfix.type = type;
17489             return finishNode(postfix);
17490         }
17491         function parseTypeOperator(operator) {
17492             var node = createNode(184);
17493             parseExpected(operator);
17494             node.operator = operator;
17495             node.type = parseTypeOperatorOrHigher();
17496             return finishNode(node);
17497         }
17498         function parseInferType() {
17499             var node = createNode(181);
17500             parseExpected(132);
17501             var typeParameter = createNode(155);
17502             typeParameter.name = parseIdentifier();
17503             node.typeParameter = finishNode(typeParameter);
17504             return finishNode(node);
17505         }
17506         function parseTypeOperatorOrHigher() {
17507             var operator = token();
17508             switch (operator) {
17509                 case 134:
17510                 case 147:
17511                 case 138:
17512                     return parseTypeOperator(operator);
17513                 case 132:
17514                     return parseInferType();
17515             }
17516             return parsePostfixTypeOrHigher();
17517         }
17518         function parseUnionOrIntersectionType(kind, parseConstituentType, operator) {
17519             var start = scanner.getStartPos();
17520             var hasLeadingOperator = parseOptional(operator);
17521             var type = parseConstituentType();
17522             if (token() === operator || hasLeadingOperator) {
17523                 var types = [type];
17524                 while (parseOptional(operator)) {
17525                     types.push(parseConstituentType());
17526                 }
17527                 var node = createNode(kind, start);
17528                 node.types = createNodeArray(types, start);
17529                 type = finishNode(node);
17530             }
17531             return type;
17532         }
17533         function parseIntersectionTypeOrHigher() {
17534             return parseUnionOrIntersectionType(179, parseTypeOperatorOrHigher, 50);
17535         }
17536         function parseUnionTypeOrHigher() {
17537             return parseUnionOrIntersectionType(178, parseIntersectionTypeOrHigher, 51);
17538         }
17539         function isStartOfFunctionType() {
17540             if (token() === 29) {
17541                 return true;
17542             }
17543             return token() === 20 && lookAhead(isUnambiguouslyStartOfFunctionType);
17544         }
17545         function skipParameterStart() {
17546             if (ts.isModifierKind(token())) {
17547                 parseModifiers();
17548             }
17549             if (isIdentifier() || token() === 104) {
17550                 nextToken();
17551                 return true;
17552             }
17553             if (token() === 22 || token() === 18) {
17554                 var previousErrorCount = parseDiagnostics.length;
17555                 parseIdentifierOrPattern();
17556                 return previousErrorCount === parseDiagnostics.length;
17557             }
17558             return false;
17559         }
17560         function isUnambiguouslyStartOfFunctionType() {
17561             nextToken();
17562             if (token() === 21 || token() === 25) {
17563                 return true;
17564             }
17565             if (skipParameterStart()) {
17566                 if (token() === 58 || token() === 27 ||
17567                     token() === 57 || token() === 62) {
17568                     return true;
17569                 }
17570                 if (token() === 21) {
17571                     nextToken();
17572                     if (token() === 38) {
17573                         return true;
17574                     }
17575                 }
17576             }
17577             return false;
17578         }
17579         function parseTypeOrTypePredicate() {
17580             var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix);
17581             var type = parseType();
17582             if (typePredicateVariable) {
17583                 var node = createNode(168, typePredicateVariable.pos);
17584                 node.assertsModifier = undefined;
17585                 node.parameterName = typePredicateVariable;
17586                 node.type = type;
17587                 return finishNode(node);
17588             }
17589             else {
17590                 return type;
17591             }
17592         }
17593         function parseTypePredicatePrefix() {
17594             var id = parseIdentifier();
17595             if (token() === 133 && !scanner.hasPrecedingLineBreak()) {
17596                 nextToken();
17597                 return id;
17598             }
17599         }
17600         function parseAssertsTypePredicate() {
17601             var node = createNode(168);
17602             node.assertsModifier = parseExpectedToken(124);
17603             node.parameterName = token() === 104 ? parseThisTypeNode() : parseIdentifier();
17604             node.type = parseOptional(133) ? parseType() : undefined;
17605             return finishNode(node);
17606         }
17607         function parseType() {
17608             return doOutsideOfContext(40960, parseTypeWorker);
17609         }
17610         function parseTypeWorker(noConditionalTypes) {
17611             if (isStartOfFunctionType() || token() === 99) {
17612                 return parseFunctionOrConstructorType();
17613             }
17614             var type = parseUnionTypeOrHigher();
17615             if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(90)) {
17616                 var node = createNode(180, type.pos);
17617                 node.checkType = type;
17618                 node.extendsType = parseTypeWorker(true);
17619                 parseExpected(57);
17620                 node.trueType = parseTypeWorker();
17621                 parseExpected(58);
17622                 node.falseType = parseTypeWorker();
17623                 return finishNode(node);
17624             }
17625             return type;
17626         }
17627         function parseTypeAnnotation() {
17628             return parseOptional(58) ? parseType() : undefined;
17629         }
17630         function isStartOfLeftHandSideExpression() {
17631             switch (token()) {
17632                 case 104:
17633                 case 102:
17634                 case 100:
17635                 case 106:
17636                 case 91:
17637                 case 8:
17638                 case 9:
17639                 case 10:
17640                 case 14:
17641                 case 15:
17642                 case 20:
17643                 case 22:
17644                 case 18:
17645                 case 94:
17646                 case 80:
17647                 case 99:
17648                 case 43:
17649                 case 67:
17650                 case 75:
17651                     return true;
17652                 case 96:
17653                     return lookAhead(nextTokenIsOpenParenOrLessThanOrDot);
17654                 default:
17655                     return isIdentifier();
17656             }
17657         }
17658         function isStartOfExpression() {
17659             if (isStartOfLeftHandSideExpression()) {
17660                 return true;
17661             }
17662             switch (token()) {
17663                 case 39:
17664                 case 40:
17665                 case 54:
17666                 case 53:
17667                 case 85:
17668                 case 108:
17669                 case 110:
17670                 case 45:
17671                 case 46:
17672                 case 29:
17673                 case 127:
17674                 case 121:
17675                 case 76:
17676                     return true;
17677                 default:
17678                     if (isBinaryOperator()) {
17679                         return true;
17680                     }
17681                     return isIdentifier();
17682             }
17683         }
17684         function isStartOfExpressionStatement() {
17685             return token() !== 18 &&
17686                 token() !== 94 &&
17687                 token() !== 80 &&
17688                 token() !== 59 &&
17689                 isStartOfExpression();
17690         }
17691         function parseExpression() {
17692             var saveDecoratorContext = inDecoratorContext();
17693             if (saveDecoratorContext) {
17694                 setDecoratorContext(false);
17695             }
17696             var expr = parseAssignmentExpressionOrHigher();
17697             var operatorToken;
17698             while ((operatorToken = parseOptionalToken(27))) {
17699                 expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher());
17700             }
17701             if (saveDecoratorContext) {
17702                 setDecoratorContext(true);
17703             }
17704             return expr;
17705         }
17706         function parseInitializer() {
17707             return parseOptional(62) ? parseAssignmentExpressionOrHigher() : undefined;
17708         }
17709         function parseAssignmentExpressionOrHigher() {
17710             if (isYieldExpression()) {
17711                 return parseYieldExpression();
17712             }
17713             var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
17714             if (arrowExpression) {
17715                 return arrowExpression;
17716             }
17717             var expr = parseBinaryExpressionOrHigher(0);
17718             if (expr.kind === 75 && token() === 38) {
17719                 return parseSimpleArrowFunctionExpression(expr);
17720             }
17721             if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) {
17722                 return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher());
17723             }
17724             return parseConditionalExpressionRest(expr);
17725         }
17726         function isYieldExpression() {
17727             if (token() === 121) {
17728                 if (inYieldContext()) {
17729                     return true;
17730                 }
17731                 return lookAhead(nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine);
17732             }
17733             return false;
17734         }
17735         function nextTokenIsIdentifierOnSameLine() {
17736             nextToken();
17737             return !scanner.hasPrecedingLineBreak() && isIdentifier();
17738         }
17739         function parseYieldExpression() {
17740             var node = createNode(212);
17741             nextToken();
17742             if (!scanner.hasPrecedingLineBreak() &&
17743                 (token() === 41 || isStartOfExpression())) {
17744                 node.asteriskToken = parseOptionalToken(41);
17745                 node.expression = parseAssignmentExpressionOrHigher();
17746                 return finishNode(node);
17747             }
17748             else {
17749                 return finishNode(node);
17750             }
17751         }
17752         function parseSimpleArrowFunctionExpression(identifier, asyncModifier) {
17753             ts.Debug.assert(token() === 38, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
17754             var node;
17755             if (asyncModifier) {
17756                 node = createNode(202, asyncModifier.pos);
17757                 node.modifiers = asyncModifier;
17758             }
17759             else {
17760                 node = createNode(202, identifier.pos);
17761             }
17762             var parameter = createNode(156, identifier.pos);
17763             parameter.name = identifier;
17764             finishNode(parameter);
17765             node.parameters = createNodeArray([parameter], parameter.pos, parameter.end);
17766             node.equalsGreaterThanToken = parseExpectedToken(38);
17767             node.body = parseArrowFunctionExpressionBody(!!asyncModifier);
17768             return addJSDocComment(finishNode(node));
17769         }
17770         function tryParseParenthesizedArrowFunctionExpression() {
17771             var triState = isParenthesizedArrowFunctionExpression();
17772             if (triState === 0) {
17773                 return undefined;
17774             }
17775             var arrowFunction = triState === 1
17776                 ? parseParenthesizedArrowFunctionExpressionHead(true)
17777                 : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead);
17778             if (!arrowFunction) {
17779                 return undefined;
17780             }
17781             var isAsync = hasModifierOfKind(arrowFunction, 126);
17782             var lastToken = token();
17783             arrowFunction.equalsGreaterThanToken = parseExpectedToken(38);
17784             arrowFunction.body = (lastToken === 38 || lastToken === 18)
17785                 ? parseArrowFunctionExpressionBody(isAsync)
17786                 : parseIdentifier();
17787             return finishNode(arrowFunction);
17788         }
17789         function isParenthesizedArrowFunctionExpression() {
17790             if (token() === 20 || token() === 29 || token() === 126) {
17791                 return lookAhead(isParenthesizedArrowFunctionExpressionWorker);
17792             }
17793             if (token() === 38) {
17794                 return 1;
17795             }
17796             return 0;
17797         }
17798         function isParenthesizedArrowFunctionExpressionWorker() {
17799             if (token() === 126) {
17800                 nextToken();
17801                 if (scanner.hasPrecedingLineBreak()) {
17802                     return 0;
17803                 }
17804                 if (token() !== 20 && token() !== 29) {
17805                     return 0;
17806                 }
17807             }
17808             var first = token();
17809             var second = nextToken();
17810             if (first === 20) {
17811                 if (second === 21) {
17812                     var third = nextToken();
17813                     switch (third) {
17814                         case 38:
17815                         case 58:
17816                         case 18:
17817                             return 1;
17818                         default:
17819                             return 0;
17820                     }
17821                 }
17822                 if (second === 22 || second === 18) {
17823                     return 2;
17824                 }
17825                 if (second === 25) {
17826                     return 1;
17827                 }
17828                 if (ts.isModifierKind(second) && second !== 126 && lookAhead(nextTokenIsIdentifier)) {
17829                     return 1;
17830                 }
17831                 if (!isIdentifier() && second !== 104) {
17832                     return 0;
17833                 }
17834                 switch (nextToken()) {
17835                     case 58:
17836                         return 1;
17837                     case 57:
17838                         nextToken();
17839                         if (token() === 58 || token() === 27 || token() === 62 || token() === 21) {
17840                             return 1;
17841                         }
17842                         return 0;
17843                     case 27:
17844                     case 62:
17845                     case 21:
17846                         return 2;
17847                 }
17848                 return 0;
17849             }
17850             else {
17851                 ts.Debug.assert(first === 29);
17852                 if (!isIdentifier()) {
17853                     return 0;
17854                 }
17855                 if (sourceFile.languageVariant === 1) {
17856                     var isArrowFunctionInJsx = lookAhead(function () {
17857                         var third = nextToken();
17858                         if (third === 90) {
17859                             var fourth = nextToken();
17860                             switch (fourth) {
17861                                 case 62:
17862                                 case 31:
17863                                     return false;
17864                                 default:
17865                                     return true;
17866                             }
17867                         }
17868                         else if (third === 27) {
17869                             return true;
17870                         }
17871                         return false;
17872                     });
17873                     if (isArrowFunctionInJsx) {
17874                         return 1;
17875                     }
17876                     return 0;
17877                 }
17878                 return 2;
17879             }
17880         }
17881         function parsePossibleParenthesizedArrowFunctionExpressionHead() {
17882             var tokenPos = scanner.getTokenPos();
17883             if (notParenthesizedArrow && notParenthesizedArrow.has(tokenPos.toString())) {
17884                 return undefined;
17885             }
17886             var result = parseParenthesizedArrowFunctionExpressionHead(false);
17887             if (!result) {
17888                 (notParenthesizedArrow || (notParenthesizedArrow = ts.createMap())).set(tokenPos.toString(), true);
17889             }
17890             return result;
17891         }
17892         function tryParseAsyncSimpleArrowFunctionExpression() {
17893             if (token() === 126) {
17894                 if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1) {
17895                     var asyncModifier = parseModifiersForArrowFunction();
17896                     var expr = parseBinaryExpressionOrHigher(0);
17897                     return parseSimpleArrowFunctionExpression(expr, asyncModifier);
17898                 }
17899             }
17900             return undefined;
17901         }
17902         function isUnParenthesizedAsyncArrowFunctionWorker() {
17903             if (token() === 126) {
17904                 nextToken();
17905                 if (scanner.hasPrecedingLineBreak() || token() === 38) {
17906                     return 0;
17907                 }
17908                 var expr = parseBinaryExpressionOrHigher(0);
17909                 if (!scanner.hasPrecedingLineBreak() && expr.kind === 75 && token() === 38) {
17910                     return 1;
17911                 }
17912             }
17913             return 0;
17914         }
17915         function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) {
17916             var node = createNodeWithJSDoc(202);
17917             node.modifiers = parseModifiersForArrowFunction();
17918             var isAsync = hasModifierOfKind(node, 126) ? 2 : 0;
17919             if (!fillSignature(58, isAsync, node) && !allowAmbiguity) {
17920                 return undefined;
17921             }
17922             var hasJSDocFunctionType = node.type && ts.isJSDocFunctionType(node.type);
17923             if (!allowAmbiguity && token() !== 38 && (hasJSDocFunctionType || token() !== 18)) {
17924                 return undefined;
17925             }
17926             return node;
17927         }
17928         function parseArrowFunctionExpressionBody(isAsync) {
17929             if (token() === 18) {
17930                 return parseFunctionBlock(isAsync ? 2 : 0);
17931             }
17932             if (token() !== 26 &&
17933                 token() !== 94 &&
17934                 token() !== 80 &&
17935                 isStartOfStatement() &&
17936                 !isStartOfExpressionStatement()) {
17937                 return parseFunctionBlock(16 | (isAsync ? 2 : 0));
17938             }
17939             return isAsync
17940                 ? doInAwaitContext(parseAssignmentExpressionOrHigher)
17941                 : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
17942         }
17943         function parseConditionalExpressionRest(leftOperand) {
17944             var questionToken = parseOptionalToken(57);
17945             if (!questionToken) {
17946                 return leftOperand;
17947             }
17948             var node = createNode(210, leftOperand.pos);
17949             node.condition = leftOperand;
17950             node.questionToken = questionToken;
17951             node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher);
17952             node.colonToken = parseExpectedToken(58);
17953             node.whenFalse = ts.nodeIsPresent(node.colonToken)
17954                 ? parseAssignmentExpressionOrHigher()
17955                 : createMissingNode(75, false, ts.Diagnostics._0_expected, ts.tokenToString(58));
17956             return finishNode(node);
17957         }
17958         function parseBinaryExpressionOrHigher(precedence) {
17959             var leftOperand = parseUnaryExpressionOrHigher();
17960             return parseBinaryExpressionRest(precedence, leftOperand);
17961         }
17962         function isInOrOfKeyword(t) {
17963             return t === 97 || t === 152;
17964         }
17965         function parseBinaryExpressionRest(precedence, leftOperand) {
17966             while (true) {
17967                 reScanGreaterToken();
17968                 var newPrecedence = ts.getBinaryOperatorPrecedence(token());
17969                 var consumeCurrentOperator = token() === 42 ?
17970                     newPrecedence >= precedence :
17971                     newPrecedence > precedence;
17972                 if (!consumeCurrentOperator) {
17973                     break;
17974                 }
17975                 if (token() === 97 && inDisallowInContext()) {
17976                     break;
17977                 }
17978                 if (token() === 123) {
17979                     if (scanner.hasPrecedingLineBreak()) {
17980                         break;
17981                     }
17982                     else {
17983                         nextToken();
17984                         leftOperand = makeAsExpression(leftOperand, parseType());
17985                     }
17986                 }
17987                 else {
17988                     leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence));
17989                 }
17990             }
17991             return leftOperand;
17992         }
17993         function isBinaryOperator() {
17994             if (inDisallowInContext() && token() === 97) {
17995                 return false;
17996             }
17997             return ts.getBinaryOperatorPrecedence(token()) > 0;
17998         }
17999         function makeBinaryExpression(left, operatorToken, right) {
18000             var node = createNode(209, left.pos);
18001             node.left = left;
18002             node.operatorToken = operatorToken;
18003             node.right = right;
18004             return finishNode(node);
18005         }
18006         function makeAsExpression(left, right) {
18007             var node = createNode(217, left.pos);
18008             node.expression = left;
18009             node.type = right;
18010             return finishNode(node);
18011         }
18012         function parsePrefixUnaryExpression() {
18013             var node = createNode(207);
18014             node.operator = token();
18015             nextToken();
18016             node.operand = parseSimpleUnaryExpression();
18017             return finishNode(node);
18018         }
18019         function parseDeleteExpression() {
18020             var node = createNode(203);
18021             nextToken();
18022             node.expression = parseSimpleUnaryExpression();
18023             return finishNode(node);
18024         }
18025         function parseTypeOfExpression() {
18026             var node = createNode(204);
18027             nextToken();
18028             node.expression = parseSimpleUnaryExpression();
18029             return finishNode(node);
18030         }
18031         function parseVoidExpression() {
18032             var node = createNode(205);
18033             nextToken();
18034             node.expression = parseSimpleUnaryExpression();
18035             return finishNode(node);
18036         }
18037         function isAwaitExpression() {
18038             if (token() === 127) {
18039                 if (inAwaitContext()) {
18040                     return true;
18041                 }
18042                 return lookAhead(nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine);
18043             }
18044             return false;
18045         }
18046         function parseAwaitExpression() {
18047             var node = createNode(206);
18048             nextToken();
18049             node.expression = parseSimpleUnaryExpression();
18050             return finishNode(node);
18051         }
18052         function parseUnaryExpressionOrHigher() {
18053             if (isUpdateExpression()) {
18054                 var updateExpression = parseUpdateExpression();
18055                 return token() === 42 ?
18056                     parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression) :
18057                     updateExpression;
18058             }
18059             var unaryOperator = token();
18060             var simpleUnaryExpression = parseSimpleUnaryExpression();
18061             if (token() === 42) {
18062                 var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos);
18063                 var end = simpleUnaryExpression.end;
18064                 if (simpleUnaryExpression.kind === 199) {
18065                     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);
18066                 }
18067                 else {
18068                     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));
18069                 }
18070             }
18071             return simpleUnaryExpression;
18072         }
18073         function parseSimpleUnaryExpression() {
18074             switch (token()) {
18075                 case 39:
18076                 case 40:
18077                 case 54:
18078                 case 53:
18079                     return parsePrefixUnaryExpression();
18080                 case 85:
18081                     return parseDeleteExpression();
18082                 case 108:
18083                     return parseTypeOfExpression();
18084                 case 110:
18085                     return parseVoidExpression();
18086                 case 29:
18087                     return parseTypeAssertion();
18088                 case 127:
18089                     if (isAwaitExpression()) {
18090                         return parseAwaitExpression();
18091                     }
18092                 default:
18093                     return parseUpdateExpression();
18094             }
18095         }
18096         function isUpdateExpression() {
18097             switch (token()) {
18098                 case 39:
18099                 case 40:
18100                 case 54:
18101                 case 53:
18102                 case 85:
18103                 case 108:
18104                 case 110:
18105                 case 127:
18106                     return false;
18107                 case 29:
18108                     if (sourceFile.languageVariant !== 1) {
18109                         return false;
18110                     }
18111                 default:
18112                     return true;
18113             }
18114         }
18115         function parseUpdateExpression() {
18116             if (token() === 45 || token() === 46) {
18117                 var node = createNode(207);
18118                 node.operator = token();
18119                 nextToken();
18120                 node.operand = parseLeftHandSideExpressionOrHigher();
18121                 return finishNode(node);
18122             }
18123             else if (sourceFile.languageVariant === 1 && token() === 29 && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) {
18124                 return parseJsxElementOrSelfClosingElementOrFragment(true);
18125             }
18126             var expression = parseLeftHandSideExpressionOrHigher();
18127             ts.Debug.assert(ts.isLeftHandSideExpression(expression));
18128             if ((token() === 45 || token() === 46) && !scanner.hasPrecedingLineBreak()) {
18129                 var node = createNode(208, expression.pos);
18130                 node.operand = expression;
18131                 node.operator = token();
18132                 nextToken();
18133                 return finishNode(node);
18134             }
18135             return expression;
18136         }
18137         function parseLeftHandSideExpressionOrHigher() {
18138             var expression;
18139             if (token() === 96) {
18140                 if (lookAhead(nextTokenIsOpenParenOrLessThan)) {
18141                     sourceFile.flags |= 1048576;
18142                     expression = parseTokenNode();
18143                 }
18144                 else if (lookAhead(nextTokenIsDot)) {
18145                     var fullStart = scanner.getStartPos();
18146                     nextToken();
18147                     nextToken();
18148                     var node = createNode(219, fullStart);
18149                     node.keywordToken = 96;
18150                     node.name = parseIdentifierName();
18151                     expression = finishNode(node);
18152                     sourceFile.flags |= 2097152;
18153                 }
18154                 else {
18155                     expression = parseMemberExpressionOrHigher();
18156                 }
18157             }
18158             else {
18159                 expression = token() === 102 ? parseSuperExpression() : parseMemberExpressionOrHigher();
18160             }
18161             return parseCallExpressionRest(expression);
18162         }
18163         function parseMemberExpressionOrHigher() {
18164             var expression = parsePrimaryExpression();
18165             return parseMemberExpressionRest(expression, true);
18166         }
18167         function parseSuperExpression() {
18168             var expression = parseTokenNode();
18169             if (token() === 29) {
18170                 var startPos = getNodePos();
18171                 var typeArguments = tryParse(parseTypeArgumentsInExpression);
18172                 if (typeArguments !== undefined) {
18173                     parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments);
18174                 }
18175             }
18176             if (token() === 20 || token() === 24 || token() === 22) {
18177                 return expression;
18178             }
18179             var node = createNode(194, expression.pos);
18180             node.expression = expression;
18181             parseExpectedToken(24, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access);
18182             node.name = parseRightSideOfDot(true, true);
18183             return finishNode(node);
18184         }
18185         function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) {
18186             var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext);
18187             var result;
18188             if (opening.kind === 268) {
18189                 var node = createNode(266, opening.pos);
18190                 node.openingElement = opening;
18191                 node.children = parseJsxChildren(node.openingElement);
18192                 node.closingElement = parseJsxClosingElement(inExpressionContext);
18193                 if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) {
18194                     parseErrorAtRange(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, node.openingElement.tagName));
18195                 }
18196                 result = finishNode(node);
18197             }
18198             else if (opening.kind === 271) {
18199                 var node = createNode(270, opening.pos);
18200                 node.openingFragment = opening;
18201                 node.children = parseJsxChildren(node.openingFragment);
18202                 node.closingFragment = parseJsxClosingFragment(inExpressionContext);
18203                 result = finishNode(node);
18204             }
18205             else {
18206                 ts.Debug.assert(opening.kind === 267);
18207                 result = opening;
18208             }
18209             if (inExpressionContext && token() === 29) {
18210                 var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(true); });
18211                 if (invalidElement) {
18212                     parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element);
18213                     var badNode = createNode(209, result.pos);
18214                     badNode.end = invalidElement.end;
18215                     badNode.left = result;
18216                     badNode.right = invalidElement;
18217                     badNode.operatorToken = createMissingNode(27, false);
18218                     badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos;
18219                     return badNode;
18220                 }
18221             }
18222             return result;
18223         }
18224         function parseJsxText() {
18225             var node = createNode(11);
18226             node.text = scanner.getTokenValue();
18227             node.containsOnlyTriviaWhiteSpaces = currentToken === 12;
18228             currentToken = scanner.scanJsxToken();
18229             return finishNode(node);
18230         }
18231         function parseJsxChild(openingTag, token) {
18232             switch (token) {
18233                 case 1:
18234                     if (ts.isJsxOpeningFragment(openingTag)) {
18235                         parseErrorAtRange(openingTag, ts.Diagnostics.JSX_fragment_has_no_corresponding_closing_tag);
18236                     }
18237                     else {
18238                         var tag = openingTag.tagName;
18239                         var start = ts.skipTrivia(sourceText, tag.pos);
18240                         parseErrorAt(start, tag.end, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName));
18241                     }
18242                     return undefined;
18243                 case 30:
18244                 case 7:
18245                     return undefined;
18246                 case 11:
18247                 case 12:
18248                     return parseJsxText();
18249                 case 18:
18250                     return parseJsxExpression(false);
18251                 case 29:
18252                     return parseJsxElementOrSelfClosingElementOrFragment(false);
18253                 default:
18254                     return ts.Debug.assertNever(token);
18255             }
18256         }
18257         function parseJsxChildren(openingTag) {
18258             var list = [];
18259             var listPos = getNodePos();
18260             var saveParsingContext = parsingContext;
18261             parsingContext |= 1 << 14;
18262             while (true) {
18263                 var child = parseJsxChild(openingTag, currentToken = scanner.reScanJsxToken());
18264                 if (!child)
18265                     break;
18266                 list.push(child);
18267             }
18268             parsingContext = saveParsingContext;
18269             return createNodeArray(list, listPos);
18270         }
18271         function parseJsxAttributes() {
18272             var jsxAttributes = createNode(274);
18273             jsxAttributes.properties = parseList(13, parseJsxAttribute);
18274             return finishNode(jsxAttributes);
18275         }
18276         function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) {
18277             var fullStart = scanner.getStartPos();
18278             parseExpected(29);
18279             if (token() === 31) {
18280                 var node_1 = createNode(271, fullStart);
18281                 scanJsxText();
18282                 return finishNode(node_1);
18283             }
18284             var tagName = parseJsxElementName();
18285             var typeArguments = tryParseTypeArguments();
18286             var attributes = parseJsxAttributes();
18287             var node;
18288             if (token() === 31) {
18289                 node = createNode(268, fullStart);
18290                 scanJsxText();
18291             }
18292             else {
18293                 parseExpected(43);
18294                 if (inExpressionContext) {
18295                     parseExpected(31);
18296                 }
18297                 else {
18298                     parseExpected(31, undefined, false);
18299                     scanJsxText();
18300                 }
18301                 node = createNode(267, fullStart);
18302             }
18303             node.tagName = tagName;
18304             node.typeArguments = typeArguments;
18305             node.attributes = attributes;
18306             return finishNode(node);
18307         }
18308         function parseJsxElementName() {
18309             scanJsxIdentifier();
18310             var expression = token() === 104 ?
18311                 parseTokenNode() : parseIdentifierName();
18312             while (parseOptional(24)) {
18313                 var propertyAccess = createNode(194, expression.pos);
18314                 propertyAccess.expression = expression;
18315                 propertyAccess.name = parseRightSideOfDot(true, false);
18316                 expression = finishNode(propertyAccess);
18317             }
18318             return expression;
18319         }
18320         function parseJsxExpression(inExpressionContext) {
18321             var node = createNode(276);
18322             if (!parseExpected(18)) {
18323                 return undefined;
18324             }
18325             if (token() !== 19) {
18326                 node.dotDotDotToken = parseOptionalToken(25);
18327                 node.expression = parseExpression();
18328             }
18329             if (inExpressionContext) {
18330                 parseExpected(19);
18331             }
18332             else {
18333                 if (parseExpected(19, undefined, false)) {
18334                     scanJsxText();
18335                 }
18336             }
18337             return finishNode(node);
18338         }
18339         function parseJsxAttribute() {
18340             if (token() === 18) {
18341                 return parseJsxSpreadAttribute();
18342             }
18343             scanJsxIdentifier();
18344             var node = createNode(273);
18345             node.name = parseIdentifierName();
18346             if (token() === 62) {
18347                 switch (scanJsxAttributeValue()) {
18348                     case 10:
18349                         node.initializer = parseLiteralNode();
18350                         break;
18351                     default:
18352                         node.initializer = parseJsxExpression(true);
18353                         break;
18354                 }
18355             }
18356             return finishNode(node);
18357         }
18358         function parseJsxSpreadAttribute() {
18359             var node = createNode(275);
18360             parseExpected(18);
18361             parseExpected(25);
18362             node.expression = parseExpression();
18363             parseExpected(19);
18364             return finishNode(node);
18365         }
18366         function parseJsxClosingElement(inExpressionContext) {
18367             var node = createNode(269);
18368             parseExpected(30);
18369             node.tagName = parseJsxElementName();
18370             if (inExpressionContext) {
18371                 parseExpected(31);
18372             }
18373             else {
18374                 parseExpected(31, undefined, false);
18375                 scanJsxText();
18376             }
18377             return finishNode(node);
18378         }
18379         function parseJsxClosingFragment(inExpressionContext) {
18380             var node = createNode(272);
18381             parseExpected(30);
18382             if (ts.tokenIsIdentifierOrKeyword(token())) {
18383                 parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment);
18384             }
18385             if (inExpressionContext) {
18386                 parseExpected(31);
18387             }
18388             else {
18389                 parseExpected(31, undefined, false);
18390                 scanJsxText();
18391             }
18392             return finishNode(node);
18393         }
18394         function parseTypeAssertion() {
18395             var node = createNode(199);
18396             parseExpected(29);
18397             node.type = parseType();
18398             parseExpected(31);
18399             node.expression = parseSimpleUnaryExpression();
18400             return finishNode(node);
18401         }
18402         function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() {
18403             nextToken();
18404             return ts.tokenIsIdentifierOrKeyword(token())
18405                 || token() === 22
18406                 || isTemplateStartOfTaggedTemplate();
18407         }
18408         function isStartOfOptionalPropertyOrElementAccessChain() {
18409             return token() === 28
18410                 && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate);
18411         }
18412         function tryReparseOptionalChain(node) {
18413             if (node.flags & 32) {
18414                 return true;
18415             }
18416             if (ts.isNonNullExpression(node)) {
18417                 var expr = node.expression;
18418                 while (ts.isNonNullExpression(expr) && !(expr.flags & 32)) {
18419                     expr = expr.expression;
18420                 }
18421                 if (expr.flags & 32) {
18422                     while (ts.isNonNullExpression(node)) {
18423                         node.flags |= 32;
18424                         node = node.expression;
18425                     }
18426                     return true;
18427                 }
18428             }
18429             return false;
18430         }
18431         function parsePropertyAccessExpressionRest(expression, questionDotToken) {
18432             var propertyAccess = createNode(194, expression.pos);
18433             propertyAccess.expression = expression;
18434             propertyAccess.questionDotToken = questionDotToken;
18435             propertyAccess.name = parseRightSideOfDot(true, true);
18436             if (questionDotToken || tryReparseOptionalChain(expression)) {
18437                 propertyAccess.flags |= 32;
18438                 if (ts.isPrivateIdentifier(propertyAccess.name)) {
18439                     parseErrorAtRange(propertyAccess.name, ts.Diagnostics.An_optional_chain_cannot_contain_private_identifiers);
18440                 }
18441             }
18442             return finishNode(propertyAccess);
18443         }
18444         function parseElementAccessExpressionRest(expression, questionDotToken) {
18445             var indexedAccess = createNode(195, expression.pos);
18446             indexedAccess.expression = expression;
18447             indexedAccess.questionDotToken = questionDotToken;
18448             if (token() === 23) {
18449                 indexedAccess.argumentExpression = createMissingNode(75, true, ts.Diagnostics.An_element_access_expression_should_take_an_argument);
18450             }
18451             else {
18452                 var argument = allowInAnd(parseExpression);
18453                 if (ts.isStringOrNumericLiteralLike(argument)) {
18454                     argument.text = internIdentifier(argument.text);
18455                 }
18456                 indexedAccess.argumentExpression = argument;
18457             }
18458             parseExpected(23);
18459             if (questionDotToken || tryReparseOptionalChain(expression)) {
18460                 indexedAccess.flags |= 32;
18461             }
18462             return finishNode(indexedAccess);
18463         }
18464         function parseMemberExpressionRest(expression, allowOptionalChain) {
18465             while (true) {
18466                 var questionDotToken = void 0;
18467                 var isPropertyAccess = false;
18468                 if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) {
18469                     questionDotToken = parseExpectedToken(28);
18470                     isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token());
18471                 }
18472                 else {
18473                     isPropertyAccess = parseOptional(24);
18474                 }
18475                 if (isPropertyAccess) {
18476                     expression = parsePropertyAccessExpressionRest(expression, questionDotToken);
18477                     continue;
18478                 }
18479                 if (!questionDotToken && token() === 53 && !scanner.hasPrecedingLineBreak()) {
18480                     nextToken();
18481                     var nonNullExpression = createNode(218, expression.pos);
18482                     nonNullExpression.expression = expression;
18483                     expression = finishNode(nonNullExpression);
18484                     continue;
18485                 }
18486                 if ((questionDotToken || !inDecoratorContext()) && parseOptional(22)) {
18487                     expression = parseElementAccessExpressionRest(expression, questionDotToken);
18488                     continue;
18489                 }
18490                 if (isTemplateStartOfTaggedTemplate()) {
18491                     expression = parseTaggedTemplateRest(expression, questionDotToken, undefined);
18492                     continue;
18493                 }
18494                 return expression;
18495             }
18496         }
18497         function isTemplateStartOfTaggedTemplate() {
18498             return token() === 14 || token() === 15;
18499         }
18500         function parseTaggedTemplateRest(tag, questionDotToken, typeArguments) {
18501             var tagExpression = createNode(198, tag.pos);
18502             tagExpression.tag = tag;
18503             tagExpression.questionDotToken = questionDotToken;
18504             tagExpression.typeArguments = typeArguments;
18505             tagExpression.template = token() === 14
18506                 ? (reScanTemplateHeadOrNoSubstitutionTemplate(), parseLiteralNode())
18507                 : parseTemplateExpression(true);
18508             if (questionDotToken || tag.flags & 32) {
18509                 tagExpression.flags |= 32;
18510             }
18511             return finishNode(tagExpression);
18512         }
18513         function parseCallExpressionRest(expression) {
18514             while (true) {
18515                 expression = parseMemberExpressionRest(expression, true);
18516                 var questionDotToken = parseOptionalToken(28);
18517                 if (token() === 29 || token() === 47) {
18518                     var typeArguments = tryParse(parseTypeArgumentsInExpression);
18519                     if (typeArguments) {
18520                         if (isTemplateStartOfTaggedTemplate()) {
18521                             expression = parseTaggedTemplateRest(expression, questionDotToken, typeArguments);
18522                             continue;
18523                         }
18524                         var callExpr = createNode(196, expression.pos);
18525                         callExpr.expression = expression;
18526                         callExpr.questionDotToken = questionDotToken;
18527                         callExpr.typeArguments = typeArguments;
18528                         callExpr.arguments = parseArgumentList();
18529                         if (questionDotToken || tryReparseOptionalChain(expression)) {
18530                             callExpr.flags |= 32;
18531                         }
18532                         expression = finishNode(callExpr);
18533                         continue;
18534                     }
18535                 }
18536                 else if (token() === 20) {
18537                     var callExpr = createNode(196, expression.pos);
18538                     callExpr.expression = expression;
18539                     callExpr.questionDotToken = questionDotToken;
18540                     callExpr.arguments = parseArgumentList();
18541                     if (questionDotToken || tryReparseOptionalChain(expression)) {
18542                         callExpr.flags |= 32;
18543                     }
18544                     expression = finishNode(callExpr);
18545                     continue;
18546                 }
18547                 if (questionDotToken) {
18548                     var propertyAccess = createNode(194, expression.pos);
18549                     propertyAccess.expression = expression;
18550                     propertyAccess.questionDotToken = questionDotToken;
18551                     propertyAccess.name = createMissingNode(75, false, ts.Diagnostics.Identifier_expected);
18552                     propertyAccess.flags |= 32;
18553                     expression = finishNode(propertyAccess);
18554                 }
18555                 break;
18556             }
18557             return expression;
18558         }
18559         function parseArgumentList() {
18560             parseExpected(20);
18561             var result = parseDelimitedList(11, parseArgumentExpression);
18562             parseExpected(21);
18563             return result;
18564         }
18565         function parseTypeArgumentsInExpression() {
18566             if (reScanLessThanToken() !== 29) {
18567                 return undefined;
18568             }
18569             nextToken();
18570             var typeArguments = parseDelimitedList(20, parseType);
18571             if (!parseExpected(31)) {
18572                 return undefined;
18573             }
18574             return typeArguments && canFollowTypeArgumentsInExpression()
18575                 ? typeArguments
18576                 : undefined;
18577         }
18578         function canFollowTypeArgumentsInExpression() {
18579             switch (token()) {
18580                 case 20:
18581                 case 14:
18582                 case 15:
18583                 case 24:
18584                 case 21:
18585                 case 23:
18586                 case 58:
18587                 case 26:
18588                 case 57:
18589                 case 34:
18590                 case 36:
18591                 case 35:
18592                 case 37:
18593                 case 55:
18594                 case 56:
18595                 case 60:
18596                 case 52:
18597                 case 50:
18598                 case 51:
18599                 case 19:
18600                 case 1:
18601                     return true;
18602                 case 27:
18603                 case 18:
18604                 default:
18605                     return false;
18606             }
18607         }
18608         function parsePrimaryExpression() {
18609             switch (token()) {
18610                 case 8:
18611                 case 9:
18612                 case 10:
18613                 case 14:
18614                     return parseLiteralNode();
18615                 case 104:
18616                 case 102:
18617                 case 100:
18618                 case 106:
18619                 case 91:
18620                     return parseTokenNode();
18621                 case 20:
18622                     return parseParenthesizedExpression();
18623                 case 22:
18624                     return parseArrayLiteralExpression();
18625                 case 18:
18626                     return parseObjectLiteralExpression();
18627                 case 126:
18628                     if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) {
18629                         break;
18630                     }
18631                     return parseFunctionExpression();
18632                 case 80:
18633                     return parseClassExpression();
18634                 case 94:
18635                     return parseFunctionExpression();
18636                 case 99:
18637                     return parseNewExpressionOrNewDotTarget();
18638                 case 43:
18639                 case 67:
18640                     if (reScanSlashToken() === 13) {
18641                         return parseLiteralNode();
18642                     }
18643                     break;
18644                 case 15:
18645                     return parseTemplateExpression(false);
18646             }
18647             return parseIdentifier(ts.Diagnostics.Expression_expected);
18648         }
18649         function parseParenthesizedExpression() {
18650             var node = createNodeWithJSDoc(200);
18651             parseExpected(20);
18652             node.expression = allowInAnd(parseExpression);
18653             parseExpected(21);
18654             return finishNode(node);
18655         }
18656         function parseSpreadElement() {
18657             var node = createNode(213);
18658             parseExpected(25);
18659             node.expression = parseAssignmentExpressionOrHigher();
18660             return finishNode(node);
18661         }
18662         function parseArgumentOrArrayLiteralElement() {
18663             return token() === 25 ? parseSpreadElement() :
18664                 token() === 27 ? createNode(215) :
18665                     parseAssignmentExpressionOrHigher();
18666         }
18667         function parseArgumentExpression() {
18668             return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement);
18669         }
18670         function parseArrayLiteralExpression() {
18671             var node = createNode(192);
18672             parseExpected(22);
18673             if (scanner.hasPrecedingLineBreak()) {
18674                 node.multiLine = true;
18675             }
18676             node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement);
18677             parseExpected(23);
18678             return finishNode(node);
18679         }
18680         function parseObjectLiteralElement() {
18681             var node = createNodeWithJSDoc(0);
18682             if (parseOptionalToken(25)) {
18683                 node.kind = 283;
18684                 node.expression = parseAssignmentExpressionOrHigher();
18685                 return finishNode(node);
18686             }
18687             node.decorators = parseDecorators();
18688             node.modifiers = parseModifiers();
18689             if (parseContextualModifier(131)) {
18690                 return parseAccessorDeclaration(node, 163);
18691             }
18692             if (parseContextualModifier(142)) {
18693                 return parseAccessorDeclaration(node, 164);
18694             }
18695             var asteriskToken = parseOptionalToken(41);
18696             var tokenIsIdentifier = isIdentifier();
18697             node.name = parsePropertyName();
18698             node.questionToken = parseOptionalToken(57);
18699             node.exclamationToken = parseOptionalToken(53);
18700             if (asteriskToken || token() === 20 || token() === 29) {
18701                 return parseMethodDeclaration(node, asteriskToken);
18702             }
18703             var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58);
18704             if (isShorthandPropertyAssignment) {
18705                 node.kind = 282;
18706                 var equalsToken = parseOptionalToken(62);
18707                 if (equalsToken) {
18708                     node.equalsToken = equalsToken;
18709                     node.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher);
18710                 }
18711             }
18712             else {
18713                 node.kind = 281;
18714                 parseExpected(58);
18715                 node.initializer = allowInAnd(parseAssignmentExpressionOrHigher);
18716             }
18717             return finishNode(node);
18718         }
18719         function parseObjectLiteralExpression() {
18720             var node = createNode(193);
18721             var openBracePosition = scanner.getTokenPos();
18722             parseExpected(18);
18723             if (scanner.hasPrecedingLineBreak()) {
18724                 node.multiLine = true;
18725             }
18726             node.properties = parseDelimitedList(12, parseObjectLiteralElement, true);
18727             if (!parseExpected(19)) {
18728                 var lastError = ts.lastOrUndefined(parseDiagnostics);
18729                 if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
18730                     ts.addRelatedInfo(lastError, ts.createFileDiagnostic(sourceFile, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
18731                 }
18732             }
18733             return finishNode(node);
18734         }
18735         function parseFunctionExpression() {
18736             var saveDecoratorContext = inDecoratorContext();
18737             if (saveDecoratorContext) {
18738                 setDecoratorContext(false);
18739             }
18740             var node = createNodeWithJSDoc(201);
18741             node.modifiers = parseModifiers();
18742             parseExpected(94);
18743             node.asteriskToken = parseOptionalToken(41);
18744             var isGenerator = node.asteriskToken ? 1 : 0;
18745             var isAsync = hasModifierOfKind(node, 126) ? 2 : 0;
18746             node.name =
18747                 isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) :
18748                     isGenerator ? doInYieldContext(parseOptionalIdentifier) :
18749                         isAsync ? doInAwaitContext(parseOptionalIdentifier) :
18750                             parseOptionalIdentifier();
18751             fillSignature(58, isGenerator | isAsync, node);
18752             node.body = parseFunctionBlock(isGenerator | isAsync);
18753             if (saveDecoratorContext) {
18754                 setDecoratorContext(true);
18755             }
18756             return finishNode(node);
18757         }
18758         function parseOptionalIdentifier() {
18759             return isIdentifier() ? parseIdentifier() : undefined;
18760         }
18761         function parseNewExpressionOrNewDotTarget() {
18762             var fullStart = scanner.getStartPos();
18763             parseExpected(99);
18764             if (parseOptional(24)) {
18765                 var node_2 = createNode(219, fullStart);
18766                 node_2.keywordToken = 99;
18767                 node_2.name = parseIdentifierName();
18768                 return finishNode(node_2);
18769             }
18770             var expression = parsePrimaryExpression();
18771             var typeArguments;
18772             while (true) {
18773                 expression = parseMemberExpressionRest(expression, false);
18774                 typeArguments = tryParse(parseTypeArgumentsInExpression);
18775                 if (isTemplateStartOfTaggedTemplate()) {
18776                     ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'");
18777                     expression = parseTaggedTemplateRest(expression, undefined, typeArguments);
18778                     typeArguments = undefined;
18779                 }
18780                 break;
18781             }
18782             var node = createNode(197, fullStart);
18783             node.expression = expression;
18784             node.typeArguments = typeArguments;
18785             if (token() === 20) {
18786                 node.arguments = parseArgumentList();
18787             }
18788             else if (node.typeArguments) {
18789                 parseErrorAt(fullStart, scanner.getStartPos(), ts.Diagnostics.A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list);
18790             }
18791             return finishNode(node);
18792         }
18793         function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) {
18794             var node = createNode(223);
18795             var openBracePosition = scanner.getTokenPos();
18796             if (parseExpected(18, diagnosticMessage) || ignoreMissingOpenBrace) {
18797                 if (scanner.hasPrecedingLineBreak()) {
18798                     node.multiLine = true;
18799                 }
18800                 node.statements = parseList(1, parseStatement);
18801                 if (!parseExpected(19)) {
18802                     var lastError = ts.lastOrUndefined(parseDiagnostics);
18803                     if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
18804                         ts.addRelatedInfo(lastError, ts.createFileDiagnostic(sourceFile, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
18805                     }
18806                 }
18807             }
18808             else {
18809                 node.statements = createMissingList();
18810             }
18811             return finishNode(node);
18812         }
18813         function parseFunctionBlock(flags, diagnosticMessage) {
18814             var savedYieldContext = inYieldContext();
18815             setYieldContext(!!(flags & 1));
18816             var savedAwaitContext = inAwaitContext();
18817             setAwaitContext(!!(flags & 2));
18818             var saveDecoratorContext = inDecoratorContext();
18819             if (saveDecoratorContext) {
18820                 setDecoratorContext(false);
18821             }
18822             var block = parseBlock(!!(flags & 16), diagnosticMessage);
18823             if (saveDecoratorContext) {
18824                 setDecoratorContext(true);
18825             }
18826             setYieldContext(savedYieldContext);
18827             setAwaitContext(savedAwaitContext);
18828             return block;
18829         }
18830         function parseEmptyStatement() {
18831             var node = createNode(224);
18832             parseExpected(26);
18833             return finishNode(node);
18834         }
18835         function parseIfStatement() {
18836             var node = createNode(227);
18837             parseExpected(95);
18838             parseExpected(20);
18839             node.expression = allowInAnd(parseExpression);
18840             parseExpected(21);
18841             node.thenStatement = parseStatement();
18842             node.elseStatement = parseOptional(87) ? parseStatement() : undefined;
18843             return finishNode(node);
18844         }
18845         function parseDoStatement() {
18846             var node = createNode(228);
18847             parseExpected(86);
18848             node.statement = parseStatement();
18849             parseExpected(111);
18850             parseExpected(20);
18851             node.expression = allowInAnd(parseExpression);
18852             parseExpected(21);
18853             parseOptional(26);
18854             return finishNode(node);
18855         }
18856         function parseWhileStatement() {
18857             var node = createNode(229);
18858             parseExpected(111);
18859             parseExpected(20);
18860             node.expression = allowInAnd(parseExpression);
18861             parseExpected(21);
18862             node.statement = parseStatement();
18863             return finishNode(node);
18864         }
18865         function parseForOrForInOrForOfStatement() {
18866             var pos = getNodePos();
18867             parseExpected(93);
18868             var awaitToken = parseOptionalToken(127);
18869             parseExpected(20);
18870             var initializer;
18871             if (token() !== 26) {
18872                 if (token() === 109 || token() === 115 || token() === 81) {
18873                     initializer = parseVariableDeclarationList(true);
18874                 }
18875                 else {
18876                     initializer = disallowInAnd(parseExpression);
18877                 }
18878             }
18879             var forOrForInOrForOfStatement;
18880             if (awaitToken ? parseExpected(152) : parseOptional(152)) {
18881                 var forOfStatement = createNode(232, pos);
18882                 forOfStatement.awaitModifier = awaitToken;
18883                 forOfStatement.initializer = initializer;
18884                 forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher);
18885                 parseExpected(21);
18886                 forOrForInOrForOfStatement = forOfStatement;
18887             }
18888             else if (parseOptional(97)) {
18889                 var forInStatement = createNode(231, pos);
18890                 forInStatement.initializer = initializer;
18891                 forInStatement.expression = allowInAnd(parseExpression);
18892                 parseExpected(21);
18893                 forOrForInOrForOfStatement = forInStatement;
18894             }
18895             else {
18896                 var forStatement = createNode(230, pos);
18897                 forStatement.initializer = initializer;
18898                 parseExpected(26);
18899                 if (token() !== 26 && token() !== 21) {
18900                     forStatement.condition = allowInAnd(parseExpression);
18901                 }
18902                 parseExpected(26);
18903                 if (token() !== 21) {
18904                     forStatement.incrementor = allowInAnd(parseExpression);
18905                 }
18906                 parseExpected(21);
18907                 forOrForInOrForOfStatement = forStatement;
18908             }
18909             forOrForInOrForOfStatement.statement = parseStatement();
18910             return finishNode(forOrForInOrForOfStatement);
18911         }
18912         function parseBreakOrContinueStatement(kind) {
18913             var node = createNode(kind);
18914             parseExpected(kind === 234 ? 77 : 82);
18915             if (!canParseSemicolon()) {
18916                 node.label = parseIdentifier();
18917             }
18918             parseSemicolon();
18919             return finishNode(node);
18920         }
18921         function parseReturnStatement() {
18922             var node = createNode(235);
18923             parseExpected(101);
18924             if (!canParseSemicolon()) {
18925                 node.expression = allowInAnd(parseExpression);
18926             }
18927             parseSemicolon();
18928             return finishNode(node);
18929         }
18930         function parseWithStatement() {
18931             var node = createNode(236);
18932             parseExpected(112);
18933             parseExpected(20);
18934             node.expression = allowInAnd(parseExpression);
18935             parseExpected(21);
18936             node.statement = doInsideOfContext(16777216, parseStatement);
18937             return finishNode(node);
18938         }
18939         function parseCaseClause() {
18940             var node = createNode(277);
18941             parseExpected(78);
18942             node.expression = allowInAnd(parseExpression);
18943             parseExpected(58);
18944             node.statements = parseList(3, parseStatement);
18945             return finishNode(node);
18946         }
18947         function parseDefaultClause() {
18948             var node = createNode(278);
18949             parseExpected(84);
18950             parseExpected(58);
18951             node.statements = parseList(3, parseStatement);
18952             return finishNode(node);
18953         }
18954         function parseCaseOrDefaultClause() {
18955             return token() === 78 ? parseCaseClause() : parseDefaultClause();
18956         }
18957         function parseSwitchStatement() {
18958             var node = createNode(237);
18959             parseExpected(103);
18960             parseExpected(20);
18961             node.expression = allowInAnd(parseExpression);
18962             parseExpected(21);
18963             var caseBlock = createNode(251);
18964             parseExpected(18);
18965             caseBlock.clauses = parseList(2, parseCaseOrDefaultClause);
18966             parseExpected(19);
18967             node.caseBlock = finishNode(caseBlock);
18968             return finishNode(node);
18969         }
18970         function parseThrowStatement() {
18971             var node = createNode(239);
18972             parseExpected(105);
18973             node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression);
18974             parseSemicolon();
18975             return finishNode(node);
18976         }
18977         function parseTryStatement() {
18978             var node = createNode(240);
18979             parseExpected(107);
18980             node.tryBlock = parseBlock(false);
18981             node.catchClause = token() === 79 ? parseCatchClause() : undefined;
18982             if (!node.catchClause || token() === 92) {
18983                 parseExpected(92);
18984                 node.finallyBlock = parseBlock(false);
18985             }
18986             return finishNode(node);
18987         }
18988         function parseCatchClause() {
18989             var result = createNode(280);
18990             parseExpected(79);
18991             if (parseOptional(20)) {
18992                 result.variableDeclaration = parseVariableDeclaration();
18993                 parseExpected(21);
18994             }
18995             else {
18996                 result.variableDeclaration = undefined;
18997             }
18998             result.block = parseBlock(false);
18999             return finishNode(result);
19000         }
19001         function parseDebuggerStatement() {
19002             var node = createNode(241);
19003             parseExpected(83);
19004             parseSemicolon();
19005             return finishNode(node);
19006         }
19007         function parseExpressionOrLabeledStatement() {
19008             var node = createNodeWithJSDoc(token() === 75 ? 0 : 226);
19009             var expression = allowInAnd(parseExpression);
19010             if (expression.kind === 75 && parseOptional(58)) {
19011                 node.kind = 238;
19012                 node.label = expression;
19013                 node.statement = parseStatement();
19014             }
19015             else {
19016                 node.kind = 226;
19017                 node.expression = expression;
19018                 parseSemicolon();
19019             }
19020             return finishNode(node);
19021         }
19022         function nextTokenIsIdentifierOrKeywordOnSameLine() {
19023             nextToken();
19024             return ts.tokenIsIdentifierOrKeyword(token()) && !scanner.hasPrecedingLineBreak();
19025         }
19026         function nextTokenIsClassKeywordOnSameLine() {
19027             nextToken();
19028             return token() === 80 && !scanner.hasPrecedingLineBreak();
19029         }
19030         function nextTokenIsFunctionKeywordOnSameLine() {
19031             nextToken();
19032             return token() === 94 && !scanner.hasPrecedingLineBreak();
19033         }
19034         function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() {
19035             nextToken();
19036             return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 || token() === 9 || token() === 10) && !scanner.hasPrecedingLineBreak();
19037         }
19038         function isDeclaration() {
19039             while (true) {
19040                 switch (token()) {
19041                     case 109:
19042                     case 115:
19043                     case 81:
19044                     case 94:
19045                     case 80:
19046                     case 88:
19047                         return true;
19048                     case 114:
19049                     case 145:
19050                         return nextTokenIsIdentifierOnSameLine();
19051                     case 135:
19052                     case 136:
19053                         return nextTokenIsIdentifierOrStringLiteralOnSameLine();
19054                     case 122:
19055                     case 126:
19056                     case 130:
19057                     case 117:
19058                     case 118:
19059                     case 119:
19060                     case 138:
19061                         nextToken();
19062                         if (scanner.hasPrecedingLineBreak()) {
19063                             return false;
19064                         }
19065                         continue;
19066                     case 150:
19067                         nextToken();
19068                         return token() === 18 || token() === 75 || token() === 89;
19069                     case 96:
19070                         nextToken();
19071                         return token() === 10 || token() === 41 ||
19072                             token() === 18 || ts.tokenIsIdentifierOrKeyword(token());
19073                     case 89:
19074                         var currentToken_1 = nextToken();
19075                         if (currentToken_1 === 145) {
19076                             currentToken_1 = lookAhead(nextToken);
19077                         }
19078                         if (currentToken_1 === 62 || currentToken_1 === 41 ||
19079                             currentToken_1 === 18 || currentToken_1 === 84 ||
19080                             currentToken_1 === 123) {
19081                             return true;
19082                         }
19083                         continue;
19084                     case 120:
19085                         nextToken();
19086                         continue;
19087                     default:
19088                         return false;
19089                 }
19090             }
19091         }
19092         function isStartOfDeclaration() {
19093             return lookAhead(isDeclaration);
19094         }
19095         function isStartOfStatement() {
19096             switch (token()) {
19097                 case 59:
19098                 case 26:
19099                 case 18:
19100                 case 109:
19101                 case 115:
19102                 case 94:
19103                 case 80:
19104                 case 88:
19105                 case 95:
19106                 case 86:
19107                 case 111:
19108                 case 93:
19109                 case 82:
19110                 case 77:
19111                 case 101:
19112                 case 112:
19113                 case 103:
19114                 case 105:
19115                 case 107:
19116                 case 83:
19117                 case 79:
19118                 case 92:
19119                     return true;
19120                 case 96:
19121                     return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot);
19122                 case 81:
19123                 case 89:
19124                     return isStartOfDeclaration();
19125                 case 126:
19126                 case 130:
19127                 case 114:
19128                 case 135:
19129                 case 136:
19130                 case 145:
19131                 case 150:
19132                     return true;
19133                 case 119:
19134                 case 117:
19135                 case 118:
19136                 case 120:
19137                 case 138:
19138                     return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
19139                 default:
19140                     return isStartOfExpression();
19141             }
19142         }
19143         function nextTokenIsIdentifierOrStartOfDestructuring() {
19144             nextToken();
19145             return isIdentifier() || token() === 18 || token() === 22;
19146         }
19147         function isLetDeclaration() {
19148             return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring);
19149         }
19150         function parseStatement() {
19151             switch (token()) {
19152                 case 26:
19153                     return parseEmptyStatement();
19154                 case 18:
19155                     return parseBlock(false);
19156                 case 109:
19157                     return parseVariableStatement(createNodeWithJSDoc(242));
19158                 case 115:
19159                     if (isLetDeclaration()) {
19160                         return parseVariableStatement(createNodeWithJSDoc(242));
19161                     }
19162                     break;
19163                 case 94:
19164                     return parseFunctionDeclaration(createNodeWithJSDoc(244));
19165                 case 80:
19166                     return parseClassDeclaration(createNodeWithJSDoc(245));
19167                 case 95:
19168                     return parseIfStatement();
19169                 case 86:
19170                     return parseDoStatement();
19171                 case 111:
19172                     return parseWhileStatement();
19173                 case 93:
19174                     return parseForOrForInOrForOfStatement();
19175                 case 82:
19176                     return parseBreakOrContinueStatement(233);
19177                 case 77:
19178                     return parseBreakOrContinueStatement(234);
19179                 case 101:
19180                     return parseReturnStatement();
19181                 case 112:
19182                     return parseWithStatement();
19183                 case 103:
19184                     return parseSwitchStatement();
19185                 case 105:
19186                     return parseThrowStatement();
19187                 case 107:
19188                 case 79:
19189                 case 92:
19190                     return parseTryStatement();
19191                 case 83:
19192                     return parseDebuggerStatement();
19193                 case 59:
19194                     return parseDeclaration();
19195                 case 126:
19196                 case 114:
19197                 case 145:
19198                 case 135:
19199                 case 136:
19200                 case 130:
19201                 case 81:
19202                 case 88:
19203                 case 89:
19204                 case 96:
19205                 case 117:
19206                 case 118:
19207                 case 119:
19208                 case 122:
19209                 case 120:
19210                 case 138:
19211                 case 150:
19212                     if (isStartOfDeclaration()) {
19213                         return parseDeclaration();
19214                     }
19215                     break;
19216             }
19217             return parseExpressionOrLabeledStatement();
19218         }
19219         function isDeclareModifier(modifier) {
19220             return modifier.kind === 130;
19221         }
19222         function parseDeclaration() {
19223             var modifiers = lookAhead(function () { return (parseDecorators(), parseModifiers()); });
19224             var isAmbient = ts.some(modifiers, isDeclareModifier);
19225             if (isAmbient) {
19226                 var node_3 = tryReuseAmbientDeclaration();
19227                 if (node_3) {
19228                     return node_3;
19229                 }
19230             }
19231             var node = createNodeWithJSDoc(0);
19232             node.decorators = parseDecorators();
19233             node.modifiers = parseModifiers();
19234             if (isAmbient) {
19235                 for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
19236                     var m = _a[_i];
19237                     m.flags |= 8388608;
19238                 }
19239                 return doInsideOfContext(8388608, function () { return parseDeclarationWorker(node); });
19240             }
19241             else {
19242                 return parseDeclarationWorker(node);
19243             }
19244         }
19245         function tryReuseAmbientDeclaration() {
19246             return doInsideOfContext(8388608, function () {
19247                 var node = currentNode(parsingContext);
19248                 if (node) {
19249                     return consumeNode(node);
19250                 }
19251             });
19252         }
19253         function parseDeclarationWorker(node) {
19254             switch (token()) {
19255                 case 109:
19256                 case 115:
19257                 case 81:
19258                     return parseVariableStatement(node);
19259                 case 94:
19260                     return parseFunctionDeclaration(node);
19261                 case 80:
19262                     return parseClassDeclaration(node);
19263                 case 114:
19264                     return parseInterfaceDeclaration(node);
19265                 case 145:
19266                     return parseTypeAliasDeclaration(node);
19267                 case 88:
19268                     return parseEnumDeclaration(node);
19269                 case 150:
19270                 case 135:
19271                 case 136:
19272                     return parseModuleDeclaration(node);
19273                 case 96:
19274                     return parseImportDeclarationOrImportEqualsDeclaration(node);
19275                 case 89:
19276                     nextToken();
19277                     switch (token()) {
19278                         case 84:
19279                         case 62:
19280                             return parseExportAssignment(node);
19281                         case 123:
19282                             return parseNamespaceExportDeclaration(node);
19283                         default:
19284                             return parseExportDeclaration(node);
19285                     }
19286                 default:
19287                     if (node.decorators || node.modifiers) {
19288                         var missing = createMissingNode(264, true, ts.Diagnostics.Declaration_expected);
19289                         missing.pos = node.pos;
19290                         missing.decorators = node.decorators;
19291                         missing.modifiers = node.modifiers;
19292                         return finishNode(missing);
19293                     }
19294                     return undefined;
19295             }
19296         }
19297         function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
19298             nextToken();
19299             return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10);
19300         }
19301         function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) {
19302             if (token() !== 18 && canParseSemicolon()) {
19303                 parseSemicolon();
19304                 return;
19305             }
19306             return parseFunctionBlock(flags, diagnosticMessage);
19307         }
19308         function parseArrayBindingElement() {
19309             if (token() === 27) {
19310                 return createNode(215);
19311             }
19312             var node = createNode(191);
19313             node.dotDotDotToken = parseOptionalToken(25);
19314             node.name = parseIdentifierOrPattern();
19315             node.initializer = parseInitializer();
19316             return finishNode(node);
19317         }
19318         function parseObjectBindingElement() {
19319             var node = createNode(191);
19320             node.dotDotDotToken = parseOptionalToken(25);
19321             var tokenIsIdentifier = isIdentifier();
19322             var propertyName = parsePropertyName();
19323             if (tokenIsIdentifier && token() !== 58) {
19324                 node.name = propertyName;
19325             }
19326             else {
19327                 parseExpected(58);
19328                 node.propertyName = propertyName;
19329                 node.name = parseIdentifierOrPattern();
19330             }
19331             node.initializer = parseInitializer();
19332             return finishNode(node);
19333         }
19334         function parseObjectBindingPattern() {
19335             var node = createNode(189);
19336             parseExpected(18);
19337             node.elements = parseDelimitedList(9, parseObjectBindingElement);
19338             parseExpected(19);
19339             return finishNode(node);
19340         }
19341         function parseArrayBindingPattern() {
19342             var node = createNode(190);
19343             parseExpected(22);
19344             node.elements = parseDelimitedList(10, parseArrayBindingElement);
19345             parseExpected(23);
19346             return finishNode(node);
19347         }
19348         function isIdentifierOrPrivateIdentifierOrPattern() {
19349             return token() === 18
19350                 || token() === 22
19351                 || token() === 76
19352                 || isIdentifier();
19353         }
19354         function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) {
19355             if (token() === 22) {
19356                 return parseArrayBindingPattern();
19357             }
19358             if (token() === 18) {
19359                 return parseObjectBindingPattern();
19360             }
19361             return parseIdentifier(undefined, privateIdentifierDiagnosticMessage);
19362         }
19363         function parseVariableDeclarationAllowExclamation() {
19364             return parseVariableDeclaration(true);
19365         }
19366         function parseVariableDeclaration(allowExclamation) {
19367             var node = createNode(242);
19368             node.name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations);
19369             if (allowExclamation && node.name.kind === 75 &&
19370                 token() === 53 && !scanner.hasPrecedingLineBreak()) {
19371                 node.exclamationToken = parseTokenNode();
19372             }
19373             node.type = parseTypeAnnotation();
19374             if (!isInOrOfKeyword(token())) {
19375                 node.initializer = parseInitializer();
19376             }
19377             return finishNode(node);
19378         }
19379         function parseVariableDeclarationList(inForStatementInitializer) {
19380             var node = createNode(243);
19381             switch (token()) {
19382                 case 109:
19383                     break;
19384                 case 115:
19385                     node.flags |= 1;
19386                     break;
19387                 case 81:
19388                     node.flags |= 2;
19389                     break;
19390                 default:
19391                     ts.Debug.fail();
19392             }
19393             nextToken();
19394             if (token() === 152 && lookAhead(canFollowContextualOfKeyword)) {
19395                 node.declarations = createMissingList();
19396             }
19397             else {
19398                 var savedDisallowIn = inDisallowInContext();
19399                 setDisallowInContext(inForStatementInitializer);
19400                 node.declarations = parseDelimitedList(8, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation);
19401                 setDisallowInContext(savedDisallowIn);
19402             }
19403             return finishNode(node);
19404         }
19405         function canFollowContextualOfKeyword() {
19406             return nextTokenIsIdentifier() && nextToken() === 21;
19407         }
19408         function parseVariableStatement(node) {
19409             node.kind = 225;
19410             node.declarationList = parseVariableDeclarationList(false);
19411             parseSemicolon();
19412             return finishNode(node);
19413         }
19414         function parseFunctionDeclaration(node) {
19415             node.kind = 244;
19416             parseExpected(94);
19417             node.asteriskToken = parseOptionalToken(41);
19418             node.name = hasModifierOfKind(node, 84) ? parseOptionalIdentifier() : parseIdentifier();
19419             var isGenerator = node.asteriskToken ? 1 : 0;
19420             var isAsync = hasModifierOfKind(node, 126) ? 2 : 0;
19421             fillSignature(58, isGenerator | isAsync, node);
19422             node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected);
19423             return finishNode(node);
19424         }
19425         function parseConstructorName() {
19426             if (token() === 129) {
19427                 return parseExpected(129);
19428             }
19429             if (token() === 10 && lookAhead(nextToken) === 20) {
19430                 return tryParse(function () {
19431                     var literalNode = parseLiteralNode();
19432                     return literalNode.text === "constructor" ? literalNode : undefined;
19433                 });
19434             }
19435         }
19436         function tryParseConstructorDeclaration(node) {
19437             return tryParse(function () {
19438                 if (parseConstructorName()) {
19439                     node.kind = 162;
19440                     fillSignature(58, 0, node);
19441                     node.body = parseFunctionBlockOrSemicolon(0, ts.Diagnostics.or_expected);
19442                     return finishNode(node);
19443                 }
19444             });
19445         }
19446         function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) {
19447             node.kind = 161;
19448             node.asteriskToken = asteriskToken;
19449             var isGenerator = asteriskToken ? 1 : 0;
19450             var isAsync = hasModifierOfKind(node, 126) ? 2 : 0;
19451             fillSignature(58, isGenerator | isAsync, node);
19452             node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage);
19453             return finishNode(node);
19454         }
19455         function parsePropertyDeclaration(node) {
19456             node.kind = 159;
19457             if (!node.questionToken && token() === 53 && !scanner.hasPrecedingLineBreak()) {
19458                 node.exclamationToken = parseTokenNode();
19459             }
19460             node.type = parseTypeAnnotation();
19461             node.initializer = doOutsideOfContext(8192 | 32768 | 4096, parseInitializer);
19462             parseSemicolon();
19463             return finishNode(node);
19464         }
19465         function parsePropertyOrMethodDeclaration(node) {
19466             var asteriskToken = parseOptionalToken(41);
19467             node.name = parsePropertyName();
19468             node.questionToken = parseOptionalToken(57);
19469             if (asteriskToken || token() === 20 || token() === 29) {
19470                 return parseMethodDeclaration(node, asteriskToken, ts.Diagnostics.or_expected);
19471             }
19472             return parsePropertyDeclaration(node);
19473         }
19474         function parseAccessorDeclaration(node, kind) {
19475             node.kind = kind;
19476             node.name = parsePropertyName();
19477             fillSignature(58, 0, node);
19478             node.body = parseFunctionBlockOrSemicolon(0);
19479             return finishNode(node);
19480         }
19481         function isClassMemberStart() {
19482             var idToken;
19483             if (token() === 59) {
19484                 return true;
19485             }
19486             while (ts.isModifierKind(token())) {
19487                 idToken = token();
19488                 if (ts.isClassMemberModifier(idToken)) {
19489                     return true;
19490                 }
19491                 nextToken();
19492             }
19493             if (token() === 41) {
19494                 return true;
19495             }
19496             if (isLiteralPropertyName()) {
19497                 idToken = token();
19498                 nextToken();
19499             }
19500             if (token() === 22) {
19501                 return true;
19502             }
19503             if (idToken !== undefined) {
19504                 if (!ts.isKeyword(idToken) || idToken === 142 || idToken === 131) {
19505                     return true;
19506                 }
19507                 switch (token()) {
19508                     case 20:
19509                     case 29:
19510                     case 53:
19511                     case 58:
19512                     case 62:
19513                     case 57:
19514                         return true;
19515                     default:
19516                         return canParseSemicolon();
19517                 }
19518             }
19519             return false;
19520         }
19521         function parseDecorators() {
19522             var list;
19523             var listPos = getNodePos();
19524             while (true) {
19525                 var decoratorStart = getNodePos();
19526                 if (!parseOptional(59)) {
19527                     break;
19528                 }
19529                 var decorator = createNode(157, decoratorStart);
19530                 decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher);
19531                 finishNode(decorator);
19532                 (list || (list = [])).push(decorator);
19533             }
19534             return list && createNodeArray(list, listPos);
19535         }
19536         function parseModifiers(permitInvalidConstAsModifier) {
19537             var list;
19538             var listPos = getNodePos();
19539             while (true) {
19540                 var modifierStart = scanner.getStartPos();
19541                 var modifierKind = token();
19542                 if (token() === 81 && permitInvalidConstAsModifier) {
19543                     if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) {
19544                         break;
19545                     }
19546                 }
19547                 else {
19548                     if (!parseAnyContextualModifier()) {
19549                         break;
19550                     }
19551                 }
19552                 var modifier = finishNode(createNode(modifierKind, modifierStart));
19553                 (list || (list = [])).push(modifier);
19554             }
19555             return list && createNodeArray(list, listPos);
19556         }
19557         function parseModifiersForArrowFunction() {
19558             var modifiers;
19559             if (token() === 126) {
19560                 var modifierStart = scanner.getStartPos();
19561                 var modifierKind = token();
19562                 nextToken();
19563                 var modifier = finishNode(createNode(modifierKind, modifierStart));
19564                 modifiers = createNodeArray([modifier], modifierStart);
19565             }
19566             return modifiers;
19567         }
19568         function parseClassElement() {
19569             if (token() === 26) {
19570                 var result = createNode(222);
19571                 nextToken();
19572                 return finishNode(result);
19573             }
19574             var node = createNodeWithJSDoc(0);
19575             node.decorators = parseDecorators();
19576             node.modifiers = parseModifiers(true);
19577             if (parseContextualModifier(131)) {
19578                 return parseAccessorDeclaration(node, 163);
19579             }
19580             if (parseContextualModifier(142)) {
19581                 return parseAccessorDeclaration(node, 164);
19582             }
19583             if (token() === 129 || token() === 10) {
19584                 var constructorDeclaration = tryParseConstructorDeclaration(node);
19585                 if (constructorDeclaration) {
19586                     return constructorDeclaration;
19587                 }
19588             }
19589             if (isIndexSignature()) {
19590                 return parseIndexSignatureDeclaration(node);
19591             }
19592             if (ts.tokenIsIdentifierOrKeyword(token()) ||
19593                 token() === 10 ||
19594                 token() === 8 ||
19595                 token() === 41 ||
19596                 token() === 22) {
19597                 var isAmbient = node.modifiers && ts.some(node.modifiers, isDeclareModifier);
19598                 if (isAmbient) {
19599                     for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
19600                         var m = _a[_i];
19601                         m.flags |= 8388608;
19602                     }
19603                     return doInsideOfContext(8388608, function () { return parsePropertyOrMethodDeclaration(node); });
19604                 }
19605                 else {
19606                     return parsePropertyOrMethodDeclaration(node);
19607                 }
19608             }
19609             if (node.decorators || node.modifiers) {
19610                 node.name = createMissingNode(75, true, ts.Diagnostics.Declaration_expected);
19611                 return parsePropertyDeclaration(node);
19612             }
19613             return ts.Debug.fail("Should not have attempted to parse class member declaration.");
19614         }
19615         function parseClassExpression() {
19616             return parseClassDeclarationOrExpression(createNodeWithJSDoc(0), 214);
19617         }
19618         function parseClassDeclaration(node) {
19619             return parseClassDeclarationOrExpression(node, 245);
19620         }
19621         function parseClassDeclarationOrExpression(node, kind) {
19622             node.kind = kind;
19623             parseExpected(80);
19624             node.name = parseNameOfClassDeclarationOrExpression();
19625             node.typeParameters = parseTypeParameters();
19626             node.heritageClauses = parseHeritageClauses();
19627             if (parseExpected(18)) {
19628                 node.members = parseClassMembers();
19629                 parseExpected(19);
19630             }
19631             else {
19632                 node.members = createMissingList();
19633             }
19634             return finishNode(node);
19635         }
19636         function parseNameOfClassDeclarationOrExpression() {
19637             return isIdentifier() && !isImplementsClause()
19638                 ? parseIdentifier()
19639                 : undefined;
19640         }
19641         function isImplementsClause() {
19642             return token() === 113 && lookAhead(nextTokenIsIdentifierOrKeyword);
19643         }
19644         function parseHeritageClauses() {
19645             if (isHeritageClause()) {
19646                 return parseList(22, parseHeritageClause);
19647             }
19648             return undefined;
19649         }
19650         function parseHeritageClause() {
19651             var tok = token();
19652             ts.Debug.assert(tok === 90 || tok === 113);
19653             var node = createNode(279);
19654             node.token = tok;
19655             nextToken();
19656             node.types = parseDelimitedList(7, parseExpressionWithTypeArguments);
19657             return finishNode(node);
19658         }
19659         function parseExpressionWithTypeArguments() {
19660             var node = createNode(216);
19661             node.expression = parseLeftHandSideExpressionOrHigher();
19662             node.typeArguments = tryParseTypeArguments();
19663             return finishNode(node);
19664         }
19665         function tryParseTypeArguments() {
19666             return token() === 29 ?
19667                 parseBracketedList(20, parseType, 29, 31) : undefined;
19668         }
19669         function isHeritageClause() {
19670             return token() === 90 || token() === 113;
19671         }
19672         function parseClassMembers() {
19673             return parseList(5, parseClassElement);
19674         }
19675         function parseInterfaceDeclaration(node) {
19676             node.kind = 246;
19677             parseExpected(114);
19678             node.name = parseIdentifier();
19679             node.typeParameters = parseTypeParameters();
19680             node.heritageClauses = parseHeritageClauses();
19681             node.members = parseObjectTypeMembers();
19682             return finishNode(node);
19683         }
19684         function parseTypeAliasDeclaration(node) {
19685             node.kind = 247;
19686             parseExpected(145);
19687             node.name = parseIdentifier();
19688             node.typeParameters = parseTypeParameters();
19689             parseExpected(62);
19690             node.type = parseType();
19691             parseSemicolon();
19692             return finishNode(node);
19693         }
19694         function parseEnumMember() {
19695             var node = createNodeWithJSDoc(284);
19696             node.name = parsePropertyName();
19697             node.initializer = allowInAnd(parseInitializer);
19698             return finishNode(node);
19699         }
19700         function parseEnumDeclaration(node) {
19701             node.kind = 248;
19702             parseExpected(88);
19703             node.name = parseIdentifier();
19704             if (parseExpected(18)) {
19705                 node.members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6, parseEnumMember); });
19706                 parseExpected(19);
19707             }
19708             else {
19709                 node.members = createMissingList();
19710             }
19711             return finishNode(node);
19712         }
19713         function parseModuleBlock() {
19714             var node = createNode(250);
19715             if (parseExpected(18)) {
19716                 node.statements = parseList(1, parseStatement);
19717                 parseExpected(19);
19718             }
19719             else {
19720                 node.statements = createMissingList();
19721             }
19722             return finishNode(node);
19723         }
19724         function parseModuleOrNamespaceDeclaration(node, flags) {
19725             node.kind = 249;
19726             var namespaceFlag = flags & 16;
19727             node.flags |= flags;
19728             node.name = parseIdentifier();
19729             node.body = parseOptional(24)
19730                 ? parseModuleOrNamespaceDeclaration(createNode(0), 4 | namespaceFlag)
19731                 : parseModuleBlock();
19732             return finishNode(node);
19733         }
19734         function parseAmbientExternalModuleDeclaration(node) {
19735             node.kind = 249;
19736             if (token() === 150) {
19737                 node.name = parseIdentifier();
19738                 node.flags |= 1024;
19739             }
19740             else {
19741                 node.name = parseLiteralNode();
19742                 node.name.text = internIdentifier(node.name.text);
19743             }
19744             if (token() === 18) {
19745                 node.body = parseModuleBlock();
19746             }
19747             else {
19748                 parseSemicolon();
19749             }
19750             return finishNode(node);
19751         }
19752         function parseModuleDeclaration(node) {
19753             var flags = 0;
19754             if (token() === 150) {
19755                 return parseAmbientExternalModuleDeclaration(node);
19756             }
19757             else if (parseOptional(136)) {
19758                 flags |= 16;
19759             }
19760             else {
19761                 parseExpected(135);
19762                 if (token() === 10) {
19763                     return parseAmbientExternalModuleDeclaration(node);
19764                 }
19765             }
19766             return parseModuleOrNamespaceDeclaration(node, flags);
19767         }
19768         function isExternalModuleReference() {
19769             return token() === 139 &&
19770                 lookAhead(nextTokenIsOpenParen);
19771         }
19772         function nextTokenIsOpenParen() {
19773             return nextToken() === 20;
19774         }
19775         function nextTokenIsSlash() {
19776             return nextToken() === 43;
19777         }
19778         function parseNamespaceExportDeclaration(node) {
19779             node.kind = 252;
19780             parseExpected(123);
19781             parseExpected(136);
19782             node.name = parseIdentifier();
19783             parseSemicolon();
19784             return finishNode(node);
19785         }
19786         function parseImportDeclarationOrImportEqualsDeclaration(node) {
19787             parseExpected(96);
19788             var afterImportPos = scanner.getStartPos();
19789             var identifier;
19790             if (isIdentifier()) {
19791                 identifier = parseIdentifier();
19792             }
19793             var isTypeOnly = false;
19794             if (token() !== 149 &&
19795                 (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" &&
19796                 (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
19797                 isTypeOnly = true;
19798                 identifier = isIdentifier() ? parseIdentifier() : undefined;
19799             }
19800             if (identifier && !tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration()) {
19801                 return parseImportEqualsDeclaration(node, identifier, isTypeOnly);
19802             }
19803             node.kind = 254;
19804             if (identifier ||
19805                 token() === 41 ||
19806                 token() === 18) {
19807                 node.importClause = parseImportClause(identifier, afterImportPos, isTypeOnly);
19808                 parseExpected(149);
19809             }
19810             node.moduleSpecifier = parseModuleSpecifier();
19811             parseSemicolon();
19812             return finishNode(node);
19813         }
19814         function tokenAfterImportDefinitelyProducesImportDeclaration() {
19815             return token() === 41 || token() === 18;
19816         }
19817         function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() {
19818             return token() === 27 || token() === 149;
19819         }
19820         function parseImportEqualsDeclaration(node, identifier, isTypeOnly) {
19821             node.kind = 253;
19822             node.name = identifier;
19823             parseExpected(62);
19824             node.moduleReference = parseModuleReference();
19825             parseSemicolon();
19826             var finished = finishNode(node);
19827             if (isTypeOnly) {
19828                 parseErrorAtRange(finished, ts.Diagnostics.Only_ECMAScript_imports_may_use_import_type);
19829             }
19830             return finished;
19831         }
19832         function parseImportClause(identifier, fullStart, isTypeOnly) {
19833             var importClause = createNode(255, fullStart);
19834             importClause.isTypeOnly = isTypeOnly;
19835             if (identifier) {
19836                 importClause.name = identifier;
19837             }
19838             if (!importClause.name ||
19839                 parseOptional(27)) {
19840                 importClause.namedBindings = token() === 41 ? parseNamespaceImport() : parseNamedImportsOrExports(257);
19841             }
19842             return finishNode(importClause);
19843         }
19844         function parseModuleReference() {
19845             return isExternalModuleReference()
19846                 ? parseExternalModuleReference()
19847                 : parseEntityName(false);
19848         }
19849         function parseExternalModuleReference() {
19850             var node = createNode(265);
19851             parseExpected(139);
19852             parseExpected(20);
19853             node.expression = parseModuleSpecifier();
19854             parseExpected(21);
19855             return finishNode(node);
19856         }
19857         function parseModuleSpecifier() {
19858             if (token() === 10) {
19859                 var result = parseLiteralNode();
19860                 result.text = internIdentifier(result.text);
19861                 return result;
19862             }
19863             else {
19864                 return parseExpression();
19865             }
19866         }
19867         function parseNamespaceImport() {
19868             var namespaceImport = createNode(256);
19869             parseExpected(41);
19870             parseExpected(123);
19871             namespaceImport.name = parseIdentifier();
19872             return finishNode(namespaceImport);
19873         }
19874         function parseNamedImportsOrExports(kind) {
19875             var node = createNode(kind);
19876             node.elements = parseBracketedList(23, kind === 257 ? parseImportSpecifier : parseExportSpecifier, 18, 19);
19877             return finishNode(node);
19878         }
19879         function parseExportSpecifier() {
19880             return parseImportOrExportSpecifier(263);
19881         }
19882         function parseImportSpecifier() {
19883             return parseImportOrExportSpecifier(258);
19884         }
19885         function parseImportOrExportSpecifier(kind) {
19886             var node = createNode(kind);
19887             var checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier();
19888             var checkIdentifierStart = scanner.getTokenPos();
19889             var checkIdentifierEnd = scanner.getTextPos();
19890             var identifierName = parseIdentifierName();
19891             if (token() === 123) {
19892                 node.propertyName = identifierName;
19893                 parseExpected(123);
19894                 checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier();
19895                 checkIdentifierStart = scanner.getTokenPos();
19896                 checkIdentifierEnd = scanner.getTextPos();
19897                 node.name = parseIdentifierName();
19898             }
19899             else {
19900                 node.name = identifierName;
19901             }
19902             if (kind === 258 && checkIdentifierIsKeyword) {
19903                 parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected);
19904             }
19905             return finishNode(node);
19906         }
19907         function parseNamespaceExport(pos) {
19908             var node = createNode(262, pos);
19909             node.name = parseIdentifier();
19910             return finishNode(node);
19911         }
19912         function parseExportDeclaration(node) {
19913             node.kind = 260;
19914             node.isTypeOnly = parseOptional(145);
19915             var namespaceExportPos = scanner.getStartPos();
19916             if (parseOptional(41)) {
19917                 if (parseOptional(123)) {
19918                     node.exportClause = parseNamespaceExport(namespaceExportPos);
19919                 }
19920                 parseExpected(149);
19921                 node.moduleSpecifier = parseModuleSpecifier();
19922             }
19923             else {
19924                 node.exportClause = parseNamedImportsOrExports(261);
19925                 if (token() === 149 || (token() === 10 && !scanner.hasPrecedingLineBreak())) {
19926                     parseExpected(149);
19927                     node.moduleSpecifier = parseModuleSpecifier();
19928                 }
19929             }
19930             parseSemicolon();
19931             return finishNode(node);
19932         }
19933         function parseExportAssignment(node) {
19934             node.kind = 259;
19935             if (parseOptional(62)) {
19936                 node.isExportEquals = true;
19937             }
19938             else {
19939                 parseExpected(84);
19940             }
19941             node.expression = parseAssignmentExpressionOrHigher();
19942             parseSemicolon();
19943             return finishNode(node);
19944         }
19945         function setExternalModuleIndicator(sourceFile) {
19946             sourceFile.externalModuleIndicator =
19947                 ts.forEach(sourceFile.statements, isAnExternalModuleIndicatorNode) ||
19948                     getImportMetaIfNecessary(sourceFile);
19949         }
19950         function isAnExternalModuleIndicatorNode(node) {
19951             return hasModifierOfKind(node, 89)
19952                 || node.kind === 253 && node.moduleReference.kind === 265
19953                 || node.kind === 254
19954                 || node.kind === 259
19955                 || node.kind === 260 ? node : undefined;
19956         }
19957         function getImportMetaIfNecessary(sourceFile) {
19958             return sourceFile.flags & 2097152 ?
19959                 walkTreeForExternalModuleIndicators(sourceFile) :
19960                 undefined;
19961         }
19962         function walkTreeForExternalModuleIndicators(node) {
19963             return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators);
19964         }
19965         function hasModifierOfKind(node, kind) {
19966             return ts.some(node.modifiers, function (m) { return m.kind === kind; });
19967         }
19968         function isImportMeta(node) {
19969             return ts.isMetaProperty(node) && node.keywordToken === 96 && node.name.escapedText === "meta";
19970         }
19971         var JSDocParser;
19972         (function (JSDocParser) {
19973             function parseJSDocTypeExpressionForTests(content, start, length) {
19974                 initializeState(content, 99, undefined, 1);
19975                 sourceFile = createSourceFile("file.js", 99, 1, false);
19976                 scanner.setText(content, start, length);
19977                 currentToken = scanner.scan();
19978                 var jsDocTypeExpression = parseJSDocTypeExpression();
19979                 var diagnostics = parseDiagnostics;
19980                 clearState();
19981                 return jsDocTypeExpression ? { jsDocTypeExpression: jsDocTypeExpression, diagnostics: diagnostics } : undefined;
19982             }
19983             JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests;
19984             function parseJSDocTypeExpression(mayOmitBraces) {
19985                 var result = createNode(294);
19986                 var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18);
19987                 result.type = doInsideOfContext(4194304, parseJSDocType);
19988                 if (!mayOmitBraces || hasBrace) {
19989                     parseExpectedJSDoc(19);
19990                 }
19991                 fixupParentReferences(result);
19992                 return finishNode(result);
19993             }
19994             JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression;
19995             function parseIsolatedJSDocComment(content, start, length) {
19996                 initializeState(content, 99, undefined, 1);
19997                 sourceFile = { languageVariant: 0, text: content };
19998                 var jsDoc = doInsideOfContext(4194304, function () { return parseJSDocCommentWorker(start, length); });
19999                 var diagnostics = parseDiagnostics;
20000                 clearState();
20001                 return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined;
20002             }
20003             JSDocParser.parseIsolatedJSDocComment = parseIsolatedJSDocComment;
20004             function parseJSDocComment(parent, start, length) {
20005                 var _a;
20006                 var saveToken = currentToken;
20007                 var saveParseDiagnosticsLength = parseDiagnostics.length;
20008                 var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
20009                 var comment = doInsideOfContext(4194304, function () { return parseJSDocCommentWorker(start, length); });
20010                 if (comment) {
20011                     comment.parent = parent;
20012                 }
20013                 if (contextFlags & 131072) {
20014                     if (!sourceFile.jsDocDiagnostics) {
20015                         sourceFile.jsDocDiagnostics = [];
20016                     }
20017                     (_a = sourceFile.jsDocDiagnostics).push.apply(_a, parseDiagnostics);
20018                 }
20019                 currentToken = saveToken;
20020                 parseDiagnostics.length = saveParseDiagnosticsLength;
20021                 parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode;
20022                 return comment;
20023             }
20024             JSDocParser.parseJSDocComment = parseJSDocComment;
20025             function parseJSDocCommentWorker(start, length) {
20026                 if (start === void 0) { start = 0; }
20027                 var content = sourceText;
20028                 var end = length === undefined ? content.length : start + length;
20029                 length = end - start;
20030                 ts.Debug.assert(start >= 0);
20031                 ts.Debug.assert(start <= end);
20032                 ts.Debug.assert(end <= content.length);
20033                 if (!isJSDocLikeText(content, start)) {
20034                     return undefined;
20035                 }
20036                 var tags;
20037                 var tagsPos;
20038                 var tagsEnd;
20039                 var comments = [];
20040                 return scanner.scanRange(start + 3, length - 5, function () {
20041                     var state = 1;
20042                     var margin;
20043                     var indent = start - Math.max(content.lastIndexOf("\n", start), 0) + 4;
20044                     function pushComment(text) {
20045                         if (!margin) {
20046                             margin = indent;
20047                         }
20048                         comments.push(text);
20049                         indent += text.length;
20050                     }
20051                     nextTokenJSDoc();
20052                     while (parseOptionalJsdoc(5))
20053                         ;
20054                     if (parseOptionalJsdoc(4)) {
20055                         state = 0;
20056                         indent = 0;
20057                     }
20058                     loop: while (true) {
20059                         switch (token()) {
20060                             case 59:
20061                                 if (state === 0 || state === 1) {
20062                                     removeTrailingWhitespace(comments);
20063                                     addTag(parseTag(indent));
20064                                     state = 0;
20065                                     margin = undefined;
20066                                 }
20067                                 else {
20068                                     pushComment(scanner.getTokenText());
20069                                 }
20070                                 break;
20071                             case 4:
20072                                 comments.push(scanner.getTokenText());
20073                                 state = 0;
20074                                 indent = 0;
20075                                 break;
20076                             case 41:
20077                                 var asterisk = scanner.getTokenText();
20078                                 if (state === 1 || state === 2) {
20079                                     state = 2;
20080                                     pushComment(asterisk);
20081                                 }
20082                                 else {
20083                                     state = 1;
20084                                     indent += asterisk.length;
20085                                 }
20086                                 break;
20087                             case 5:
20088                                 var whitespace = scanner.getTokenText();
20089                                 if (state === 2) {
20090                                     comments.push(whitespace);
20091                                 }
20092                                 else if (margin !== undefined && indent + whitespace.length > margin) {
20093                                     comments.push(whitespace.slice(margin - indent - 1));
20094                                 }
20095                                 indent += whitespace.length;
20096                                 break;
20097                             case 1:
20098                                 break loop;
20099                             default:
20100                                 state = 2;
20101                                 pushComment(scanner.getTokenText());
20102                                 break;
20103                         }
20104                         nextTokenJSDoc();
20105                     }
20106                     removeLeadingNewlines(comments);
20107                     removeTrailingWhitespace(comments);
20108                     return createJSDocComment();
20109                 });
20110                 function removeLeadingNewlines(comments) {
20111                     while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) {
20112                         comments.shift();
20113                     }
20114                 }
20115                 function removeTrailingWhitespace(comments) {
20116                     while (comments.length && comments[comments.length - 1].trim() === "") {
20117                         comments.pop();
20118                     }
20119                 }
20120                 function createJSDocComment() {
20121                     var result = createNode(303, start);
20122                     result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd);
20123                     result.comment = comments.length ? comments.join("") : undefined;
20124                     return finishNode(result, end);
20125                 }
20126                 function isNextNonwhitespaceTokenEndOfFile() {
20127                     while (true) {
20128                         nextTokenJSDoc();
20129                         if (token() === 1) {
20130                             return true;
20131                         }
20132                         if (!(token() === 5 || token() === 4)) {
20133                             return false;
20134                         }
20135                     }
20136                 }
20137                 function skipWhitespace() {
20138                     if (token() === 5 || token() === 4) {
20139                         if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) {
20140                             return;
20141                         }
20142                     }
20143                     while (token() === 5 || token() === 4) {
20144                         nextTokenJSDoc();
20145                     }
20146                 }
20147                 function skipWhitespaceOrAsterisk() {
20148                     if (token() === 5 || token() === 4) {
20149                         if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) {
20150                             return "";
20151                         }
20152                     }
20153                     var precedingLineBreak = scanner.hasPrecedingLineBreak();
20154                     var seenLineBreak = false;
20155                     var indentText = "";
20156                     while ((precedingLineBreak && token() === 41) || token() === 5 || token() === 4) {
20157                         indentText += scanner.getTokenText();
20158                         if (token() === 4) {
20159                             precedingLineBreak = true;
20160                             seenLineBreak = true;
20161                             indentText = "";
20162                         }
20163                         else if (token() === 41) {
20164                             precedingLineBreak = false;
20165                         }
20166                         nextTokenJSDoc();
20167                     }
20168                     return seenLineBreak ? indentText : "";
20169                 }
20170                 function parseTag(margin) {
20171                     ts.Debug.assert(token() === 59);
20172                     var start = scanner.getTokenPos();
20173                     nextTokenJSDoc();
20174                     var tagName = parseJSDocIdentifierName(undefined);
20175                     var indentText = skipWhitespaceOrAsterisk();
20176                     var tag;
20177                     switch (tagName.escapedText) {
20178                         case "author":
20179                             tag = parseAuthorTag(start, tagName, margin);
20180                             break;
20181                         case "implements":
20182                             tag = parseImplementsTag(start, tagName);
20183                             break;
20184                         case "augments":
20185                         case "extends":
20186                             tag = parseAugmentsTag(start, tagName);
20187                             break;
20188                         case "class":
20189                         case "constructor":
20190                             tag = parseSimpleTag(start, 310, tagName);
20191                             break;
20192                         case "public":
20193                             tag = parseSimpleTag(start, 311, tagName);
20194                             break;
20195                         case "private":
20196                             tag = parseSimpleTag(start, 312, tagName);
20197                             break;
20198                         case "protected":
20199                             tag = parseSimpleTag(start, 313, tagName);
20200                             break;
20201                         case "readonly":
20202                             tag = parseSimpleTag(start, 314, tagName);
20203                             break;
20204                         case "this":
20205                             tag = parseThisTag(start, tagName);
20206                             break;
20207                         case "enum":
20208                             tag = parseEnumTag(start, tagName);
20209                             break;
20210                         case "arg":
20211                         case "argument":
20212                         case "param":
20213                             return parseParameterOrPropertyTag(start, tagName, 2, margin);
20214                         case "return":
20215                         case "returns":
20216                             tag = parseReturnTag(start, tagName);
20217                             break;
20218                         case "template":
20219                             tag = parseTemplateTag(start, tagName);
20220                             break;
20221                         case "type":
20222                             tag = parseTypeTag(start, tagName);
20223                             break;
20224                         case "typedef":
20225                             tag = parseTypedefTag(start, tagName, margin);
20226                             break;
20227                         case "callback":
20228                             tag = parseCallbackTag(start, tagName, margin);
20229                             break;
20230                         default:
20231                             tag = parseUnknownTag(start, tagName);
20232                             break;
20233                     }
20234                     if (!tag.comment) {
20235                         if (!indentText) {
20236                             margin += tag.end - tag.pos;
20237                         }
20238                         tag.comment = parseTagComments(margin, indentText.slice(margin));
20239                     }
20240                     return tag;
20241                 }
20242                 function parseTagComments(indent, initialMargin) {
20243                     var comments = [];
20244                     var state = 0;
20245                     var margin;
20246                     function pushComment(text) {
20247                         if (!margin) {
20248                             margin = indent;
20249                         }
20250                         comments.push(text);
20251                         indent += text.length;
20252                     }
20253                     if (initialMargin !== undefined) {
20254                         if (initialMargin !== "") {
20255                             pushComment(initialMargin);
20256                         }
20257                         state = 1;
20258                     }
20259                     var tok = token();
20260                     loop: while (true) {
20261                         switch (tok) {
20262                             case 4:
20263                                 if (state >= 1) {
20264                                     state = 0;
20265                                     comments.push(scanner.getTokenText());
20266                                 }
20267                                 indent = 0;
20268                                 break;
20269                             case 59:
20270                                 if (state === 3) {
20271                                     comments.push(scanner.getTokenText());
20272                                     break;
20273                                 }
20274                                 scanner.setTextPos(scanner.getTextPos() - 1);
20275                             case 1:
20276                                 break loop;
20277                             case 5:
20278                                 if (state === 2 || state === 3) {
20279                                     pushComment(scanner.getTokenText());
20280                                 }
20281                                 else {
20282                                     var whitespace = scanner.getTokenText();
20283                                     if (margin !== undefined && indent + whitespace.length > margin) {
20284                                         comments.push(whitespace.slice(margin - indent));
20285                                     }
20286                                     indent += whitespace.length;
20287                                 }
20288                                 break;
20289                             case 18:
20290                                 state = 2;
20291                                 if (lookAhead(function () { return nextTokenJSDoc() === 59 && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) {
20292                                     pushComment(scanner.getTokenText());
20293                                     nextTokenJSDoc();
20294                                     pushComment(scanner.getTokenText());
20295                                     nextTokenJSDoc();
20296                                 }
20297                                 pushComment(scanner.getTokenText());
20298                                 break;
20299                             case 61:
20300                                 if (state === 3) {
20301                                     state = 2;
20302                                 }
20303                                 else {
20304                                     state = 3;
20305                                 }
20306                                 pushComment(scanner.getTokenText());
20307                                 break;
20308                             case 41:
20309                                 if (state === 0) {
20310                                     state = 1;
20311                                     indent += 1;
20312                                     break;
20313                                 }
20314                             default:
20315                                 if (state !== 3) {
20316                                     state = 2;
20317                                 }
20318                                 pushComment(scanner.getTokenText());
20319                                 break;
20320                         }
20321                         tok = nextTokenJSDoc();
20322                     }
20323                     removeLeadingNewlines(comments);
20324                     removeTrailingWhitespace(comments);
20325                     return comments.length === 0 ? undefined : comments.join("");
20326                 }
20327                 function parseUnknownTag(start, tagName) {
20328                     var result = createNode(306, start);
20329                     result.tagName = tagName;
20330                     return finishNode(result);
20331                 }
20332                 function addTag(tag) {
20333                     if (!tag) {
20334                         return;
20335                     }
20336                     if (!tags) {
20337                         tags = [tag];
20338                         tagsPos = tag.pos;
20339                     }
20340                     else {
20341                         tags.push(tag);
20342                     }
20343                     tagsEnd = tag.end;
20344                 }
20345                 function tryParseTypeExpression() {
20346                     skipWhitespaceOrAsterisk();
20347                     return token() === 18 ? parseJSDocTypeExpression() : undefined;
20348                 }
20349                 function parseBracketNameInPropertyAndParamTag() {
20350                     var isBracketed = parseOptionalJsdoc(22);
20351                     if (isBracketed) {
20352                         skipWhitespace();
20353                     }
20354                     var isBackquoted = parseOptionalJsdoc(61);
20355                     var name = parseJSDocEntityName();
20356                     if (isBackquoted) {
20357                         parseExpectedTokenJSDoc(61);
20358                     }
20359                     if (isBracketed) {
20360                         skipWhitespace();
20361                         if (parseOptionalToken(62)) {
20362                             parseExpression();
20363                         }
20364                         parseExpected(23);
20365                     }
20366                     return { name: name, isBracketed: isBracketed };
20367                 }
20368                 function isObjectOrObjectArrayTypeReference(node) {
20369                     switch (node.kind) {
20370                         case 141:
20371                             return true;
20372                         case 174:
20373                             return isObjectOrObjectArrayTypeReference(node.elementType);
20374                         default:
20375                             return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments;
20376                     }
20377                 }
20378                 function parseParameterOrPropertyTag(start, tagName, target, indent) {
20379                     var typeExpression = tryParseTypeExpression();
20380                     var isNameFirst = !typeExpression;
20381                     skipWhitespaceOrAsterisk();
20382                     var _a = parseBracketNameInPropertyAndParamTag(), name = _a.name, isBracketed = _a.isBracketed;
20383                     skipWhitespace();
20384                     if (isNameFirst) {
20385                         typeExpression = tryParseTypeExpression();
20386                     }
20387                     var result = target === 1 ?
20388                         createNode(323, start) :
20389                         createNode(317, start);
20390                     var comment = parseTagComments(indent + scanner.getStartPos() - start);
20391                     var nestedTypeLiteral = target !== 4 && parseNestedTypeLiteral(typeExpression, name, target, indent);
20392                     if (nestedTypeLiteral) {
20393                         typeExpression = nestedTypeLiteral;
20394                         isNameFirst = true;
20395                     }
20396                     result.tagName = tagName;
20397                     result.typeExpression = typeExpression;
20398                     result.name = name;
20399                     result.isNameFirst = isNameFirst;
20400                     result.isBracketed = isBracketed;
20401                     result.comment = comment;
20402                     return finishNode(result);
20403                 }
20404                 function parseNestedTypeLiteral(typeExpression, name, target, indent) {
20405                     if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) {
20406                         var typeLiteralExpression = createNode(294, scanner.getTokenPos());
20407                         var child = void 0;
20408                         var jsdocTypeLiteral = void 0;
20409                         var start_3 = scanner.getStartPos();
20410                         var children = void 0;
20411                         while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) {
20412                             if (child.kind === 317 || child.kind === 323) {
20413                                 children = ts.append(children, child);
20414                             }
20415                         }
20416                         if (children) {
20417                             jsdocTypeLiteral = createNode(304, start_3);
20418                             jsdocTypeLiteral.jsDocPropertyTags = children;
20419                             if (typeExpression.type.kind === 174) {
20420                                 jsdocTypeLiteral.isArrayType = true;
20421                             }
20422                             typeLiteralExpression.type = finishNode(jsdocTypeLiteral);
20423                             return finishNode(typeLiteralExpression);
20424                         }
20425                     }
20426                 }
20427                 function parseReturnTag(start, tagName) {
20428                     if (ts.some(tags, ts.isJSDocReturnTag)) {
20429                         parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
20430                     }
20431                     var result = createNode(318, start);
20432                     result.tagName = tagName;
20433                     result.typeExpression = tryParseTypeExpression();
20434                     return finishNode(result);
20435                 }
20436                 function parseTypeTag(start, tagName) {
20437                     if (ts.some(tags, ts.isJSDocTypeTag)) {
20438                         parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
20439                     }
20440                     var result = createNode(320, start);
20441                     result.tagName = tagName;
20442                     result.typeExpression = parseJSDocTypeExpression(true);
20443                     return finishNode(result);
20444                 }
20445                 function parseAuthorTag(start, tagName, indent) {
20446                     var result = createNode(309, start);
20447                     result.tagName = tagName;
20448                     var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); });
20449                     if (!authorInfoWithEmail) {
20450                         return finishNode(result);
20451                     }
20452                     result.comment = authorInfoWithEmail;
20453                     if (lookAhead(function () { return nextToken() !== 4; })) {
20454                         var comment = parseTagComments(indent);
20455                         if (comment) {
20456                             result.comment += comment;
20457                         }
20458                     }
20459                     return finishNode(result);
20460                 }
20461                 function tryParseAuthorNameAndEmail() {
20462                     var comments = [];
20463                     var seenLessThan = false;
20464                     var seenGreaterThan = false;
20465                     var token = scanner.getToken();
20466                     loop: while (true) {
20467                         switch (token) {
20468                             case 75:
20469                             case 5:
20470                             case 24:
20471                             case 59:
20472                                 comments.push(scanner.getTokenText());
20473                                 break;
20474                             case 29:
20475                                 if (seenLessThan || seenGreaterThan) {
20476                                     return;
20477                                 }
20478                                 seenLessThan = true;
20479                                 comments.push(scanner.getTokenText());
20480                                 break;
20481                             case 31:
20482                                 if (!seenLessThan || seenGreaterThan) {
20483                                     return;
20484                                 }
20485                                 seenGreaterThan = true;
20486                                 comments.push(scanner.getTokenText());
20487                                 scanner.setTextPos(scanner.getTokenPos() + 1);
20488                                 break loop;
20489                             case 4:
20490                             case 1:
20491                                 break loop;
20492                         }
20493                         token = nextTokenJSDoc();
20494                     }
20495                     if (seenLessThan && seenGreaterThan) {
20496                         return comments.length === 0 ? undefined : comments.join("");
20497                     }
20498                 }
20499                 function parseImplementsTag(start, tagName) {
20500                     var result = createNode(308, start);
20501                     result.tagName = tagName;
20502                     result.class = parseExpressionWithTypeArgumentsForAugments();
20503                     return finishNode(result);
20504                 }
20505                 function parseAugmentsTag(start, tagName) {
20506                     var result = createNode(307, start);
20507                     result.tagName = tagName;
20508                     result.class = parseExpressionWithTypeArgumentsForAugments();
20509                     return finishNode(result);
20510                 }
20511                 function parseExpressionWithTypeArgumentsForAugments() {
20512                     var usedBrace = parseOptional(18);
20513                     var node = createNode(216);
20514                     node.expression = parsePropertyAccessEntityNameExpression();
20515                     node.typeArguments = tryParseTypeArguments();
20516                     var res = finishNode(node);
20517                     if (usedBrace) {
20518                         parseExpected(19);
20519                     }
20520                     return res;
20521                 }
20522                 function parsePropertyAccessEntityNameExpression() {
20523                     var node = parseJSDocIdentifierName();
20524                     while (parseOptional(24)) {
20525                         var prop = createNode(194, node.pos);
20526                         prop.expression = node;
20527                         prop.name = parseJSDocIdentifierName();
20528                         node = finishNode(prop);
20529                     }
20530                     return node;
20531                 }
20532                 function parseSimpleTag(start, kind, tagName) {
20533                     var tag = createNode(kind, start);
20534                     tag.tagName = tagName;
20535                     return finishNode(tag);
20536                 }
20537                 function parseThisTag(start, tagName) {
20538                     var tag = createNode(319, start);
20539                     tag.tagName = tagName;
20540                     tag.typeExpression = parseJSDocTypeExpression(true);
20541                     skipWhitespace();
20542                     return finishNode(tag);
20543                 }
20544                 function parseEnumTag(start, tagName) {
20545                     var tag = createNode(316, start);
20546                     tag.tagName = tagName;
20547                     tag.typeExpression = parseJSDocTypeExpression(true);
20548                     skipWhitespace();
20549                     return finishNode(tag);
20550                 }
20551                 function parseTypedefTag(start, tagName, indent) {
20552                     var typeExpression = tryParseTypeExpression();
20553                     skipWhitespaceOrAsterisk();
20554                     var typedefTag = createNode(322, start);
20555                     typedefTag.tagName = tagName;
20556                     typedefTag.fullName = parseJSDocTypeNameWithNamespace();
20557                     typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName);
20558                     skipWhitespace();
20559                     typedefTag.comment = parseTagComments(indent);
20560                     typedefTag.typeExpression = typeExpression;
20561                     var end;
20562                     if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) {
20563                         var child = void 0;
20564                         var jsdocTypeLiteral = void 0;
20565                         var childTypeTag = void 0;
20566                         while (child = tryParse(function () { return parseChildPropertyTag(indent); })) {
20567                             if (!jsdocTypeLiteral) {
20568                                 jsdocTypeLiteral = createNode(304, start);
20569                             }
20570                             if (child.kind === 320) {
20571                                 if (childTypeTag) {
20572                                     break;
20573                                 }
20574                                 else {
20575                                     childTypeTag = child;
20576                                 }
20577                             }
20578                             else {
20579                                 jsdocTypeLiteral.jsDocPropertyTags = ts.append(jsdocTypeLiteral.jsDocPropertyTags, child);
20580                             }
20581                         }
20582                         if (jsdocTypeLiteral) {
20583                             if (typeExpression && typeExpression.type.kind === 174) {
20584                                 jsdocTypeLiteral.isArrayType = true;
20585                             }
20586                             typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ?
20587                                 childTypeTag.typeExpression :
20588                                 finishNode(jsdocTypeLiteral);
20589                             end = typedefTag.typeExpression.end;
20590                         }
20591                     }
20592                     return finishNode(typedefTag, end || typedefTag.comment !== undefined ? scanner.getStartPos() : (typedefTag.fullName || typedefTag.typeExpression || typedefTag.tagName).end);
20593                 }
20594                 function parseJSDocTypeNameWithNamespace(nested) {
20595                     var pos = scanner.getTokenPos();
20596                     if (!ts.tokenIsIdentifierOrKeyword(token())) {
20597                         return undefined;
20598                     }
20599                     var typeNameOrNamespaceName = parseJSDocIdentifierName();
20600                     if (parseOptional(24)) {
20601                         var jsDocNamespaceNode = createNode(249, pos);
20602                         if (nested) {
20603                             jsDocNamespaceNode.flags |= 4;
20604                         }
20605                         jsDocNamespaceNode.name = typeNameOrNamespaceName;
20606                         jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(true);
20607                         return finishNode(jsDocNamespaceNode);
20608                     }
20609                     if (nested) {
20610                         typeNameOrNamespaceName.isInJSDocNamespace = true;
20611                     }
20612                     return typeNameOrNamespaceName;
20613                 }
20614                 function parseCallbackTag(start, tagName, indent) {
20615                     var callbackTag = createNode(315, start);
20616                     callbackTag.tagName = tagName;
20617                     callbackTag.fullName = parseJSDocTypeNameWithNamespace();
20618                     callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName);
20619                     skipWhitespace();
20620                     callbackTag.comment = parseTagComments(indent);
20621                     var child;
20622                     var jsdocSignature = createNode(305, start);
20623                     jsdocSignature.parameters = [];
20624                     while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4, indent); })) {
20625                         jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child);
20626                     }
20627                     var returnTag = tryParse(function () {
20628                         if (parseOptionalJsdoc(59)) {
20629                             var tag = parseTag(indent);
20630                             if (tag && tag.kind === 318) {
20631                                 return tag;
20632                             }
20633                         }
20634                     });
20635                     if (returnTag) {
20636                         jsdocSignature.type = returnTag;
20637                     }
20638                     callbackTag.typeExpression = finishNode(jsdocSignature);
20639                     return finishNode(callbackTag);
20640                 }
20641                 function getJSDocTypeAliasName(fullName) {
20642                     if (fullName) {
20643                         var rightNode = fullName;
20644                         while (true) {
20645                             if (ts.isIdentifier(rightNode) || !rightNode.body) {
20646                                 return ts.isIdentifier(rightNode) ? rightNode : rightNode.name;
20647                             }
20648                             rightNode = rightNode.body;
20649                         }
20650                     }
20651                 }
20652                 function escapedTextsEqual(a, b) {
20653                     while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) {
20654                         if (!ts.isIdentifier(a) && !ts.isIdentifier(b) && a.right.escapedText === b.right.escapedText) {
20655                             a = a.left;
20656                             b = b.left;
20657                         }
20658                         else {
20659                             return false;
20660                         }
20661                     }
20662                     return a.escapedText === b.escapedText;
20663                 }
20664                 function parseChildPropertyTag(indent) {
20665                     return parseChildParameterOrPropertyTag(1, indent);
20666                 }
20667                 function parseChildParameterOrPropertyTag(target, indent, name) {
20668                     var canParseTag = true;
20669                     var seenAsterisk = false;
20670                     while (true) {
20671                         switch (nextTokenJSDoc()) {
20672                             case 59:
20673                                 if (canParseTag) {
20674                                     var child = tryParseChildTag(target, indent);
20675                                     if (child && (child.kind === 317 || child.kind === 323) &&
20676                                         target !== 4 &&
20677                                         name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) {
20678                                         return false;
20679                                     }
20680                                     return child;
20681                                 }
20682                                 seenAsterisk = false;
20683                                 break;
20684                             case 4:
20685                                 canParseTag = true;
20686                                 seenAsterisk = false;
20687                                 break;
20688                             case 41:
20689                                 if (seenAsterisk) {
20690                                     canParseTag = false;
20691                                 }
20692                                 seenAsterisk = true;
20693                                 break;
20694                             case 75:
20695                                 canParseTag = false;
20696                                 break;
20697                             case 1:
20698                                 return false;
20699                         }
20700                     }
20701                 }
20702                 function tryParseChildTag(target, indent) {
20703                     ts.Debug.assert(token() === 59);
20704                     var start = scanner.getStartPos();
20705                     nextTokenJSDoc();
20706                     var tagName = parseJSDocIdentifierName();
20707                     skipWhitespace();
20708                     var t;
20709                     switch (tagName.escapedText) {
20710                         case "type":
20711                             return target === 1 && parseTypeTag(start, tagName);
20712                         case "prop":
20713                         case "property":
20714                             t = 1;
20715                             break;
20716                         case "arg":
20717                         case "argument":
20718                         case "param":
20719                             t = 2 | 4;
20720                             break;
20721                         default:
20722                             return false;
20723                     }
20724                     if (!(target & t)) {
20725                         return false;
20726                     }
20727                     return parseParameterOrPropertyTag(start, tagName, target, indent);
20728                 }
20729                 function parseTemplateTag(start, tagName) {
20730                     var constraint;
20731                     if (token() === 18) {
20732                         constraint = parseJSDocTypeExpression();
20733                     }
20734                     var typeParameters = [];
20735                     var typeParametersPos = getNodePos();
20736                     do {
20737                         skipWhitespace();
20738                         var typeParameter = createNode(155);
20739                         typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces);
20740                         finishNode(typeParameter);
20741                         skipWhitespaceOrAsterisk();
20742                         typeParameters.push(typeParameter);
20743                     } while (parseOptionalJsdoc(27));
20744                     var result = createNode(321, start);
20745                     result.tagName = tagName;
20746                     result.constraint = constraint;
20747                     result.typeParameters = createNodeArray(typeParameters, typeParametersPos);
20748                     finishNode(result);
20749                     return result;
20750                 }
20751                 function parseOptionalJsdoc(t) {
20752                     if (token() === t) {
20753                         nextTokenJSDoc();
20754                         return true;
20755                     }
20756                     return false;
20757                 }
20758                 function parseJSDocEntityName() {
20759                     var entity = parseJSDocIdentifierName();
20760                     if (parseOptional(22)) {
20761                         parseExpected(23);
20762                     }
20763                     while (parseOptional(24)) {
20764                         var name = parseJSDocIdentifierName();
20765                         if (parseOptional(22)) {
20766                             parseExpected(23);
20767                         }
20768                         entity = createQualifiedName(entity, name);
20769                     }
20770                     return entity;
20771                 }
20772                 function parseJSDocIdentifierName(message) {
20773                     if (!ts.tokenIsIdentifierOrKeyword(token())) {
20774                         return createMissingNode(75, !message, message || ts.Diagnostics.Identifier_expected);
20775                     }
20776                     identifierCount++;
20777                     var pos = scanner.getTokenPos();
20778                     var end = scanner.getTextPos();
20779                     var result = createNode(75, pos);
20780                     if (token() !== 75) {
20781                         result.originalKeywordKind = token();
20782                     }
20783                     result.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue()));
20784                     finishNode(result, end);
20785                     nextTokenJSDoc();
20786                     return result;
20787                 }
20788             }
20789         })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {}));
20790     })(Parser || (Parser = {}));
20791     var IncrementalParser;
20792     (function (IncrementalParser) {
20793         function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) {
20794             aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2);
20795             checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks);
20796             if (ts.textChangeRangeIsUnchanged(textChangeRange)) {
20797                 return sourceFile;
20798             }
20799             if (sourceFile.statements.length === 0) {
20800                 return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, undefined, true, sourceFile.scriptKind);
20801             }
20802             var incrementalSourceFile = sourceFile;
20803             ts.Debug.assert(!incrementalSourceFile.hasBeenIncrementallyParsed);
20804             incrementalSourceFile.hasBeenIncrementallyParsed = true;
20805             var oldText = sourceFile.text;
20806             var syntaxCursor = createSyntaxCursor(sourceFile);
20807             var changeRange = extendToAffectedRange(sourceFile, textChangeRange);
20808             checkChangeRange(sourceFile, newText, changeRange, aggressiveChecks);
20809             ts.Debug.assert(changeRange.span.start <= textChangeRange.span.start);
20810             ts.Debug.assert(ts.textSpanEnd(changeRange.span) === ts.textSpanEnd(textChangeRange.span));
20811             ts.Debug.assert(ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)) === ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)));
20812             var delta = ts.textChangeRangeNewSpan(changeRange).length - changeRange.span.length;
20813             updateTokenPositionsAndMarkElements(incrementalSourceFile, changeRange.span.start, ts.textSpanEnd(changeRange.span), ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)), delta, oldText, newText, aggressiveChecks);
20814             var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, true, sourceFile.scriptKind);
20815             result.commentDirectives = getNewCommentDirectives(sourceFile.commentDirectives, result.commentDirectives, changeRange.span.start, ts.textSpanEnd(changeRange.span), delta, oldText, newText, aggressiveChecks);
20816             return result;
20817         }
20818         IncrementalParser.updateSourceFile = updateSourceFile;
20819         function getNewCommentDirectives(oldDirectives, newDirectives, changeStart, changeRangeOldEnd, delta, oldText, newText, aggressiveChecks) {
20820             if (!oldDirectives)
20821                 return newDirectives;
20822             var commentDirectives;
20823             var addedNewlyScannedDirectives = false;
20824             for (var _i = 0, oldDirectives_1 = oldDirectives; _i < oldDirectives_1.length; _i++) {
20825                 var directive = oldDirectives_1[_i];
20826                 var range = directive.range, type = directive.type;
20827                 if (range.end < changeStart) {
20828                     commentDirectives = ts.append(commentDirectives, directive);
20829                 }
20830                 else if (range.pos > changeRangeOldEnd) {
20831                     addNewlyScannedDirectives();
20832                     var updatedDirective = {
20833                         range: { pos: range.pos + delta, end: range.end + delta },
20834                         type: type
20835                     };
20836                     commentDirectives = ts.append(commentDirectives, updatedDirective);
20837                     if (aggressiveChecks) {
20838                         ts.Debug.assert(oldText.substring(range.pos, range.end) === newText.substring(updatedDirective.range.pos, updatedDirective.range.end));
20839                     }
20840                 }
20841             }
20842             addNewlyScannedDirectives();
20843             return commentDirectives;
20844             function addNewlyScannedDirectives() {
20845                 if (addedNewlyScannedDirectives)
20846                     return;
20847                 addedNewlyScannedDirectives = true;
20848                 if (!commentDirectives) {
20849                     commentDirectives = newDirectives;
20850                 }
20851                 else if (newDirectives) {
20852                     commentDirectives.push.apply(commentDirectives, newDirectives);
20853                 }
20854             }
20855         }
20856         function moveElementEntirelyPastChangeRange(element, isArray, delta, oldText, newText, aggressiveChecks) {
20857             if (isArray) {
20858                 visitArray(element);
20859             }
20860             else {
20861                 visitNode(element);
20862             }
20863             return;
20864             function visitNode(node) {
20865                 var text = "";
20866                 if (aggressiveChecks && shouldCheckNode(node)) {
20867                     text = oldText.substring(node.pos, node.end);
20868                 }
20869                 if (node._children) {
20870                     node._children = undefined;
20871                 }
20872                 node.pos += delta;
20873                 node.end += delta;
20874                 if (aggressiveChecks && shouldCheckNode(node)) {
20875                     ts.Debug.assert(text === newText.substring(node.pos, node.end));
20876                 }
20877                 forEachChild(node, visitNode, visitArray);
20878                 if (ts.hasJSDocNodes(node)) {
20879                     for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
20880                         var jsDocComment = _a[_i];
20881                         visitNode(jsDocComment);
20882                     }
20883                 }
20884                 checkNodePositions(node, aggressiveChecks);
20885             }
20886             function visitArray(array) {
20887                 array._children = undefined;
20888                 array.pos += delta;
20889                 array.end += delta;
20890                 for (var _i = 0, array_8 = array; _i < array_8.length; _i++) {
20891                     var node = array_8[_i];
20892                     visitNode(node);
20893                 }
20894             }
20895         }
20896         function shouldCheckNode(node) {
20897             switch (node.kind) {
20898                 case 10:
20899                 case 8:
20900                 case 75:
20901                     return true;
20902             }
20903             return false;
20904         }
20905         function adjustIntersectingElement(element, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta) {
20906             ts.Debug.assert(element.end >= changeStart, "Adjusting an element that was entirely before the change range");
20907             ts.Debug.assert(element.pos <= changeRangeOldEnd, "Adjusting an element that was entirely after the change range");
20908             ts.Debug.assert(element.pos <= element.end);
20909             element.pos = Math.min(element.pos, changeRangeNewEnd);
20910             if (element.end >= changeRangeOldEnd) {
20911                 element.end += delta;
20912             }
20913             else {
20914                 element.end = Math.min(element.end, changeRangeNewEnd);
20915             }
20916             ts.Debug.assert(element.pos <= element.end);
20917             if (element.parent) {
20918                 ts.Debug.assert(element.pos >= element.parent.pos);
20919                 ts.Debug.assert(element.end <= element.parent.end);
20920             }
20921         }
20922         function checkNodePositions(node, aggressiveChecks) {
20923             if (aggressiveChecks) {
20924                 var pos_2 = node.pos;
20925                 var visitNode_1 = function (child) {
20926                     ts.Debug.assert(child.pos >= pos_2);
20927                     pos_2 = child.end;
20928                 };
20929                 if (ts.hasJSDocNodes(node)) {
20930                     for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
20931                         var jsDocComment = _a[_i];
20932                         visitNode_1(jsDocComment);
20933                     }
20934                 }
20935                 forEachChild(node, visitNode_1);
20936                 ts.Debug.assert(pos_2 <= node.end);
20937             }
20938         }
20939         function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) {
20940             visitNode(sourceFile);
20941             return;
20942             function visitNode(child) {
20943                 ts.Debug.assert(child.pos <= child.end);
20944                 if (child.pos > changeRangeOldEnd) {
20945                     moveElementEntirelyPastChangeRange(child, false, delta, oldText, newText, aggressiveChecks);
20946                     return;
20947                 }
20948                 var fullEnd = child.end;
20949                 if (fullEnd >= changeStart) {
20950                     child.intersectsChange = true;
20951                     child._children = undefined;
20952                     adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
20953                     forEachChild(child, visitNode, visitArray);
20954                     if (ts.hasJSDocNodes(child)) {
20955                         for (var _i = 0, _a = child.jsDoc; _i < _a.length; _i++) {
20956                             var jsDocComment = _a[_i];
20957                             visitNode(jsDocComment);
20958                         }
20959                     }
20960                     checkNodePositions(child, aggressiveChecks);
20961                     return;
20962                 }
20963                 ts.Debug.assert(fullEnd < changeStart);
20964             }
20965             function visitArray(array) {
20966                 ts.Debug.assert(array.pos <= array.end);
20967                 if (array.pos > changeRangeOldEnd) {
20968                     moveElementEntirelyPastChangeRange(array, true, delta, oldText, newText, aggressiveChecks);
20969                     return;
20970                 }
20971                 var fullEnd = array.end;
20972                 if (fullEnd >= changeStart) {
20973                     array.intersectsChange = true;
20974                     array._children = undefined;
20975                     adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
20976                     for (var _i = 0, array_9 = array; _i < array_9.length; _i++) {
20977                         var node = array_9[_i];
20978                         visitNode(node);
20979                     }
20980                     return;
20981                 }
20982                 ts.Debug.assert(fullEnd < changeStart);
20983             }
20984         }
20985         function extendToAffectedRange(sourceFile, changeRange) {
20986             var maxLookahead = 1;
20987             var start = changeRange.span.start;
20988             for (var i = 0; start > 0 && i <= maxLookahead; i++) {
20989                 var nearestNode = findNearestNodeStartingBeforeOrAtPosition(sourceFile, start);
20990                 ts.Debug.assert(nearestNode.pos <= start);
20991                 var position = nearestNode.pos;
20992                 start = Math.max(0, position - 1);
20993             }
20994             var finalSpan = ts.createTextSpanFromBounds(start, ts.textSpanEnd(changeRange.span));
20995             var finalLength = changeRange.newLength + (changeRange.span.start - start);
20996             return ts.createTextChangeRange(finalSpan, finalLength);
20997         }
20998         function findNearestNodeStartingBeforeOrAtPosition(sourceFile, position) {
20999             var bestResult = sourceFile;
21000             var lastNodeEntirelyBeforePosition;
21001             forEachChild(sourceFile, visit);
21002             if (lastNodeEntirelyBeforePosition) {
21003                 var lastChildOfLastEntireNodeBeforePosition = getLastDescendant(lastNodeEntirelyBeforePosition);
21004                 if (lastChildOfLastEntireNodeBeforePosition.pos > bestResult.pos) {
21005                     bestResult = lastChildOfLastEntireNodeBeforePosition;
21006                 }
21007             }
21008             return bestResult;
21009             function getLastDescendant(node) {
21010                 while (true) {
21011                     var lastChild = ts.getLastChild(node);
21012                     if (lastChild) {
21013                         node = lastChild;
21014                     }
21015                     else {
21016                         return node;
21017                     }
21018                 }
21019             }
21020             function visit(child) {
21021                 if (ts.nodeIsMissing(child)) {
21022                     return;
21023                 }
21024                 if (child.pos <= position) {
21025                     if (child.pos >= bestResult.pos) {
21026                         bestResult = child;
21027                     }
21028                     if (position < child.end) {
21029                         forEachChild(child, visit);
21030                         return true;
21031                     }
21032                     else {
21033                         ts.Debug.assert(child.end <= position);
21034                         lastNodeEntirelyBeforePosition = child;
21035                     }
21036                 }
21037                 else {
21038                     ts.Debug.assert(child.pos > position);
21039                     return true;
21040                 }
21041             }
21042         }
21043         function checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks) {
21044             var oldText = sourceFile.text;
21045             if (textChangeRange) {
21046                 ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length);
21047                 if (aggressiveChecks || ts.Debug.shouldAssert(3)) {
21048                     var oldTextPrefix = oldText.substr(0, textChangeRange.span.start);
21049                     var newTextPrefix = newText.substr(0, textChangeRange.span.start);
21050                     ts.Debug.assert(oldTextPrefix === newTextPrefix);
21051                     var oldTextSuffix = oldText.substring(ts.textSpanEnd(textChangeRange.span), oldText.length);
21052                     var newTextSuffix = newText.substring(ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)), newText.length);
21053                     ts.Debug.assert(oldTextSuffix === newTextSuffix);
21054                 }
21055             }
21056         }
21057         function createSyntaxCursor(sourceFile) {
21058             var currentArray = sourceFile.statements;
21059             var currentArrayIndex = 0;
21060             ts.Debug.assert(currentArrayIndex < currentArray.length);
21061             var current = currentArray[currentArrayIndex];
21062             var lastQueriedPosition = -1;
21063             return {
21064                 currentNode: function (position) {
21065                     if (position !== lastQueriedPosition) {
21066                         if (current && current.end === position && currentArrayIndex < (currentArray.length - 1)) {
21067                             currentArrayIndex++;
21068                             current = currentArray[currentArrayIndex];
21069                         }
21070                         if (!current || current.pos !== position) {
21071                             findHighestListElementThatStartsAtPosition(position);
21072                         }
21073                     }
21074                     lastQueriedPosition = position;
21075                     ts.Debug.assert(!current || current.pos === position);
21076                     return current;
21077                 }
21078             };
21079             function findHighestListElementThatStartsAtPosition(position) {
21080                 currentArray = undefined;
21081                 currentArrayIndex = -1;
21082                 current = undefined;
21083                 forEachChild(sourceFile, visitNode, visitArray);
21084                 return;
21085                 function visitNode(node) {
21086                     if (position >= node.pos && position < node.end) {
21087                         forEachChild(node, visitNode, visitArray);
21088                         return true;
21089                     }
21090                     return false;
21091                 }
21092                 function visitArray(array) {
21093                     if (position >= array.pos && position < array.end) {
21094                         for (var i = 0; i < array.length; i++) {
21095                             var child = array[i];
21096                             if (child) {
21097                                 if (child.pos === position) {
21098                                     currentArray = array;
21099                                     currentArrayIndex = i;
21100                                     current = child;
21101                                     return true;
21102                                 }
21103                                 else {
21104                                     if (child.pos < position && position < child.end) {
21105                                         forEachChild(child, visitNode, visitArray);
21106                                         return true;
21107                                     }
21108                                 }
21109                             }
21110                         }
21111                     }
21112                     return false;
21113                 }
21114             }
21115         }
21116     })(IncrementalParser || (IncrementalParser = {}));
21117     function isDeclarationFileName(fileName) {
21118         return ts.fileExtensionIs(fileName, ".d.ts");
21119     }
21120     ts.isDeclarationFileName = isDeclarationFileName;
21121     function processCommentPragmas(context, sourceText) {
21122         var pragmas = [];
21123         for (var _i = 0, _a = ts.getLeadingCommentRanges(sourceText, 0) || ts.emptyArray; _i < _a.length; _i++) {
21124             var range = _a[_i];
21125             var comment = sourceText.substring(range.pos, range.end);
21126             extractPragmas(pragmas, range, comment);
21127         }
21128         context.pragmas = ts.createMap();
21129         for (var _b = 0, pragmas_1 = pragmas; _b < pragmas_1.length; _b++) {
21130             var pragma = pragmas_1[_b];
21131             if (context.pragmas.has(pragma.name)) {
21132                 var currentValue = context.pragmas.get(pragma.name);
21133                 if (currentValue instanceof Array) {
21134                     currentValue.push(pragma.args);
21135                 }
21136                 else {
21137                     context.pragmas.set(pragma.name, [currentValue, pragma.args]);
21138                 }
21139                 continue;
21140             }
21141             context.pragmas.set(pragma.name, pragma.args);
21142         }
21143     }
21144     ts.processCommentPragmas = processCommentPragmas;
21145     function processPragmasIntoFields(context, reportDiagnostic) {
21146         context.checkJsDirective = undefined;
21147         context.referencedFiles = [];
21148         context.typeReferenceDirectives = [];
21149         context.libReferenceDirectives = [];
21150         context.amdDependencies = [];
21151         context.hasNoDefaultLib = false;
21152         context.pragmas.forEach(function (entryOrList, key) {
21153             switch (key) {
21154                 case "reference": {
21155                     var referencedFiles_1 = context.referencedFiles;
21156                     var typeReferenceDirectives_1 = context.typeReferenceDirectives;
21157                     var libReferenceDirectives_1 = context.libReferenceDirectives;
21158                     ts.forEach(ts.toArray(entryOrList), function (arg) {
21159                         var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path;
21160                         if (arg.arguments["no-default-lib"]) {
21161                             context.hasNoDefaultLib = true;
21162                         }
21163                         else if (types) {
21164                             typeReferenceDirectives_1.push({ pos: types.pos, end: types.end, fileName: types.value });
21165                         }
21166                         else if (lib) {
21167                             libReferenceDirectives_1.push({ pos: lib.pos, end: lib.end, fileName: lib.value });
21168                         }
21169                         else if (path) {
21170                             referencedFiles_1.push({ pos: path.pos, end: path.end, fileName: path.value });
21171                         }
21172                         else {
21173                             reportDiagnostic(arg.range.pos, arg.range.end - arg.range.pos, ts.Diagnostics.Invalid_reference_directive_syntax);
21174                         }
21175                     });
21176                     break;
21177                 }
21178                 case "amd-dependency": {
21179                     context.amdDependencies = ts.map(ts.toArray(entryOrList), function (x) { return ({ name: x.arguments.name, path: x.arguments.path }); });
21180                     break;
21181                 }
21182                 case "amd-module": {
21183                     if (entryOrList instanceof Array) {
21184                         for (var _i = 0, entryOrList_1 = entryOrList; _i < entryOrList_1.length; _i++) {
21185                             var entry = entryOrList_1[_i];
21186                             if (context.moduleName) {
21187                                 reportDiagnostic(entry.range.pos, entry.range.end - entry.range.pos, ts.Diagnostics.An_AMD_module_cannot_have_multiple_name_assignments);
21188                             }
21189                             context.moduleName = entry.arguments.name;
21190                         }
21191                     }
21192                     else {
21193                         context.moduleName = entryOrList.arguments.name;
21194                     }
21195                     break;
21196                 }
21197                 case "ts-nocheck":
21198                 case "ts-check": {
21199                     ts.forEach(ts.toArray(entryOrList), function (entry) {
21200                         if (!context.checkJsDirective || entry.range.pos > context.checkJsDirective.pos) {
21201                             context.checkJsDirective = {
21202                                 enabled: key === "ts-check",
21203                                 end: entry.range.end,
21204                                 pos: entry.range.pos
21205                             };
21206                         }
21207                     });
21208                     break;
21209                 }
21210                 case "jsx": return;
21211                 default: ts.Debug.fail("Unhandled pragma kind");
21212             }
21213         });
21214     }
21215     ts.processPragmasIntoFields = processPragmasIntoFields;
21216     var namedArgRegExCache = ts.createMap();
21217     function getNamedArgRegEx(name) {
21218         if (namedArgRegExCache.has(name)) {
21219             return namedArgRegExCache.get(name);
21220         }
21221         var result = new RegExp("(\\s" + name + "\\s*=\\s*)('|\")(.+?)\\2", "im");
21222         namedArgRegExCache.set(name, result);
21223         return result;
21224     }
21225     var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im;
21226     var singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im;
21227     function extractPragmas(pragmas, range, text) {
21228         var tripleSlash = range.kind === 2 && tripleSlashXMLCommentStartRegEx.exec(text);
21229         if (tripleSlash) {
21230             var name = tripleSlash[1].toLowerCase();
21231             var pragma = ts.commentPragmas[name];
21232             if (!pragma || !(pragma.kind & 1)) {
21233                 return;
21234             }
21235             if (pragma.args) {
21236                 var argument = {};
21237                 for (var _i = 0, _a = pragma.args; _i < _a.length; _i++) {
21238                     var arg = _a[_i];
21239                     var matcher = getNamedArgRegEx(arg.name);
21240                     var matchResult = matcher.exec(text);
21241                     if (!matchResult && !arg.optional) {
21242                         return;
21243                     }
21244                     else if (matchResult) {
21245                         if (arg.captureSpan) {
21246                             var startPos = range.pos + matchResult.index + matchResult[1].length + matchResult[2].length;
21247                             argument[arg.name] = {
21248                                 value: matchResult[3],
21249                                 pos: startPos,
21250                                 end: startPos + matchResult[3].length
21251                             };
21252                         }
21253                         else {
21254                             argument[arg.name] = matchResult[3];
21255                         }
21256                     }
21257                 }
21258                 pragmas.push({ name: name, args: { arguments: argument, range: range } });
21259             }
21260             else {
21261                 pragmas.push({ name: name, args: { arguments: {}, range: range } });
21262             }
21263             return;
21264         }
21265         var singleLine = range.kind === 2 && singleLinePragmaRegEx.exec(text);
21266         if (singleLine) {
21267             return addPragmaForMatch(pragmas, range, 2, singleLine);
21268         }
21269         if (range.kind === 3) {
21270             var multiLinePragmaRegEx = /\s*@(\S+)\s*(.*)\s*$/gim;
21271             var multiLineMatch = void 0;
21272             while (multiLineMatch = multiLinePragmaRegEx.exec(text)) {
21273                 addPragmaForMatch(pragmas, range, 4, multiLineMatch);
21274             }
21275         }
21276     }
21277     function addPragmaForMatch(pragmas, range, kind, match) {
21278         if (!match)
21279             return;
21280         var name = match[1].toLowerCase();
21281         var pragma = ts.commentPragmas[name];
21282         if (!pragma || !(pragma.kind & kind)) {
21283             return;
21284         }
21285         var args = match[2];
21286         var argument = getNamedPragmaArguments(pragma, args);
21287         if (argument === "fail")
21288             return;
21289         pragmas.push({ name: name, args: { arguments: argument, range: range } });
21290         return;
21291     }
21292     function getNamedPragmaArguments(pragma, text) {
21293         if (!text)
21294             return {};
21295         if (!pragma.args)
21296             return {};
21297         var args = text.split(/\s+/);
21298         var argMap = {};
21299         for (var i = 0; i < pragma.args.length; i++) {
21300             var argument = pragma.args[i];
21301             if (!args[i] && !argument.optional) {
21302                 return "fail";
21303             }
21304             if (argument.captureSpan) {
21305                 return ts.Debug.fail("Capture spans not yet implemented for non-xml pragmas");
21306             }
21307             argMap[argument.name] = args[i];
21308         }
21309         return argMap;
21310     }
21311     function tagNamesAreEquivalent(lhs, rhs) {
21312         if (lhs.kind !== rhs.kind) {
21313             return false;
21314         }
21315         if (lhs.kind === 75) {
21316             return lhs.escapedText === rhs.escapedText;
21317         }
21318         if (lhs.kind === 104) {
21319             return true;
21320         }
21321         return lhs.name.escapedText === rhs.name.escapedText &&
21322             tagNamesAreEquivalent(lhs.expression, rhs.expression);
21323     }
21324     ts.tagNamesAreEquivalent = tagNamesAreEquivalent;
21325 })(ts || (ts = {}));
21326 var ts;
21327 (function (ts) {
21328     ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" };
21329     var libEntries = [
21330         ["es5", "lib.es5.d.ts"],
21331         ["es6", "lib.es2015.d.ts"],
21332         ["es2015", "lib.es2015.d.ts"],
21333         ["es7", "lib.es2016.d.ts"],
21334         ["es2016", "lib.es2016.d.ts"],
21335         ["es2017", "lib.es2017.d.ts"],
21336         ["es2018", "lib.es2018.d.ts"],
21337         ["es2019", "lib.es2019.d.ts"],
21338         ["es2020", "lib.es2020.d.ts"],
21339         ["esnext", "lib.esnext.d.ts"],
21340         ["dom", "lib.dom.d.ts"],
21341         ["dom.iterable", "lib.dom.iterable.d.ts"],
21342         ["webworker", "lib.webworker.d.ts"],
21343         ["webworker.importscripts", "lib.webworker.importscripts.d.ts"],
21344         ["scripthost", "lib.scripthost.d.ts"],
21345         ["es2015.core", "lib.es2015.core.d.ts"],
21346         ["es2015.collection", "lib.es2015.collection.d.ts"],
21347         ["es2015.generator", "lib.es2015.generator.d.ts"],
21348         ["es2015.iterable", "lib.es2015.iterable.d.ts"],
21349         ["es2015.promise", "lib.es2015.promise.d.ts"],
21350         ["es2015.proxy", "lib.es2015.proxy.d.ts"],
21351         ["es2015.reflect", "lib.es2015.reflect.d.ts"],
21352         ["es2015.symbol", "lib.es2015.symbol.d.ts"],
21353         ["es2015.symbol.wellknown", "lib.es2015.symbol.wellknown.d.ts"],
21354         ["es2016.array.include", "lib.es2016.array.include.d.ts"],
21355         ["es2017.object", "lib.es2017.object.d.ts"],
21356         ["es2017.sharedmemory", "lib.es2017.sharedmemory.d.ts"],
21357         ["es2017.string", "lib.es2017.string.d.ts"],
21358         ["es2017.intl", "lib.es2017.intl.d.ts"],
21359         ["es2017.typedarrays", "lib.es2017.typedarrays.d.ts"],
21360         ["es2018.asyncgenerator", "lib.es2018.asyncgenerator.d.ts"],
21361         ["es2018.asynciterable", "lib.es2018.asynciterable.d.ts"],
21362         ["es2018.intl", "lib.es2018.intl.d.ts"],
21363         ["es2018.promise", "lib.es2018.promise.d.ts"],
21364         ["es2018.regexp", "lib.es2018.regexp.d.ts"],
21365         ["es2019.array", "lib.es2019.array.d.ts"],
21366         ["es2019.object", "lib.es2019.object.d.ts"],
21367         ["es2019.string", "lib.es2019.string.d.ts"],
21368         ["es2019.symbol", "lib.es2019.symbol.d.ts"],
21369         ["es2020.bigint", "lib.es2020.bigint.d.ts"],
21370         ["es2020.promise", "lib.es2020.promise.d.ts"],
21371         ["es2020.string", "lib.es2020.string.d.ts"],
21372         ["es2020.symbol.wellknown", "lib.es2020.symbol.wellknown.d.ts"],
21373         ["esnext.array", "lib.es2019.array.d.ts"],
21374         ["esnext.symbol", "lib.es2019.symbol.d.ts"],
21375         ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"],
21376         ["esnext.intl", "lib.esnext.intl.d.ts"],
21377         ["esnext.bigint", "lib.es2020.bigint.d.ts"],
21378         ["esnext.string", "lib.esnext.string.d.ts"],
21379         ["esnext.promise", "lib.esnext.promise.d.ts"]
21380     ];
21381     ts.libs = libEntries.map(function (entry) { return entry[0]; });
21382     ts.libMap = ts.createMapFromEntries(libEntries);
21383     ts.optionsForWatch = [
21384         {
21385             name: "watchFile",
21386             type: ts.createMapFromTemplate({
21387                 fixedpollinginterval: ts.WatchFileKind.FixedPollingInterval,
21388                 prioritypollinginterval: ts.WatchFileKind.PriorityPollingInterval,
21389                 dynamicprioritypolling: ts.WatchFileKind.DynamicPriorityPolling,
21390                 usefsevents: ts.WatchFileKind.UseFsEvents,
21391                 usefseventsonparentdirectory: ts.WatchFileKind.UseFsEventsOnParentDirectory,
21392             }),
21393             category: ts.Diagnostics.Advanced_Options,
21394             description: ts.Diagnostics.Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_UseFsEvents_UseFsEventsOnParentDirectory,
21395         },
21396         {
21397             name: "watchDirectory",
21398             type: ts.createMapFromTemplate({
21399                 usefsevents: ts.WatchDirectoryKind.UseFsEvents,
21400                 fixedpollinginterval: ts.WatchDirectoryKind.FixedPollingInterval,
21401                 dynamicprioritypolling: ts.WatchDirectoryKind.DynamicPriorityPolling,
21402             }),
21403             category: ts.Diagnostics.Advanced_Options,
21404             description: ts.Diagnostics.Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling,
21405         },
21406         {
21407             name: "fallbackPolling",
21408             type: ts.createMapFromTemplate({
21409                 fixedinterval: ts.PollingWatchKind.FixedInterval,
21410                 priorityinterval: ts.PollingWatchKind.PriorityInterval,
21411                 dynamicpriority: ts.PollingWatchKind.DynamicPriority,
21412             }),
21413             category: ts.Diagnostics.Advanced_Options,
21414             description: ts.Diagnostics.Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority,
21415         },
21416         {
21417             name: "synchronousWatchDirectory",
21418             type: "boolean",
21419             category: ts.Diagnostics.Advanced_Options,
21420             description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively,
21421         },
21422     ];
21423     ts.commonOptionsWithBuild = [
21424         {
21425             name: "help",
21426             shortName: "h",
21427             type: "boolean",
21428             showInSimplifiedHelpView: true,
21429             category: ts.Diagnostics.Command_line_Options,
21430             description: ts.Diagnostics.Print_this_message,
21431         },
21432         {
21433             name: "help",
21434             shortName: "?",
21435             type: "boolean"
21436         },
21437         {
21438             name: "watch",
21439             shortName: "w",
21440             type: "boolean",
21441             showInSimplifiedHelpView: true,
21442             category: ts.Diagnostics.Command_line_Options,
21443             description: ts.Diagnostics.Watch_input_files,
21444         },
21445         {
21446             name: "preserveWatchOutput",
21447             type: "boolean",
21448             showInSimplifiedHelpView: false,
21449             category: ts.Diagnostics.Command_line_Options,
21450             description: ts.Diagnostics.Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen,
21451         },
21452         {
21453             name: "listFiles",
21454             type: "boolean",
21455             category: ts.Diagnostics.Advanced_Options,
21456             description: ts.Diagnostics.Print_names_of_files_part_of_the_compilation
21457         },
21458         {
21459             name: "listEmittedFiles",
21460             type: "boolean",
21461             category: ts.Diagnostics.Advanced_Options,
21462             description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation
21463         },
21464         {
21465             name: "pretty",
21466             type: "boolean",
21467             showInSimplifiedHelpView: true,
21468             category: ts.Diagnostics.Command_line_Options,
21469             description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental
21470         },
21471         {
21472             name: "traceResolution",
21473             type: "boolean",
21474             category: ts.Diagnostics.Advanced_Options,
21475             description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process
21476         },
21477         {
21478             name: "diagnostics",
21479             type: "boolean",
21480             category: ts.Diagnostics.Advanced_Options,
21481             description: ts.Diagnostics.Show_diagnostic_information
21482         },
21483         {
21484             name: "extendedDiagnostics",
21485             type: "boolean",
21486             category: ts.Diagnostics.Advanced_Options,
21487             description: ts.Diagnostics.Show_verbose_diagnostic_information
21488         },
21489         {
21490             name: "generateCpuProfile",
21491             type: "string",
21492             isFilePath: true,
21493             paramType: ts.Diagnostics.FILE_OR_DIRECTORY,
21494             category: ts.Diagnostics.Advanced_Options,
21495             description: ts.Diagnostics.Generates_a_CPU_profile
21496         },
21497         {
21498             name: "incremental",
21499             shortName: "i",
21500             type: "boolean",
21501             category: ts.Diagnostics.Basic_Options,
21502             description: ts.Diagnostics.Enable_incremental_compilation,
21503             transpileOptionValue: undefined
21504         },
21505         {
21506             name: "assumeChangesOnlyAffectDirectDependencies",
21507             type: "boolean",
21508             affectsSemanticDiagnostics: true,
21509             affectsEmit: true,
21510             category: ts.Diagnostics.Advanced_Options,
21511             description: ts.Diagnostics.Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it
21512         },
21513         {
21514             name: "locale",
21515             type: "string",
21516             category: ts.Diagnostics.Advanced_Options,
21517             description: ts.Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us
21518         },
21519     ];
21520     ts.optionDeclarations = __spreadArrays(ts.commonOptionsWithBuild, [
21521         {
21522             name: "all",
21523             type: "boolean",
21524             showInSimplifiedHelpView: true,
21525             category: ts.Diagnostics.Command_line_Options,
21526             description: ts.Diagnostics.Show_all_compiler_options,
21527         },
21528         {
21529             name: "version",
21530             shortName: "v",
21531             type: "boolean",
21532             showInSimplifiedHelpView: true,
21533             category: ts.Diagnostics.Command_line_Options,
21534             description: ts.Diagnostics.Print_the_compiler_s_version,
21535         },
21536         {
21537             name: "init",
21538             type: "boolean",
21539             showInSimplifiedHelpView: true,
21540             category: ts.Diagnostics.Command_line_Options,
21541             description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file,
21542         },
21543         {
21544             name: "project",
21545             shortName: "p",
21546             type: "string",
21547             isFilePath: true,
21548             showInSimplifiedHelpView: true,
21549             category: ts.Diagnostics.Command_line_Options,
21550             paramType: ts.Diagnostics.FILE_OR_DIRECTORY,
21551             description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json,
21552         },
21553         {
21554             name: "build",
21555             type: "boolean",
21556             shortName: "b",
21557             showInSimplifiedHelpView: true,
21558             category: ts.Diagnostics.Command_line_Options,
21559             description: ts.Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date
21560         },
21561         {
21562             name: "showConfig",
21563             type: "boolean",
21564             category: ts.Diagnostics.Command_line_Options,
21565             isCommandLineOnly: true,
21566             description: ts.Diagnostics.Print_the_final_configuration_instead_of_building
21567         },
21568         {
21569             name: "listFilesOnly",
21570             type: "boolean",
21571             category: ts.Diagnostics.Command_line_Options,
21572             affectsSemanticDiagnostics: true,
21573             affectsEmit: true,
21574             isCommandLineOnly: true,
21575             description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing
21576         },
21577         {
21578             name: "target",
21579             shortName: "t",
21580             type: ts.createMapFromTemplate({
21581                 es3: 0,
21582                 es5: 1,
21583                 es6: 2,
21584                 es2015: 2,
21585                 es2016: 3,
21586                 es2017: 4,
21587                 es2018: 5,
21588                 es2019: 6,
21589                 es2020: 7,
21590                 esnext: 99,
21591             }),
21592             affectsSourceFile: true,
21593             affectsModuleResolution: true,
21594             affectsEmit: true,
21595             paramType: ts.Diagnostics.VERSION,
21596             showInSimplifiedHelpView: true,
21597             category: ts.Diagnostics.Basic_Options,
21598             description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_ESNEXT,
21599         },
21600         {
21601             name: "module",
21602             shortName: "m",
21603             type: ts.createMapFromTemplate({
21604                 none: ts.ModuleKind.None,
21605                 commonjs: ts.ModuleKind.CommonJS,
21606                 amd: ts.ModuleKind.AMD,
21607                 system: ts.ModuleKind.System,
21608                 umd: ts.ModuleKind.UMD,
21609                 es6: ts.ModuleKind.ES2015,
21610                 es2015: ts.ModuleKind.ES2015,
21611                 es2020: ts.ModuleKind.ES2020,
21612                 esnext: ts.ModuleKind.ESNext
21613             }),
21614             affectsModuleResolution: true,
21615             affectsEmit: true,
21616             paramType: ts.Diagnostics.KIND,
21617             showInSimplifiedHelpView: true,
21618             category: ts.Diagnostics.Basic_Options,
21619             description: ts.Diagnostics.Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext,
21620         },
21621         {
21622             name: "lib",
21623             type: "list",
21624             element: {
21625                 name: "lib",
21626                 type: ts.libMap
21627             },
21628             affectsModuleResolution: true,
21629             showInSimplifiedHelpView: true,
21630             category: ts.Diagnostics.Basic_Options,
21631             description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation,
21632             transpileOptionValue: undefined
21633         },
21634         {
21635             name: "allowJs",
21636             type: "boolean",
21637             affectsModuleResolution: true,
21638             showInSimplifiedHelpView: true,
21639             category: ts.Diagnostics.Basic_Options,
21640             description: ts.Diagnostics.Allow_javascript_files_to_be_compiled
21641         },
21642         {
21643             name: "checkJs",
21644             type: "boolean",
21645             category: ts.Diagnostics.Basic_Options,
21646             description: ts.Diagnostics.Report_errors_in_js_files
21647         },
21648         {
21649             name: "jsx",
21650             type: ts.createMapFromTemplate({
21651                 "preserve": 1,
21652                 "react-native": 3,
21653                 "react": 2
21654             }),
21655             affectsSourceFile: true,
21656             paramType: ts.Diagnostics.KIND,
21657             showInSimplifiedHelpView: true,
21658             category: ts.Diagnostics.Basic_Options,
21659             description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react,
21660         },
21661         {
21662             name: "declaration",
21663             shortName: "d",
21664             type: "boolean",
21665             affectsEmit: true,
21666             showInSimplifiedHelpView: true,
21667             category: ts.Diagnostics.Basic_Options,
21668             description: ts.Diagnostics.Generates_corresponding_d_ts_file,
21669             transpileOptionValue: undefined
21670         },
21671         {
21672             name: "declarationMap",
21673             type: "boolean",
21674             affectsEmit: true,
21675             showInSimplifiedHelpView: true,
21676             category: ts.Diagnostics.Basic_Options,
21677             description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file,
21678             transpileOptionValue: undefined
21679         },
21680         {
21681             name: "emitDeclarationOnly",
21682             type: "boolean",
21683             affectsEmit: true,
21684             category: ts.Diagnostics.Advanced_Options,
21685             description: ts.Diagnostics.Only_emit_d_ts_declaration_files,
21686             transpileOptionValue: undefined
21687         },
21688         {
21689             name: "sourceMap",
21690             type: "boolean",
21691             affectsEmit: true,
21692             showInSimplifiedHelpView: true,
21693             category: ts.Diagnostics.Basic_Options,
21694             description: ts.Diagnostics.Generates_corresponding_map_file,
21695         },
21696         {
21697             name: "outFile",
21698             type: "string",
21699             affectsEmit: true,
21700             isFilePath: true,
21701             paramType: ts.Diagnostics.FILE,
21702             showInSimplifiedHelpView: true,
21703             category: ts.Diagnostics.Basic_Options,
21704             description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file,
21705             transpileOptionValue: undefined
21706         },
21707         {
21708             name: "outDir",
21709             type: "string",
21710             affectsEmit: true,
21711             isFilePath: true,
21712             paramType: ts.Diagnostics.DIRECTORY,
21713             showInSimplifiedHelpView: true,
21714             category: ts.Diagnostics.Basic_Options,
21715             description: ts.Diagnostics.Redirect_output_structure_to_the_directory,
21716         },
21717         {
21718             name: "rootDir",
21719             type: "string",
21720             affectsEmit: true,
21721             isFilePath: true,
21722             paramType: ts.Diagnostics.LOCATION,
21723             category: ts.Diagnostics.Basic_Options,
21724             description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir,
21725         },
21726         {
21727             name: "composite",
21728             type: "boolean",
21729             affectsEmit: true,
21730             isTSConfigOnly: true,
21731             category: ts.Diagnostics.Basic_Options,
21732             description: ts.Diagnostics.Enable_project_compilation,
21733             transpileOptionValue: undefined
21734         },
21735         {
21736             name: "tsBuildInfoFile",
21737             type: "string",
21738             affectsEmit: true,
21739             isFilePath: true,
21740             paramType: ts.Diagnostics.FILE,
21741             category: ts.Diagnostics.Basic_Options,
21742             description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information,
21743             transpileOptionValue: undefined
21744         },
21745         {
21746             name: "removeComments",
21747             type: "boolean",
21748             affectsEmit: true,
21749             showInSimplifiedHelpView: true,
21750             category: ts.Diagnostics.Basic_Options,
21751             description: ts.Diagnostics.Do_not_emit_comments_to_output,
21752         },
21753         {
21754             name: "noEmit",
21755             type: "boolean",
21756             affectsEmit: true,
21757             showInSimplifiedHelpView: true,
21758             category: ts.Diagnostics.Basic_Options,
21759             description: ts.Diagnostics.Do_not_emit_outputs,
21760             transpileOptionValue: undefined
21761         },
21762         {
21763             name: "importHelpers",
21764             type: "boolean",
21765             affectsEmit: true,
21766             category: ts.Diagnostics.Basic_Options,
21767             description: ts.Diagnostics.Import_emit_helpers_from_tslib
21768         },
21769         {
21770             name: "importsNotUsedAsValues",
21771             type: ts.createMapFromTemplate({
21772                 remove: 0,
21773                 preserve: 1,
21774                 error: 2
21775             }),
21776             affectsEmit: true,
21777             affectsSemanticDiagnostics: true,
21778             category: ts.Diagnostics.Advanced_Options,
21779             description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types
21780         },
21781         {
21782             name: "downlevelIteration",
21783             type: "boolean",
21784             affectsEmit: true,
21785             category: ts.Diagnostics.Basic_Options,
21786             description: ts.Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3
21787         },
21788         {
21789             name: "isolatedModules",
21790             type: "boolean",
21791             category: ts.Diagnostics.Basic_Options,
21792             description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule,
21793             transpileOptionValue: true
21794         },
21795         {
21796             name: "strict",
21797             type: "boolean",
21798             showInSimplifiedHelpView: true,
21799             category: ts.Diagnostics.Strict_Type_Checking_Options,
21800             description: ts.Diagnostics.Enable_all_strict_type_checking_options
21801         },
21802         {
21803             name: "noImplicitAny",
21804             type: "boolean",
21805             affectsSemanticDiagnostics: true,
21806             strictFlag: true,
21807             showInSimplifiedHelpView: true,
21808             category: ts.Diagnostics.Strict_Type_Checking_Options,
21809             description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type
21810         },
21811         {
21812             name: "strictNullChecks",
21813             type: "boolean",
21814             affectsSemanticDiagnostics: true,
21815             strictFlag: true,
21816             showInSimplifiedHelpView: true,
21817             category: ts.Diagnostics.Strict_Type_Checking_Options,
21818             description: ts.Diagnostics.Enable_strict_null_checks
21819         },
21820         {
21821             name: "strictFunctionTypes",
21822             type: "boolean",
21823             affectsSemanticDiagnostics: true,
21824             strictFlag: true,
21825             showInSimplifiedHelpView: true,
21826             category: ts.Diagnostics.Strict_Type_Checking_Options,
21827             description: ts.Diagnostics.Enable_strict_checking_of_function_types
21828         },
21829         {
21830             name: "strictBindCallApply",
21831             type: "boolean",
21832             strictFlag: true,
21833             showInSimplifiedHelpView: true,
21834             category: ts.Diagnostics.Strict_Type_Checking_Options,
21835             description: ts.Diagnostics.Enable_strict_bind_call_and_apply_methods_on_functions
21836         },
21837         {
21838             name: "strictPropertyInitialization",
21839             type: "boolean",
21840             affectsSemanticDiagnostics: true,
21841             strictFlag: true,
21842             showInSimplifiedHelpView: true,
21843             category: ts.Diagnostics.Strict_Type_Checking_Options,
21844             description: ts.Diagnostics.Enable_strict_checking_of_property_initialization_in_classes
21845         },
21846         {
21847             name: "noImplicitThis",
21848             type: "boolean",
21849             affectsSemanticDiagnostics: true,
21850             strictFlag: true,
21851             showInSimplifiedHelpView: true,
21852             category: ts.Diagnostics.Strict_Type_Checking_Options,
21853             description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type,
21854         },
21855         {
21856             name: "alwaysStrict",
21857             type: "boolean",
21858             affectsSourceFile: true,
21859             strictFlag: true,
21860             showInSimplifiedHelpView: true,
21861             category: ts.Diagnostics.Strict_Type_Checking_Options,
21862             description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file
21863         },
21864         {
21865             name: "noUnusedLocals",
21866             type: "boolean",
21867             affectsSemanticDiagnostics: true,
21868             showInSimplifiedHelpView: true,
21869             category: ts.Diagnostics.Additional_Checks,
21870             description: ts.Diagnostics.Report_errors_on_unused_locals,
21871         },
21872         {
21873             name: "noUnusedParameters",
21874             type: "boolean",
21875             affectsSemanticDiagnostics: true,
21876             showInSimplifiedHelpView: true,
21877             category: ts.Diagnostics.Additional_Checks,
21878             description: ts.Diagnostics.Report_errors_on_unused_parameters,
21879         },
21880         {
21881             name: "noImplicitReturns",
21882             type: "boolean",
21883             affectsSemanticDiagnostics: true,
21884             showInSimplifiedHelpView: true,
21885             category: ts.Diagnostics.Additional_Checks,
21886             description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value
21887         },
21888         {
21889             name: "noFallthroughCasesInSwitch",
21890             type: "boolean",
21891             affectsBindDiagnostics: true,
21892             affectsSemanticDiagnostics: true,
21893             showInSimplifiedHelpView: true,
21894             category: ts.Diagnostics.Additional_Checks,
21895             description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement
21896         },
21897         {
21898             name: "moduleResolution",
21899             type: ts.createMapFromTemplate({
21900                 node: ts.ModuleResolutionKind.NodeJs,
21901                 classic: ts.ModuleResolutionKind.Classic,
21902             }),
21903             affectsModuleResolution: true,
21904             paramType: ts.Diagnostics.STRATEGY,
21905             category: ts.Diagnostics.Module_Resolution_Options,
21906             description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6,
21907         },
21908         {
21909             name: "baseUrl",
21910             type: "string",
21911             affectsModuleResolution: true,
21912             isFilePath: true,
21913             category: ts.Diagnostics.Module_Resolution_Options,
21914             description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names
21915         },
21916         {
21917             name: "paths",
21918             type: "object",
21919             affectsModuleResolution: true,
21920             isTSConfigOnly: true,
21921             category: ts.Diagnostics.Module_Resolution_Options,
21922             description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl,
21923             transpileOptionValue: undefined
21924         },
21925         {
21926             name: "rootDirs",
21927             type: "list",
21928             isTSConfigOnly: true,
21929             element: {
21930                 name: "rootDirs",
21931                 type: "string",
21932                 isFilePath: true
21933             },
21934             affectsModuleResolution: true,
21935             category: ts.Diagnostics.Module_Resolution_Options,
21936             description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime,
21937             transpileOptionValue: undefined
21938         },
21939         {
21940             name: "typeRoots",
21941             type: "list",
21942             element: {
21943                 name: "typeRoots",
21944                 type: "string",
21945                 isFilePath: true
21946             },
21947             affectsModuleResolution: true,
21948             category: ts.Diagnostics.Module_Resolution_Options,
21949             description: ts.Diagnostics.List_of_folders_to_include_type_definitions_from
21950         },
21951         {
21952             name: "types",
21953             type: "list",
21954             element: {
21955                 name: "types",
21956                 type: "string"
21957             },
21958             affectsModuleResolution: true,
21959             showInSimplifiedHelpView: true,
21960             category: ts.Diagnostics.Module_Resolution_Options,
21961             description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation,
21962             transpileOptionValue: undefined
21963         },
21964         {
21965             name: "allowSyntheticDefaultImports",
21966             type: "boolean",
21967             affectsSemanticDiagnostics: true,
21968             category: ts.Diagnostics.Module_Resolution_Options,
21969             description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking
21970         },
21971         {
21972             name: "esModuleInterop",
21973             type: "boolean",
21974             affectsSemanticDiagnostics: true,
21975             affectsEmit: true,
21976             showInSimplifiedHelpView: true,
21977             category: ts.Diagnostics.Module_Resolution_Options,
21978             description: ts.Diagnostics.Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports
21979         },
21980         {
21981             name: "preserveSymlinks",
21982             type: "boolean",
21983             category: ts.Diagnostics.Module_Resolution_Options,
21984             description: ts.Diagnostics.Do_not_resolve_the_real_path_of_symlinks,
21985         },
21986         {
21987             name: "allowUmdGlobalAccess",
21988             type: "boolean",
21989             affectsSemanticDiagnostics: true,
21990             category: ts.Diagnostics.Module_Resolution_Options,
21991             description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
21992         },
21993         {
21994             name: "sourceRoot",
21995             type: "string",
21996             affectsEmit: true,
21997             paramType: ts.Diagnostics.LOCATION,
21998             category: ts.Diagnostics.Source_Map_Options,
21999             description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations,
22000         },
22001         {
22002             name: "mapRoot",
22003             type: "string",
22004             affectsEmit: true,
22005             paramType: ts.Diagnostics.LOCATION,
22006             category: ts.Diagnostics.Source_Map_Options,
22007             description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations,
22008         },
22009         {
22010             name: "inlineSourceMap",
22011             type: "boolean",
22012             affectsEmit: true,
22013             category: ts.Diagnostics.Source_Map_Options,
22014             description: ts.Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file
22015         },
22016         {
22017             name: "inlineSources",
22018             type: "boolean",
22019             affectsEmit: true,
22020             category: ts.Diagnostics.Source_Map_Options,
22021             description: ts.Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set
22022         },
22023         {
22024             name: "experimentalDecorators",
22025             type: "boolean",
22026             affectsSemanticDiagnostics: true,
22027             category: ts.Diagnostics.Experimental_Options,
22028             description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators
22029         },
22030         {
22031             name: "emitDecoratorMetadata",
22032             type: "boolean",
22033             affectsSemanticDiagnostics: true,
22034             affectsEmit: true,
22035             category: ts.Diagnostics.Experimental_Options,
22036             description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators
22037         },
22038         {
22039             name: "jsxFactory",
22040             type: "string",
22041             category: ts.Diagnostics.Advanced_Options,
22042             description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h
22043         },
22044         {
22045             name: "resolveJsonModule",
22046             type: "boolean",
22047             affectsModuleResolution: true,
22048             category: ts.Diagnostics.Advanced_Options,
22049             description: ts.Diagnostics.Include_modules_imported_with_json_extension
22050         },
22051         {
22052             name: "out",
22053             type: "string",
22054             affectsEmit: true,
22055             isFilePath: false,
22056             category: ts.Diagnostics.Advanced_Options,
22057             paramType: ts.Diagnostics.FILE,
22058             description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file,
22059             transpileOptionValue: undefined
22060         },
22061         {
22062             name: "reactNamespace",
22063             type: "string",
22064             affectsEmit: true,
22065             category: ts.Diagnostics.Advanced_Options,
22066             description: ts.Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit
22067         },
22068         {
22069             name: "skipDefaultLibCheck",
22070             type: "boolean",
22071             category: ts.Diagnostics.Advanced_Options,
22072             description: ts.Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files
22073         },
22074         {
22075             name: "charset",
22076             type: "string",
22077             category: ts.Diagnostics.Advanced_Options,
22078             description: ts.Diagnostics.The_character_set_of_the_input_files
22079         },
22080         {
22081             name: "emitBOM",
22082             type: "boolean",
22083             affectsEmit: true,
22084             category: ts.Diagnostics.Advanced_Options,
22085             description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files
22086         },
22087         {
22088             name: "newLine",
22089             type: ts.createMapFromTemplate({
22090                 crlf: 0,
22091                 lf: 1
22092             }),
22093             affectsEmit: true,
22094             paramType: ts.Diagnostics.NEWLINE,
22095             category: ts.Diagnostics.Advanced_Options,
22096             description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix,
22097         },
22098         {
22099             name: "noErrorTruncation",
22100             type: "boolean",
22101             affectsSemanticDiagnostics: true,
22102             category: ts.Diagnostics.Advanced_Options,
22103             description: ts.Diagnostics.Do_not_truncate_error_messages
22104         },
22105         {
22106             name: "noLib",
22107             type: "boolean",
22108             affectsModuleResolution: true,
22109             category: ts.Diagnostics.Advanced_Options,
22110             description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts,
22111             transpileOptionValue: true
22112         },
22113         {
22114             name: "noResolve",
22115             type: "boolean",
22116             affectsModuleResolution: true,
22117             category: ts.Diagnostics.Advanced_Options,
22118             description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files,
22119             transpileOptionValue: true
22120         },
22121         {
22122             name: "stripInternal",
22123             type: "boolean",
22124             affectsEmit: true,
22125             category: ts.Diagnostics.Advanced_Options,
22126             description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation,
22127         },
22128         {
22129             name: "disableSizeLimit",
22130             type: "boolean",
22131             affectsSourceFile: true,
22132             category: ts.Diagnostics.Advanced_Options,
22133             description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects
22134         },
22135         {
22136             name: "disableSourceOfProjectReferenceRedirect",
22137             type: "boolean",
22138             isTSConfigOnly: true,
22139             category: ts.Diagnostics.Advanced_Options,
22140             description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects
22141         },
22142         {
22143             name: "disableSolutionSearching",
22144             type: "boolean",
22145             isTSConfigOnly: true,
22146             category: ts.Diagnostics.Advanced_Options,
22147             description: ts.Diagnostics.Disable_solution_searching_for_this_project
22148         },
22149         {
22150             name: "noImplicitUseStrict",
22151             type: "boolean",
22152             affectsSemanticDiagnostics: true,
22153             category: ts.Diagnostics.Advanced_Options,
22154             description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output
22155         },
22156         {
22157             name: "noEmitHelpers",
22158             type: "boolean",
22159             affectsEmit: true,
22160             category: ts.Diagnostics.Advanced_Options,
22161             description: ts.Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output
22162         },
22163         {
22164             name: "noEmitOnError",
22165             type: "boolean",
22166             affectsEmit: true,
22167             category: ts.Diagnostics.Advanced_Options,
22168             description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported,
22169             transpileOptionValue: undefined
22170         },
22171         {
22172             name: "preserveConstEnums",
22173             type: "boolean",
22174             affectsEmit: true,
22175             category: ts.Diagnostics.Advanced_Options,
22176             description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code
22177         },
22178         {
22179             name: "declarationDir",
22180             type: "string",
22181             affectsEmit: true,
22182             isFilePath: true,
22183             paramType: ts.Diagnostics.DIRECTORY,
22184             category: ts.Diagnostics.Advanced_Options,
22185             description: ts.Diagnostics.Output_directory_for_generated_declaration_files,
22186             transpileOptionValue: undefined
22187         },
22188         {
22189             name: "skipLibCheck",
22190             type: "boolean",
22191             category: ts.Diagnostics.Advanced_Options,
22192             description: ts.Diagnostics.Skip_type_checking_of_declaration_files,
22193         },
22194         {
22195             name: "allowUnusedLabels",
22196             type: "boolean",
22197             affectsBindDiagnostics: true,
22198             affectsSemanticDiagnostics: true,
22199             category: ts.Diagnostics.Advanced_Options,
22200             description: ts.Diagnostics.Do_not_report_errors_on_unused_labels
22201         },
22202         {
22203             name: "allowUnreachableCode",
22204             type: "boolean",
22205             affectsBindDiagnostics: true,
22206             affectsSemanticDiagnostics: true,
22207             category: ts.Diagnostics.Advanced_Options,
22208             description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code
22209         },
22210         {
22211             name: "suppressExcessPropertyErrors",
22212             type: "boolean",
22213             affectsSemanticDiagnostics: true,
22214             category: ts.Diagnostics.Advanced_Options,
22215             description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals,
22216         },
22217         {
22218             name: "suppressImplicitAnyIndexErrors",
22219             type: "boolean",
22220             affectsSemanticDiagnostics: true,
22221             category: ts.Diagnostics.Advanced_Options,
22222             description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures,
22223         },
22224         {
22225             name: "forceConsistentCasingInFileNames",
22226             type: "boolean",
22227             affectsModuleResolution: true,
22228             category: ts.Diagnostics.Advanced_Options,
22229             description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file
22230         },
22231         {
22232             name: "maxNodeModuleJsDepth",
22233             type: "number",
22234             affectsModuleResolution: true,
22235             category: ts.Diagnostics.Advanced_Options,
22236             description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files
22237         },
22238         {
22239             name: "noStrictGenericChecks",
22240             type: "boolean",
22241             affectsSemanticDiagnostics: true,
22242             category: ts.Diagnostics.Advanced_Options,
22243             description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types,
22244         },
22245         {
22246             name: "useDefineForClassFields",
22247             type: "boolean",
22248             affectsSemanticDiagnostics: true,
22249             affectsEmit: true,
22250             category: ts.Diagnostics.Advanced_Options,
22251             description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set,
22252         },
22253         {
22254             name: "keyofStringsOnly",
22255             type: "boolean",
22256             category: ts.Diagnostics.Advanced_Options,
22257             description: ts.Diagnostics.Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols,
22258         },
22259         {
22260             name: "plugins",
22261             type: "list",
22262             isTSConfigOnly: true,
22263             element: {
22264                 name: "plugin",
22265                 type: "object"
22266             },
22267             description: ts.Diagnostics.List_of_language_service_plugins
22268         },
22269     ]);
22270     ts.semanticDiagnosticsOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsSemanticDiagnostics; });
22271     ts.affectsEmitOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsEmit; });
22272     ts.moduleResolutionOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsModuleResolution; });
22273     ts.sourceFileAffectingCompilerOptions = ts.optionDeclarations.filter(function (option) {
22274         return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics;
22275     });
22276     ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) {
22277         return ts.hasProperty(option, "transpileOptionValue");
22278     });
22279     ts.buildOpts = __spreadArrays(ts.commonOptionsWithBuild, [
22280         {
22281             name: "verbose",
22282             shortName: "v",
22283             category: ts.Diagnostics.Command_line_Options,
22284             description: ts.Diagnostics.Enable_verbose_logging,
22285             type: "boolean"
22286         },
22287         {
22288             name: "dry",
22289             shortName: "d",
22290             category: ts.Diagnostics.Command_line_Options,
22291             description: ts.Diagnostics.Show_what_would_be_built_or_deleted_if_specified_with_clean,
22292             type: "boolean"
22293         },
22294         {
22295             name: "force",
22296             shortName: "f",
22297             category: ts.Diagnostics.Command_line_Options,
22298             description: ts.Diagnostics.Build_all_projects_including_those_that_appear_to_be_up_to_date,
22299             type: "boolean"
22300         },
22301         {
22302             name: "clean",
22303             category: ts.Diagnostics.Command_line_Options,
22304             description: ts.Diagnostics.Delete_the_outputs_of_all_projects,
22305             type: "boolean"
22306         }
22307     ]);
22308     ts.typeAcquisitionDeclarations = [
22309         {
22310             name: "enableAutoDiscovery",
22311             type: "boolean",
22312         },
22313         {
22314             name: "enable",
22315             type: "boolean",
22316         },
22317         {
22318             name: "include",
22319             type: "list",
22320             element: {
22321                 name: "include",
22322                 type: "string"
22323             }
22324         },
22325         {
22326             name: "exclude",
22327             type: "list",
22328             element: {
22329                 name: "exclude",
22330                 type: "string"
22331             }
22332         }
22333     ];
22334     function createOptionNameMap(optionDeclarations) {
22335         var optionsNameMap = ts.createMap();
22336         var shortOptionNames = ts.createMap();
22337         ts.forEach(optionDeclarations, function (option) {
22338             optionsNameMap.set(option.name.toLowerCase(), option);
22339             if (option.shortName) {
22340                 shortOptionNames.set(option.shortName, option.name);
22341             }
22342         });
22343         return { optionsNameMap: optionsNameMap, shortOptionNames: shortOptionNames };
22344     }
22345     ts.createOptionNameMap = createOptionNameMap;
22346     var optionsNameMapCache;
22347     function getOptionsNameMap() {
22348         return optionsNameMapCache || (optionsNameMapCache = createOptionNameMap(ts.optionDeclarations));
22349     }
22350     ts.getOptionsNameMap = getOptionsNameMap;
22351     ts.defaultInitCompilerOptions = {
22352         module: ts.ModuleKind.CommonJS,
22353         target: 1,
22354         strict: true,
22355         esModuleInterop: true,
22356         forceConsistentCasingInFileNames: true,
22357         skipLibCheck: true
22358     };
22359     function convertEnableAutoDiscoveryToEnable(typeAcquisition) {
22360         if (typeAcquisition && typeAcquisition.enableAutoDiscovery !== undefined && typeAcquisition.enable === undefined) {
22361             return {
22362                 enable: typeAcquisition.enableAutoDiscovery,
22363                 include: typeAcquisition.include || [],
22364                 exclude: typeAcquisition.exclude || []
22365             };
22366         }
22367         return typeAcquisition;
22368     }
22369     ts.convertEnableAutoDiscoveryToEnable = convertEnableAutoDiscoveryToEnable;
22370     function createCompilerDiagnosticForInvalidCustomType(opt) {
22371         return createDiagnosticForInvalidCustomType(opt, ts.createCompilerDiagnostic);
22372     }
22373     ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType;
22374     function createDiagnosticForInvalidCustomType(opt, createDiagnostic) {
22375         var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", ");
22376         return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType);
22377     }
22378     function parseCustomTypeOption(opt, value, errors) {
22379         return convertJsonOptionOfCustomType(opt, trimString(value || ""), errors);
22380     }
22381     ts.parseCustomTypeOption = parseCustomTypeOption;
22382     function parseListTypeOption(opt, value, errors) {
22383         if (value === void 0) { value = ""; }
22384         value = trimString(value);
22385         if (ts.startsWith(value, "-")) {
22386             return undefined;
22387         }
22388         if (value === "") {
22389             return [];
22390         }
22391         var values = value.split(",");
22392         switch (opt.element.type) {
22393             case "number":
22394                 return ts.map(values, parseInt);
22395             case "string":
22396                 return ts.map(values, function (v) { return v || ""; });
22397             default:
22398                 return ts.mapDefined(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); });
22399         }
22400     }
22401     ts.parseListTypeOption = parseListTypeOption;
22402     function getOptionName(option) {
22403         return option.name;
22404     }
22405     function createUnknownOptionError(unknownOption, diagnostics, createDiagnostics, unknownOptionErrorText) {
22406         var possibleOption = ts.getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName);
22407         return possibleOption ?
22408             createDiagnostics(diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) :
22409             createDiagnostics(diagnostics.unknownOptionDiagnostic, unknownOptionErrorText || unknownOption);
22410     }
22411     function parseCommandLineWorker(diagnostics, commandLine, readFile) {
22412         var options = {};
22413         var watchOptions;
22414         var fileNames = [];
22415         var errors = [];
22416         parseStrings(commandLine);
22417         return {
22418             options: options,
22419             watchOptions: watchOptions,
22420             fileNames: fileNames,
22421             errors: errors
22422         };
22423         function parseStrings(args) {
22424             var i = 0;
22425             while (i < args.length) {
22426                 var s = args[i];
22427                 i++;
22428                 if (s.charCodeAt(0) === 64) {
22429                     parseResponseFile(s.slice(1));
22430                 }
22431                 else if (s.charCodeAt(0) === 45) {
22432                     var inputOptionName = s.slice(s.charCodeAt(1) === 45 ? 2 : 1);
22433                     var opt = getOptionDeclarationFromName(diagnostics.getOptionsNameMap, inputOptionName, true);
22434                     if (opt) {
22435                         i = parseOptionValue(args, i, diagnostics, opt, options, errors);
22436                     }
22437                     else {
22438                         var watchOpt = getOptionDeclarationFromName(watchOptionsDidYouMeanDiagnostics.getOptionsNameMap, inputOptionName, true);
22439                         if (watchOpt) {
22440                             i = parseOptionValue(args, i, watchOptionsDidYouMeanDiagnostics, watchOpt, watchOptions || (watchOptions = {}), errors);
22441                         }
22442                         else {
22443                             errors.push(createUnknownOptionError(inputOptionName, diagnostics, ts.createCompilerDiagnostic, s));
22444                         }
22445                     }
22446                 }
22447                 else {
22448                     fileNames.push(s);
22449                 }
22450             }
22451         }
22452         function parseResponseFile(fileName) {
22453             var text = tryReadFile(fileName, readFile || (function (fileName) { return ts.sys.readFile(fileName); }));
22454             if (!ts.isString(text)) {
22455                 errors.push(text);
22456                 return;
22457             }
22458             var args = [];
22459             var pos = 0;
22460             while (true) {
22461                 while (pos < text.length && text.charCodeAt(pos) <= 32)
22462                     pos++;
22463                 if (pos >= text.length)
22464                     break;
22465                 var start = pos;
22466                 if (text.charCodeAt(start) === 34) {
22467                     pos++;
22468                     while (pos < text.length && text.charCodeAt(pos) !== 34)
22469                         pos++;
22470                     if (pos < text.length) {
22471                         args.push(text.substring(start + 1, pos));
22472                         pos++;
22473                     }
22474                     else {
22475                         errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName));
22476                     }
22477                 }
22478                 else {
22479                     while (text.charCodeAt(pos) > 32)
22480                         pos++;
22481                     args.push(text.substring(start, pos));
22482                 }
22483             }
22484             parseStrings(args);
22485         }
22486     }
22487     ts.parseCommandLineWorker = parseCommandLineWorker;
22488     function parseOptionValue(args, i, diagnostics, opt, options, errors) {
22489         if (opt.isTSConfigOnly) {
22490             var optValue = args[i];
22491             if (optValue === "null") {
22492                 options[opt.name] = undefined;
22493                 i++;
22494             }
22495             else if (opt.type === "boolean") {
22496                 if (optValue === "false") {
22497                     options[opt.name] = false;
22498                     i++;
22499                 }
22500                 else {
22501                     if (optValue === "true")
22502                         i++;
22503                     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));
22504                 }
22505             }
22506             else {
22507                 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));
22508                 if (optValue && !ts.startsWith(optValue, "-"))
22509                     i++;
22510             }
22511         }
22512         else {
22513             if (!args[i] && opt.type !== "boolean") {
22514                 errors.push(ts.createCompilerDiagnostic(diagnostics.optionTypeMismatchDiagnostic, opt.name, getCompilerOptionValueTypeString(opt)));
22515             }
22516             if (args[i] !== "null") {
22517                 switch (opt.type) {
22518                     case "number":
22519                         options[opt.name] = parseInt(args[i]);
22520                         i++;
22521                         break;
22522                     case "boolean":
22523                         var optValue = args[i];
22524                         options[opt.name] = optValue !== "false";
22525                         if (optValue === "false" || optValue === "true") {
22526                             i++;
22527                         }
22528                         break;
22529                     case "string":
22530                         options[opt.name] = args[i] || "";
22531                         i++;
22532                         break;
22533                     case "list":
22534                         var result = parseListTypeOption(opt, args[i], errors);
22535                         options[opt.name] = result || [];
22536                         if (result) {
22537                             i++;
22538                         }
22539                         break;
22540                     default:
22541                         options[opt.name] = parseCustomTypeOption(opt, args[i], errors);
22542                         i++;
22543                         break;
22544                 }
22545             }
22546             else {
22547                 options[opt.name] = undefined;
22548                 i++;
22549             }
22550         }
22551         return i;
22552     }
22553     ts.compilerOptionsDidYouMeanDiagnostics = {
22554         getOptionsNameMap: getOptionsNameMap,
22555         optionDeclarations: ts.optionDeclarations,
22556         unknownOptionDiagnostic: ts.Diagnostics.Unknown_compiler_option_0,
22557         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_compiler_option_0_Did_you_mean_1,
22558         optionTypeMismatchDiagnostic: ts.Diagnostics.Compiler_option_0_expects_an_argument
22559     };
22560     function parseCommandLine(commandLine, readFile) {
22561         return parseCommandLineWorker(ts.compilerOptionsDidYouMeanDiagnostics, commandLine, readFile);
22562     }
22563     ts.parseCommandLine = parseCommandLine;
22564     function getOptionFromName(optionName, allowShort) {
22565         return getOptionDeclarationFromName(getOptionsNameMap, optionName, allowShort);
22566     }
22567     ts.getOptionFromName = getOptionFromName;
22568     function getOptionDeclarationFromName(getOptionNameMap, optionName, allowShort) {
22569         if (allowShort === void 0) { allowShort = false; }
22570         optionName = optionName.toLowerCase();
22571         var _a = getOptionNameMap(), optionsNameMap = _a.optionsNameMap, shortOptionNames = _a.shortOptionNames;
22572         if (allowShort) {
22573             var short = shortOptionNames.get(optionName);
22574             if (short !== undefined) {
22575                 optionName = short;
22576             }
22577         }
22578         return optionsNameMap.get(optionName);
22579     }
22580     var buildOptionsNameMapCache;
22581     function getBuildOptionsNameMap() {
22582         return buildOptionsNameMapCache || (buildOptionsNameMapCache = createOptionNameMap(ts.buildOpts));
22583     }
22584     var buildOptionsDidYouMeanDiagnostics = {
22585         getOptionsNameMap: getBuildOptionsNameMap,
22586         optionDeclarations: ts.buildOpts,
22587         unknownOptionDiagnostic: ts.Diagnostics.Unknown_build_option_0,
22588         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_build_option_0_Did_you_mean_1,
22589         optionTypeMismatchDiagnostic: ts.Diagnostics.Build_option_0_requires_a_value_of_type_1
22590     };
22591     function parseBuildCommand(args) {
22592         var _a = parseCommandLineWorker(buildOptionsDidYouMeanDiagnostics, args), options = _a.options, watchOptions = _a.watchOptions, projects = _a.fileNames, errors = _a.errors;
22593         var buildOptions = options;
22594         if (projects.length === 0) {
22595             projects.push(".");
22596         }
22597         if (buildOptions.clean && buildOptions.force) {
22598             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "force"));
22599         }
22600         if (buildOptions.clean && buildOptions.verbose) {
22601             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "verbose"));
22602         }
22603         if (buildOptions.clean && buildOptions.watch) {
22604             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "watch"));
22605         }
22606         if (buildOptions.watch && buildOptions.dry) {
22607             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "watch", "dry"));
22608         }
22609         return { buildOptions: buildOptions, watchOptions: watchOptions, projects: projects, errors: errors };
22610     }
22611     ts.parseBuildCommand = parseBuildCommand;
22612     function getDiagnosticText(_message) {
22613         var _args = [];
22614         for (var _i = 1; _i < arguments.length; _i++) {
22615             _args[_i - 1] = arguments[_i];
22616         }
22617         var diagnostic = ts.createCompilerDiagnostic.apply(undefined, arguments);
22618         return diagnostic.messageText;
22619     }
22620     ts.getDiagnosticText = getDiagnosticText;
22621     function getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, extendedConfigCache, watchOptionsToExtend, extraFileExtensions) {
22622         var configFileText = tryReadFile(configFileName, function (fileName) { return host.readFile(fileName); });
22623         if (!ts.isString(configFileText)) {
22624             host.onUnRecoverableConfigFileDiagnostic(configFileText);
22625             return undefined;
22626         }
22627         var result = ts.parseJsonText(configFileName, configFileText);
22628         var cwd = host.getCurrentDirectory();
22629         result.path = ts.toPath(configFileName, cwd, ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames));
22630         result.resolvedPath = result.path;
22631         result.originalFileName = result.fileName;
22632         return parseJsonSourceFileConfigFileContent(result, host, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), cwd), optionsToExtend, ts.getNormalizedAbsolutePath(configFileName, cwd), undefined, extraFileExtensions, extendedConfigCache, watchOptionsToExtend);
22633     }
22634     ts.getParsedCommandLineOfConfigFile = getParsedCommandLineOfConfigFile;
22635     function readConfigFile(fileName, readFile) {
22636         var textOrDiagnostic = tryReadFile(fileName, readFile);
22637         return ts.isString(textOrDiagnostic) ? parseConfigFileTextToJson(fileName, textOrDiagnostic) : { config: {}, error: textOrDiagnostic };
22638     }
22639     ts.readConfigFile = readConfigFile;
22640     function parseConfigFileTextToJson(fileName, jsonText) {
22641         var jsonSourceFile = ts.parseJsonText(fileName, jsonText);
22642         return {
22643             config: convertToObject(jsonSourceFile, jsonSourceFile.parseDiagnostics),
22644             error: jsonSourceFile.parseDiagnostics.length ? jsonSourceFile.parseDiagnostics[0] : undefined
22645         };
22646     }
22647     ts.parseConfigFileTextToJson = parseConfigFileTextToJson;
22648     function readJsonConfigFile(fileName, readFile) {
22649         var textOrDiagnostic = tryReadFile(fileName, readFile);
22650         return ts.isString(textOrDiagnostic) ? ts.parseJsonText(fileName, textOrDiagnostic) : { parseDiagnostics: [textOrDiagnostic] };
22651     }
22652     ts.readJsonConfigFile = readJsonConfigFile;
22653     function tryReadFile(fileName, readFile) {
22654         var text;
22655         try {
22656             text = readFile(fileName);
22657         }
22658         catch (e) {
22659             return ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message);
22660         }
22661         return text === undefined ? ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0, fileName) : text;
22662     }
22663     ts.tryReadFile = tryReadFile;
22664     function commandLineOptionsToMap(options) {
22665         return ts.arrayToMap(options, getOptionName);
22666     }
22667     var typeAcquisitionDidYouMeanDiagnostics = {
22668         optionDeclarations: ts.typeAcquisitionDeclarations,
22669         unknownOptionDiagnostic: ts.Diagnostics.Unknown_type_acquisition_option_0,
22670         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_type_acquisition_option_0_Did_you_mean_1,
22671     };
22672     var watchOptionsNameMapCache;
22673     function getWatchOptionsNameMap() {
22674         return watchOptionsNameMapCache || (watchOptionsNameMapCache = createOptionNameMap(ts.optionsForWatch));
22675     }
22676     var watchOptionsDidYouMeanDiagnostics = {
22677         getOptionsNameMap: getWatchOptionsNameMap,
22678         optionDeclarations: ts.optionsForWatch,
22679         unknownOptionDiagnostic: ts.Diagnostics.Unknown_watch_option_0,
22680         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_watch_option_0_Did_you_mean_1,
22681         optionTypeMismatchDiagnostic: ts.Diagnostics.Watch_option_0_requires_a_value_of_type_1
22682     };
22683     var commandLineCompilerOptionsMapCache;
22684     function getCommandLineCompilerOptionsMap() {
22685         return commandLineCompilerOptionsMapCache || (commandLineCompilerOptionsMapCache = commandLineOptionsToMap(ts.optionDeclarations));
22686     }
22687     var commandLineWatchOptionsMapCache;
22688     function getCommandLineWatchOptionsMap() {
22689         return commandLineWatchOptionsMapCache || (commandLineWatchOptionsMapCache = commandLineOptionsToMap(ts.optionsForWatch));
22690     }
22691     var commandLineTypeAcquisitionMapCache;
22692     function getCommandLineTypeAcquisitionMap() {
22693         return commandLineTypeAcquisitionMapCache || (commandLineTypeAcquisitionMapCache = commandLineOptionsToMap(ts.typeAcquisitionDeclarations));
22694     }
22695     var _tsconfigRootOptions;
22696     function getTsconfigRootOptionsMap() {
22697         if (_tsconfigRootOptions === undefined) {
22698             _tsconfigRootOptions = {
22699                 name: undefined,
22700                 type: "object",
22701                 elementOptions: commandLineOptionsToMap([
22702                     {
22703                         name: "compilerOptions",
22704                         type: "object",
22705                         elementOptions: getCommandLineCompilerOptionsMap(),
22706                         extraKeyDiagnostics: ts.compilerOptionsDidYouMeanDiagnostics,
22707                     },
22708                     {
22709                         name: "watchOptions",
22710                         type: "object",
22711                         elementOptions: getCommandLineWatchOptionsMap(),
22712                         extraKeyDiagnostics: watchOptionsDidYouMeanDiagnostics,
22713                     },
22714                     {
22715                         name: "typingOptions",
22716                         type: "object",
22717                         elementOptions: getCommandLineTypeAcquisitionMap(),
22718                         extraKeyDiagnostics: typeAcquisitionDidYouMeanDiagnostics,
22719                     },
22720                     {
22721                         name: "typeAcquisition",
22722                         type: "object",
22723                         elementOptions: getCommandLineTypeAcquisitionMap(),
22724                         extraKeyDiagnostics: typeAcquisitionDidYouMeanDiagnostics
22725                     },
22726                     {
22727                         name: "extends",
22728                         type: "string"
22729                     },
22730                     {
22731                         name: "references",
22732                         type: "list",
22733                         element: {
22734                             name: "references",
22735                             type: "object"
22736                         }
22737                     },
22738                     {
22739                         name: "files",
22740                         type: "list",
22741                         element: {
22742                             name: "files",
22743                             type: "string"
22744                         }
22745                     },
22746                     {
22747                         name: "include",
22748                         type: "list",
22749                         element: {
22750                             name: "include",
22751                             type: "string"
22752                         }
22753                     },
22754                     {
22755                         name: "exclude",
22756                         type: "list",
22757                         element: {
22758                             name: "exclude",
22759                             type: "string"
22760                         }
22761                     },
22762                     ts.compileOnSaveCommandLineOption
22763                 ])
22764             };
22765         }
22766         return _tsconfigRootOptions;
22767     }
22768     function convertToObject(sourceFile, errors) {
22769         return convertToObjectWorker(sourceFile, errors, true, undefined, undefined);
22770     }
22771     ts.convertToObject = convertToObject;
22772     function convertToObjectWorker(sourceFile, errors, returnValue, knownRootOptions, jsonConversionNotifier) {
22773         if (!sourceFile.statements.length) {
22774             return returnValue ? {} : undefined;
22775         }
22776         return convertPropertyValueToJson(sourceFile.statements[0].expression, knownRootOptions);
22777         function isRootOptionMap(knownOptions) {
22778             return knownRootOptions && knownRootOptions.elementOptions === knownOptions;
22779         }
22780         function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) {
22781             var result = returnValue ? {} : undefined;
22782             var _loop_3 = function (element) {
22783                 if (element.kind !== 281) {
22784                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected));
22785                     return "continue";
22786                 }
22787                 if (element.questionToken) {
22788                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.questionToken, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?"));
22789                 }
22790                 if (!isDoubleQuotedString(element.name)) {
22791                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, ts.Diagnostics.String_literal_with_double_quotes_expected));
22792                 }
22793                 var textOfKey = ts.isComputedNonLiteralName(element.name) ? undefined : ts.getTextOfPropertyName(element.name);
22794                 var keyText = textOfKey && ts.unescapeLeadingUnderscores(textOfKey);
22795                 var option = keyText && knownOptions ? knownOptions.get(keyText) : undefined;
22796                 if (keyText && extraKeyDiagnostics && !option) {
22797                     if (knownOptions) {
22798                         errors.push(createUnknownOptionError(keyText, extraKeyDiagnostics, function (message, arg0, arg1) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, message, arg0, arg1); }));
22799                     }
22800                     else {
22801                         errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, extraKeyDiagnostics.unknownOptionDiagnostic, keyText));
22802                     }
22803                 }
22804                 var value = convertPropertyValueToJson(element.initializer, option);
22805                 if (typeof keyText !== "undefined") {
22806                     if (returnValue) {
22807                         result[keyText] = value;
22808                     }
22809                     if (jsonConversionNotifier &&
22810                         (parentOption || isRootOptionMap(knownOptions))) {
22811                         var isValidOptionValue = isCompilerOptionsValue(option, value);
22812                         if (parentOption) {
22813                             if (isValidOptionValue) {
22814                                 jsonConversionNotifier.onSetValidOptionKeyValueInParent(parentOption, option, value);
22815                             }
22816                         }
22817                         else if (isRootOptionMap(knownOptions)) {
22818                             if (isValidOptionValue) {
22819                                 jsonConversionNotifier.onSetValidOptionKeyValueInRoot(keyText, element.name, value, element.initializer);
22820                             }
22821                             else if (!option) {
22822                                 jsonConversionNotifier.onSetUnknownOptionKeyValueInRoot(keyText, element.name, value, element.initializer);
22823                             }
22824                         }
22825                     }
22826                 }
22827             };
22828             for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
22829                 var element = _a[_i];
22830                 _loop_3(element);
22831             }
22832             return result;
22833         }
22834         function convertArrayLiteralExpressionToJson(elements, elementOption) {
22835             if (!returnValue) {
22836                 return elements.forEach(function (element) { return convertPropertyValueToJson(element, elementOption); });
22837             }
22838             return ts.filter(elements.map(function (element) { return convertPropertyValueToJson(element, elementOption); }), function (v) { return v !== undefined; });
22839         }
22840         function convertPropertyValueToJson(valueExpression, option) {
22841             switch (valueExpression.kind) {
22842                 case 106:
22843                     reportInvalidOptionValue(option && option.type !== "boolean");
22844                     return true;
22845                 case 91:
22846                     reportInvalidOptionValue(option && option.type !== "boolean");
22847                     return false;
22848                 case 100:
22849                     reportInvalidOptionValue(option && option.name === "extends");
22850                     return null;
22851                 case 10:
22852                     if (!isDoubleQuotedString(valueExpression)) {
22853                         errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected));
22854                     }
22855                     reportInvalidOptionValue(option && (ts.isString(option.type) && option.type !== "string"));
22856                     var text = valueExpression.text;
22857                     if (option && !ts.isString(option.type)) {
22858                         var customOption = option;
22859                         if (!customOption.type.has(text.toLowerCase())) {
22860                             errors.push(createDiagnosticForInvalidCustomType(customOption, function (message, arg0, arg1) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, message, arg0, arg1); }));
22861                         }
22862                     }
22863                     return text;
22864                 case 8:
22865                     reportInvalidOptionValue(option && option.type !== "number");
22866                     return Number(valueExpression.text);
22867                 case 207:
22868                     if (valueExpression.operator !== 40 || valueExpression.operand.kind !== 8) {
22869                         break;
22870                     }
22871                     reportInvalidOptionValue(option && option.type !== "number");
22872                     return -Number(valueExpression.operand.text);
22873                 case 193:
22874                     reportInvalidOptionValue(option && option.type !== "object");
22875                     var objectLiteralExpression = valueExpression;
22876                     if (option) {
22877                         var _a = option, elementOptions = _a.elementOptions, extraKeyDiagnostics = _a.extraKeyDiagnostics, optionName = _a.name;
22878                         return convertObjectLiteralExpressionToJson(objectLiteralExpression, elementOptions, extraKeyDiagnostics, optionName);
22879                     }
22880                     else {
22881                         return convertObjectLiteralExpressionToJson(objectLiteralExpression, undefined, undefined, undefined);
22882                     }
22883                 case 192:
22884                     reportInvalidOptionValue(option && option.type !== "list");
22885                     return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element);
22886             }
22887             if (option) {
22888                 reportInvalidOptionValue(true);
22889             }
22890             else {
22891                 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));
22892             }
22893             return undefined;
22894             function reportInvalidOptionValue(isError) {
22895                 if (isError) {
22896                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, option.name, getCompilerOptionValueTypeString(option)));
22897                 }
22898             }
22899         }
22900         function isDoubleQuotedString(node) {
22901             return ts.isStringLiteral(node) && ts.isStringDoubleQuoted(node, sourceFile);
22902         }
22903     }
22904     ts.convertToObjectWorker = convertToObjectWorker;
22905     function getCompilerOptionValueTypeString(option) {
22906         return option.type === "list" ?
22907             "Array" :
22908             ts.isString(option.type) ? option.type : "string";
22909     }
22910     function isCompilerOptionsValue(option, value) {
22911         if (option) {
22912             if (isNullOrUndefined(value))
22913                 return true;
22914             if (option.type === "list") {
22915                 return ts.isArray(value);
22916             }
22917             var expectedType = ts.isString(option.type) ? option.type : "string";
22918             return typeof value === expectedType;
22919         }
22920         return false;
22921     }
22922     function convertToTSConfig(configParseResult, configFileName, host) {
22923         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames);
22924         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); });
22925         var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames });
22926         var watchOptionMap = configParseResult.watchOptions && serializeWatchOptions(configParseResult.watchOptions);
22927         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 ? {
22928             include: filterSameAsDefaultInclude(configParseResult.configFileSpecs.validatedIncludeSpecs),
22929             exclude: configParseResult.configFileSpecs.validatedExcludeSpecs
22930         } : {})), { compileOnSave: !!configParseResult.compileOnSave ? true : undefined });
22931         return config;
22932     }
22933     ts.convertToTSConfig = convertToTSConfig;
22934     function optionMapToObject(optionMap) {
22935         return __assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) {
22936             var _a;
22937             return (__assign(__assign({}, prev), (_a = {}, _a[cur[0]] = cur[1], _a)));
22938         }, {}));
22939     }
22940     function filterSameAsDefaultInclude(specs) {
22941         if (!ts.length(specs))
22942             return undefined;
22943         if (ts.length(specs) !== 1)
22944             return specs;
22945         if (specs[0] === "**/*")
22946             return undefined;
22947         return specs;
22948     }
22949     function matchesSpecs(path, includeSpecs, excludeSpecs, host) {
22950         if (!includeSpecs)
22951             return function (_) { return true; };
22952         var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, host.useCaseSensitiveFileNames, host.getCurrentDirectory());
22953         var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, host.useCaseSensitiveFileNames);
22954         var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, host.useCaseSensitiveFileNames);
22955         if (includeRe) {
22956             if (excludeRe) {
22957                 return function (path) { return !(includeRe.test(path) && !excludeRe.test(path)); };
22958             }
22959             return function (path) { return !includeRe.test(path); };
22960         }
22961         if (excludeRe) {
22962             return function (path) { return excludeRe.test(path); };
22963         }
22964         return function (_) { return true; };
22965     }
22966     function getCustomTypeMapOfCommandLineOption(optionDefinition) {
22967         if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean" || optionDefinition.type === "object") {
22968             return undefined;
22969         }
22970         else if (optionDefinition.type === "list") {
22971             return getCustomTypeMapOfCommandLineOption(optionDefinition.element);
22972         }
22973         else {
22974             return optionDefinition.type;
22975         }
22976     }
22977     function getNameOfCompilerOptionValue(value, customTypeMap) {
22978         return ts.forEachEntry(customTypeMap, function (mapValue, key) {
22979             if (mapValue === value) {
22980                 return key;
22981             }
22982         });
22983     }
22984     function serializeCompilerOptions(options, pathOptions) {
22985         return serializeOptionBaseObject(options, getOptionsNameMap(), pathOptions);
22986     }
22987     function serializeWatchOptions(options) {
22988         return serializeOptionBaseObject(options, getWatchOptionsNameMap());
22989     }
22990     function serializeOptionBaseObject(options, _a, pathOptions) {
22991         var optionsNameMap = _a.optionsNameMap;
22992         var result = ts.createMap();
22993         var getCanonicalFileName = pathOptions && ts.createGetCanonicalFileName(pathOptions.useCaseSensitiveFileNames);
22994         var _loop_4 = function (name) {
22995             if (ts.hasProperty(options, name)) {
22996                 if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) {
22997                     return "continue";
22998                 }
22999                 var value = options[name];
23000                 var optionDefinition = optionsNameMap.get(name.toLowerCase());
23001                 if (optionDefinition) {
23002                     var customTypeMap_1 = getCustomTypeMapOfCommandLineOption(optionDefinition);
23003                     if (!customTypeMap_1) {
23004                         if (pathOptions && optionDefinition.isFilePath) {
23005                             result.set(name, ts.getRelativePathFromFile(pathOptions.configFilePath, ts.getNormalizedAbsolutePath(value, ts.getDirectoryPath(pathOptions.configFilePath)), getCanonicalFileName));
23006                         }
23007                         else {
23008                             result.set(name, value);
23009                         }
23010                     }
23011                     else {
23012                         if (optionDefinition.type === "list") {
23013                             result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); }));
23014                         }
23015                         else {
23016                             result.set(name, getNameOfCompilerOptionValue(value, customTypeMap_1));
23017                         }
23018                     }
23019                 }
23020             }
23021         };
23022         for (var name in options) {
23023             _loop_4(name);
23024         }
23025         return result;
23026     }
23027     function generateTSConfig(options, fileNames, newLine) {
23028         var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions);
23029         var compilerOptionsMap = serializeCompilerOptions(compilerOptions);
23030         return writeConfigurations();
23031         function getDefaultValueForOption(option) {
23032             switch (option.type) {
23033                 case "number":
23034                     return 1;
23035                 case "boolean":
23036                     return true;
23037                 case "string":
23038                     return option.isFilePath ? "./" : "";
23039                 case "list":
23040                     return [];
23041                 case "object":
23042                     return {};
23043                 default:
23044                     var iterResult = option.type.keys().next();
23045                     if (!iterResult.done)
23046                         return iterResult.value;
23047                     return ts.Debug.fail("Expected 'option.type' to have entries.");
23048             }
23049         }
23050         function makePadding(paddingLength) {
23051             return Array(paddingLength + 1).join(" ");
23052         }
23053         function isAllowedOption(_a) {
23054             var category = _a.category, name = _a.name;
23055             return category !== undefined
23056                 && category !== ts.Diagnostics.Command_line_Options
23057                 && (category !== ts.Diagnostics.Advanced_Options || compilerOptionsMap.has(name));
23058         }
23059         function writeConfigurations() {
23060             var categorizedOptions = ts.createMultiMap();
23061             for (var _i = 0, optionDeclarations_1 = ts.optionDeclarations; _i < optionDeclarations_1.length; _i++) {
23062                 var option = optionDeclarations_1[_i];
23063                 var category = option.category;
23064                 if (isAllowedOption(option)) {
23065                     categorizedOptions.add(ts.getLocaleSpecificMessage(category), option);
23066                 }
23067             }
23068             var marginLength = 0;
23069             var seenKnownKeys = 0;
23070             var entries = [];
23071             categorizedOptions.forEach(function (options, category) {
23072                 if (entries.length !== 0) {
23073                     entries.push({ value: "" });
23074                 }
23075                 entries.push({ value: "/* " + category + " */" });
23076                 for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
23077                     var option = options_1[_i];
23078                     var optionName = void 0;
23079                     if (compilerOptionsMap.has(option.name)) {
23080                         optionName = "\"" + option.name + "\": " + JSON.stringify(compilerOptionsMap.get(option.name)) + ((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ",");
23081                     }
23082                     else {
23083                         optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ",";
23084                     }
23085                     entries.push({
23086                         value: optionName,
23087                         description: "/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */"
23088                     });
23089                     marginLength = Math.max(optionName.length, marginLength);
23090                 }
23091             });
23092             var tab = makePadding(2);
23093             var result = [];
23094             result.push("{");
23095             result.push(tab + "\"compilerOptions\": {");
23096             result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file) + " */");
23097             result.push("");
23098             for (var _a = 0, entries_3 = entries; _a < entries_3.length; _a++) {
23099                 var entry = entries_3[_a];
23100                 var value = entry.value, _b = entry.description, description = _b === void 0 ? "" : _b;
23101                 result.push(value && "" + tab + tab + value + (description && (makePadding(marginLength - value.length + 2) + description)));
23102             }
23103             if (fileNames.length) {
23104                 result.push(tab + "},");
23105                 result.push(tab + "\"files\": [");
23106                 for (var i = 0; i < fileNames.length; i++) {
23107                     result.push("" + tab + tab + JSON.stringify(fileNames[i]) + (i === fileNames.length - 1 ? "" : ","));
23108                 }
23109                 result.push(tab + "]");
23110             }
23111             else {
23112                 result.push(tab + "}");
23113             }
23114             result.push("}");
23115             return result.join(newLine) + newLine;
23116         }
23117     }
23118     ts.generateTSConfig = generateTSConfig;
23119     function convertToOptionsWithAbsolutePaths(options, toAbsolutePath) {
23120         var result = {};
23121         var optionsNameMap = getOptionsNameMap().optionsNameMap;
23122         for (var name in options) {
23123             if (ts.hasProperty(options, name)) {
23124                 result[name] = convertToOptionValueWithAbsolutePaths(optionsNameMap.get(name.toLowerCase()), options[name], toAbsolutePath);
23125             }
23126         }
23127         if (result.configFilePath) {
23128             result.configFilePath = toAbsolutePath(result.configFilePath);
23129         }
23130         return result;
23131     }
23132     ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths;
23133     function convertToOptionValueWithAbsolutePaths(option, value, toAbsolutePath) {
23134         if (option && !isNullOrUndefined(value)) {
23135             if (option.type === "list") {
23136                 var values = value;
23137                 if (option.element.isFilePath && values.length) {
23138                     return values.map(toAbsolutePath);
23139                 }
23140             }
23141             else if (option.isFilePath) {
23142                 return toAbsolutePath(value);
23143             }
23144         }
23145         return value;
23146     }
23147     function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) {
23148         return parseJsonConfigFileContentWorker(json, undefined, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
23149     }
23150     ts.parseJsonConfigFileContent = parseJsonConfigFileContent;
23151     function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) {
23152         return parseJsonConfigFileContentWorker(undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
23153     }
23154     ts.parseJsonSourceFileConfigFileContent = parseJsonSourceFileConfigFileContent;
23155     function setConfigFileInOptions(options, configFile) {
23156         if (configFile) {
23157             Object.defineProperty(options, "configFile", { enumerable: false, writable: false, value: configFile });
23158         }
23159     }
23160     ts.setConfigFileInOptions = setConfigFileInOptions;
23161     function isNullOrUndefined(x) {
23162         return x === undefined || x === null;
23163     }
23164     function directoryOfCombinedPath(fileName, basePath) {
23165         return ts.getDirectoryPath(ts.getNormalizedAbsolutePath(fileName, basePath));
23166     }
23167     function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache) {
23168         if (existingOptions === void 0) { existingOptions = {}; }
23169         if (resolutionStack === void 0) { resolutionStack = []; }
23170         if (extraFileExtensions === void 0) { extraFileExtensions = []; }
23171         ts.Debug.assert((json === undefined && sourceFile !== undefined) || (json !== undefined && sourceFile === undefined));
23172         var errors = [];
23173         var parsedConfig = parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors, extendedConfigCache);
23174         var raw = parsedConfig.raw;
23175         var options = ts.extend(existingOptions, parsedConfig.options || {});
23176         var watchOptions = existingWatchOptions && parsedConfig.watchOptions ?
23177             ts.extend(existingWatchOptions, parsedConfig.watchOptions) :
23178             parsedConfig.watchOptions || existingWatchOptions;
23179         options.configFilePath = configFileName && ts.normalizeSlashes(configFileName);
23180         setConfigFileInOptions(options, sourceFile);
23181         var projectReferences;
23182         var _a = getFileNames(), fileNames = _a.fileNames, wildcardDirectories = _a.wildcardDirectories, spec = _a.spec;
23183         return {
23184             options: options,
23185             watchOptions: watchOptions,
23186             fileNames: fileNames,
23187             projectReferences: projectReferences,
23188             typeAcquisition: parsedConfig.typeAcquisition || getDefaultTypeAcquisition(),
23189             raw: raw,
23190             errors: errors,
23191             wildcardDirectories: wildcardDirectories,
23192             compileOnSave: !!raw.compileOnSave,
23193             configFileSpecs: spec
23194         };
23195         function getFileNames() {
23196             var filesSpecs;
23197             if (ts.hasProperty(raw, "files") && !isNullOrUndefined(raw.files)) {
23198                 if (ts.isArray(raw.files)) {
23199                     filesSpecs = raw.files;
23200                     var hasReferences = ts.hasProperty(raw, "references") && !isNullOrUndefined(raw.references);
23201                     var hasZeroOrNoReferences = !hasReferences || raw.references.length === 0;
23202                     var hasExtends = ts.hasProperty(raw, "extends");
23203                     if (filesSpecs.length === 0 && hasZeroOrNoReferences && !hasExtends) {
23204                         if (sourceFile) {
23205                             var fileName = configFileName || "tsconfig.json";
23206                             var diagnosticMessage = ts.Diagnostics.The_files_list_in_config_file_0_is_empty;
23207                             var nodeValue = ts.firstDefined(ts.getTsConfigPropArray(sourceFile, "files"), function (property) { return property.initializer; });
23208                             var error = nodeValue
23209                                 ? ts.createDiagnosticForNodeInSourceFile(sourceFile, nodeValue, diagnosticMessage, fileName)
23210                                 : ts.createCompilerDiagnostic(diagnosticMessage, fileName);
23211                             errors.push(error);
23212                         }
23213                         else {
23214                             createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json");
23215                         }
23216                     }
23217                 }
23218                 else {
23219                     createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array");
23220                 }
23221             }
23222             var includeSpecs;
23223             if (ts.hasProperty(raw, "include") && !isNullOrUndefined(raw.include)) {
23224                 if (ts.isArray(raw.include)) {
23225                     includeSpecs = raw.include;
23226                 }
23227                 else {
23228                     createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array");
23229                 }
23230             }
23231             var excludeSpecs;
23232             if (ts.hasProperty(raw, "exclude") && !isNullOrUndefined(raw.exclude)) {
23233                 if (ts.isArray(raw.exclude)) {
23234                     excludeSpecs = raw.exclude;
23235                 }
23236                 else {
23237                     createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array");
23238                 }
23239             }
23240             else if (raw.compilerOptions) {
23241                 var outDir = raw.compilerOptions.outDir;
23242                 var declarationDir = raw.compilerOptions.declarationDir;
23243                 if (outDir || declarationDir) {
23244                     excludeSpecs = [outDir, declarationDir].filter(function (d) { return !!d; });
23245                 }
23246             }
23247             if (filesSpecs === undefined && includeSpecs === undefined) {
23248                 includeSpecs = ["**/*"];
23249             }
23250             var result = matchFileNames(filesSpecs, includeSpecs, excludeSpecs, configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath, options, host, errors, extraFileExtensions, sourceFile);
23251             if (shouldReportNoInputFiles(result, canJsonReportNoInutFiles(raw), resolutionStack)) {
23252                 errors.push(getErrorForNoInputFiles(result.spec, configFileName));
23253             }
23254             if (ts.hasProperty(raw, "references") && !isNullOrUndefined(raw.references)) {
23255                 if (ts.isArray(raw.references)) {
23256                     for (var _i = 0, _a = raw.references; _i < _a.length; _i++) {
23257                         var ref = _a[_i];
23258                         if (typeof ref.path !== "string") {
23259                             createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "reference.path", "string");
23260                         }
23261                         else {
23262                             (projectReferences || (projectReferences = [])).push({
23263                                 path: ts.getNormalizedAbsolutePath(ref.path, basePath),
23264                                 originalPath: ref.path,
23265                                 prepend: ref.prepend,
23266                                 circular: ref.circular
23267                             });
23268                         }
23269                     }
23270                 }
23271                 else {
23272                     createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "references", "Array");
23273                 }
23274             }
23275             return result;
23276         }
23277         function createCompilerDiagnosticOnlyIfJson(message, arg0, arg1) {
23278             if (!sourceFile) {
23279                 errors.push(ts.createCompilerDiagnostic(message, arg0, arg1));
23280             }
23281         }
23282     }
23283     function isErrorNoInputFiles(error) {
23284         return error.code === ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code;
23285     }
23286     function getErrorForNoInputFiles(_a, configFileName) {
23287         var includeSpecs = _a.includeSpecs, excludeSpecs = _a.excludeSpecs;
23288         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 || []));
23289     }
23290     function shouldReportNoInputFiles(result, canJsonReportNoInutFiles, resolutionStack) {
23291         return result.fileNames.length === 0 && canJsonReportNoInutFiles && (!resolutionStack || resolutionStack.length === 0);
23292     }
23293     function canJsonReportNoInutFiles(raw) {
23294         return !ts.hasProperty(raw, "files") && !ts.hasProperty(raw, "references");
23295     }
23296     ts.canJsonReportNoInutFiles = canJsonReportNoInutFiles;
23297     function updateErrorForNoInputFiles(result, configFileName, configFileSpecs, configParseDiagnostics, canJsonReportNoInutFiles) {
23298         var existingErrors = configParseDiagnostics.length;
23299         if (shouldReportNoInputFiles(result, canJsonReportNoInutFiles)) {
23300             configParseDiagnostics.push(getErrorForNoInputFiles(configFileSpecs, configFileName));
23301         }
23302         else {
23303             ts.filterMutate(configParseDiagnostics, function (error) { return !isErrorNoInputFiles(error); });
23304         }
23305         return existingErrors !== configParseDiagnostics.length;
23306     }
23307     ts.updateErrorForNoInputFiles = updateErrorForNoInputFiles;
23308     function isSuccessfulParsedTsconfig(value) {
23309         return !!value.options;
23310     }
23311     function parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors, extendedConfigCache) {
23312         basePath = ts.normalizeSlashes(basePath);
23313         var resolvedPath = ts.getNormalizedAbsolutePath(configFileName || "", basePath);
23314         if (resolutionStack.indexOf(resolvedPath) >= 0) {
23315             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, __spreadArrays(resolutionStack, [resolvedPath]).join(" -> ")));
23316             return { raw: json || convertToObject(sourceFile, errors) };
23317         }
23318         var ownConfig = json ?
23319             parseOwnConfigOfJson(json, host, basePath, configFileName, errors) :
23320             parseOwnConfigOfJsonSourceFile(sourceFile, host, basePath, configFileName, errors);
23321         if (ownConfig.extendedConfigPath) {
23322             resolutionStack = resolutionStack.concat([resolvedPath]);
23323             var extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache);
23324             if (extendedConfig && isSuccessfulParsedTsconfig(extendedConfig)) {
23325                 var baseRaw_1 = extendedConfig.raw;
23326                 var raw_1 = ownConfig.raw;
23327                 var setPropertyInRawIfNotUndefined = function (propertyName) {
23328                     var value = raw_1[propertyName] || baseRaw_1[propertyName];
23329                     if (value) {
23330                         raw_1[propertyName] = value;
23331                     }
23332                 };
23333                 setPropertyInRawIfNotUndefined("include");
23334                 setPropertyInRawIfNotUndefined("exclude");
23335                 setPropertyInRawIfNotUndefined("files");
23336                 if (raw_1.compileOnSave === undefined) {
23337                     raw_1.compileOnSave = baseRaw_1.compileOnSave;
23338                 }
23339                 ownConfig.options = ts.assign({}, extendedConfig.options, ownConfig.options);
23340                 ownConfig.watchOptions = ownConfig.watchOptions && extendedConfig.watchOptions ?
23341                     ts.assign({}, extendedConfig.watchOptions, ownConfig.watchOptions) :
23342                     ownConfig.watchOptions || extendedConfig.watchOptions;
23343             }
23344         }
23345         return ownConfig;
23346     }
23347     function parseOwnConfigOfJson(json, host, basePath, configFileName, errors) {
23348         if (ts.hasProperty(json, "excludes")) {
23349             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
23350         }
23351         var options = convertCompilerOptionsFromJsonWorker(json.compilerOptions, basePath, errors, configFileName);
23352         var typeAcquisition = convertTypeAcquisitionFromJsonWorker(json.typeAcquisition || json.typingOptions, basePath, errors, configFileName);
23353         var watchOptions = convertWatchOptionsFromJsonWorker(json.watchOptions, basePath, errors);
23354         json.compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors);
23355         var extendedConfigPath;
23356         if (json.extends) {
23357             if (!ts.isString(json.extends)) {
23358                 errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string"));
23359             }
23360             else {
23361                 var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath;
23362                 extendedConfigPath = getExtendsConfigPath(json.extends, host, newBase, errors, ts.createCompilerDiagnostic);
23363             }
23364         }
23365         return { raw: json, options: options, watchOptions: watchOptions, typeAcquisition: typeAcquisition, extendedConfigPath: extendedConfigPath };
23366     }
23367     function parseOwnConfigOfJsonSourceFile(sourceFile, host, basePath, configFileName, errors) {
23368         var options = getDefaultCompilerOptions(configFileName);
23369         var typeAcquisition, typingOptionstypeAcquisition;
23370         var watchOptions;
23371         var extendedConfigPath;
23372         var optionsIterator = {
23373             onSetValidOptionKeyValueInParent: function (parentOption, option, value) {
23374                 var currentOption;
23375                 switch (parentOption) {
23376                     case "compilerOptions":
23377                         currentOption = options;
23378                         break;
23379                     case "watchOptions":
23380                         currentOption = (watchOptions || (watchOptions = {}));
23381                         break;
23382                     case "typeAcquisition":
23383                         currentOption = (typeAcquisition || (typeAcquisition = getDefaultTypeAcquisition(configFileName)));
23384                         break;
23385                     case "typingOptions":
23386                         currentOption = (typingOptionstypeAcquisition || (typingOptionstypeAcquisition = getDefaultTypeAcquisition(configFileName)));
23387                         break;
23388                     default:
23389                         ts.Debug.fail("Unknown option");
23390                 }
23391                 currentOption[option.name] = normalizeOptionValue(option, basePath, value);
23392             },
23393             onSetValidOptionKeyValueInRoot: function (key, _keyNode, value, valueNode) {
23394                 switch (key) {
23395                     case "extends":
23396                         var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath;
23397                         extendedConfigPath = getExtendsConfigPath(value, host, newBase, errors, function (message, arg0) {
23398                             return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueNode, message, arg0);
23399                         });
23400                         return;
23401                 }
23402             },
23403             onSetUnknownOptionKeyValueInRoot: function (key, keyNode, _value, _valueNode) {
23404                 if (key === "excludes") {
23405                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, keyNode, ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
23406                 }
23407             }
23408         };
23409         var json = convertToObjectWorker(sourceFile, errors, true, getTsconfigRootOptionsMap(), optionsIterator);
23410         if (!typeAcquisition) {
23411             if (typingOptionstypeAcquisition) {
23412                 typeAcquisition = (typingOptionstypeAcquisition.enableAutoDiscovery !== undefined) ?
23413                     {
23414                         enable: typingOptionstypeAcquisition.enableAutoDiscovery,
23415                         include: typingOptionstypeAcquisition.include,
23416                         exclude: typingOptionstypeAcquisition.exclude
23417                     } :
23418                     typingOptionstypeAcquisition;
23419             }
23420             else {
23421                 typeAcquisition = getDefaultTypeAcquisition(configFileName);
23422             }
23423         }
23424         return { raw: json, options: options, watchOptions: watchOptions, typeAcquisition: typeAcquisition, extendedConfigPath: extendedConfigPath };
23425     }
23426     function getExtendsConfigPath(extendedConfig, host, basePath, errors, createDiagnostic) {
23427         extendedConfig = ts.normalizeSlashes(extendedConfig);
23428         if (ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../")) {
23429             var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath);
23430             if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) {
23431                 extendedConfigPath = extendedConfigPath + ".json";
23432                 if (!host.fileExists(extendedConfigPath)) {
23433                     errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
23434                     return undefined;
23435                 }
23436             }
23437             return extendedConfigPath;
23438         }
23439         var resolved = ts.nodeModuleNameResolver(extendedConfig, ts.combinePaths(basePath, "tsconfig.json"), { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, undefined, undefined, true);
23440         if (resolved.resolvedModule) {
23441             return resolved.resolvedModule.resolvedFileName;
23442         }
23443         errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
23444         return undefined;
23445     }
23446     function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache) {
23447         var _a;
23448         var path = host.useCaseSensitiveFileNames ? extendedConfigPath : ts.toFileNameLowerCase(extendedConfigPath);
23449         var value;
23450         var extendedResult;
23451         var extendedConfig;
23452         if (extendedConfigCache && (value = extendedConfigCache.get(path))) {
23453             (extendedResult = value.extendedResult, extendedConfig = value.extendedConfig);
23454         }
23455         else {
23456             extendedResult = readJsonConfigFile(extendedConfigPath, function (path) { return host.readFile(path); });
23457             if (!extendedResult.parseDiagnostics.length) {
23458                 var extendedDirname = ts.getDirectoryPath(extendedConfigPath);
23459                 extendedConfig = parseConfig(undefined, extendedResult, host, extendedDirname, ts.getBaseFileName(extendedConfigPath), resolutionStack, errors, extendedConfigCache);
23460                 if (isSuccessfulParsedTsconfig(extendedConfig)) {
23461                     var relativeDifference_1 = ts.convertToRelativePath(extendedDirname, basePath, ts.identity);
23462                     var updatePath_1 = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference_1, path); };
23463                     var mapPropertiesInRawIfNotUndefined = function (propertyName) {
23464                         if (raw_2[propertyName]) {
23465                             raw_2[propertyName] = ts.map(raw_2[propertyName], updatePath_1);
23466                         }
23467                     };
23468                     var raw_2 = extendedConfig.raw;
23469                     mapPropertiesInRawIfNotUndefined("include");
23470                     mapPropertiesInRawIfNotUndefined("exclude");
23471                     mapPropertiesInRawIfNotUndefined("files");
23472                 }
23473             }
23474             if (extendedConfigCache) {
23475                 extendedConfigCache.set(path, { extendedResult: extendedResult, extendedConfig: extendedConfig });
23476             }
23477         }
23478         if (sourceFile) {
23479             sourceFile.extendedSourceFiles = [extendedResult.fileName];
23480             if (extendedResult.extendedSourceFiles) {
23481                 (_a = sourceFile.extendedSourceFiles).push.apply(_a, extendedResult.extendedSourceFiles);
23482             }
23483         }
23484         if (extendedResult.parseDiagnostics.length) {
23485             errors.push.apply(errors, extendedResult.parseDiagnostics);
23486             return undefined;
23487         }
23488         return extendedConfig;
23489     }
23490     function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) {
23491         if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) {
23492             return false;
23493         }
23494         var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption.compileOnSave, basePath, errors);
23495         return typeof result === "boolean" && result;
23496     }
23497     function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) {
23498         var errors = [];
23499         var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName);
23500         return { options: options, errors: errors };
23501     }
23502     ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson;
23503     function convertTypeAcquisitionFromJson(jsonOptions, basePath, configFileName) {
23504         var errors = [];
23505         var options = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName);
23506         return { options: options, errors: errors };
23507     }
23508     ts.convertTypeAcquisitionFromJson = convertTypeAcquisitionFromJson;
23509     function getDefaultCompilerOptions(configFileName) {
23510         var options = configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json"
23511             ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true, noEmit: true }
23512             : {};
23513         return options;
23514     }
23515     function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) {
23516         var options = getDefaultCompilerOptions(configFileName);
23517         convertOptionsFromJson(getCommandLineCompilerOptionsMap(), jsonOptions, basePath, options, ts.compilerOptionsDidYouMeanDiagnostics, errors);
23518         if (configFileName) {
23519             options.configFilePath = ts.normalizeSlashes(configFileName);
23520         }
23521         return options;
23522     }
23523     function getDefaultTypeAcquisition(configFileName) {
23524         return { enable: !!configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] };
23525     }
23526     function convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName) {
23527         var options = getDefaultTypeAcquisition(configFileName);
23528         var typeAcquisition = convertEnableAutoDiscoveryToEnable(jsonOptions);
23529         convertOptionsFromJson(getCommandLineTypeAcquisitionMap(), typeAcquisition, basePath, options, typeAcquisitionDidYouMeanDiagnostics, errors);
23530         return options;
23531     }
23532     function convertWatchOptionsFromJsonWorker(jsonOptions, basePath, errors) {
23533         return convertOptionsFromJson(getCommandLineWatchOptionsMap(), jsonOptions, basePath, undefined, watchOptionsDidYouMeanDiagnostics, errors);
23534     }
23535     function convertOptionsFromJson(optionsNameMap, jsonOptions, basePath, defaultOptions, diagnostics, errors) {
23536         if (!jsonOptions) {
23537             return;
23538         }
23539         for (var id in jsonOptions) {
23540             var opt = optionsNameMap.get(id);
23541             if (opt) {
23542                 (defaultOptions || (defaultOptions = {}))[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors);
23543             }
23544             else {
23545                 errors.push(createUnknownOptionError(id, diagnostics, ts.createCompilerDiagnostic));
23546             }
23547         }
23548         return defaultOptions;
23549     }
23550     function convertJsonOption(opt, value, basePath, errors) {
23551         if (isCompilerOptionsValue(opt, value)) {
23552             var optType = opt.type;
23553             if (optType === "list" && ts.isArray(value)) {
23554                 return convertJsonOptionOfListType(opt, value, basePath, errors);
23555             }
23556             else if (!ts.isString(optType)) {
23557                 return convertJsonOptionOfCustomType(opt, value, errors);
23558             }
23559             return normalizeNonListOptionValue(opt, basePath, value);
23560         }
23561         else {
23562             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, getCompilerOptionValueTypeString(opt)));
23563         }
23564     }
23565     function normalizeOptionValue(option, basePath, value) {
23566         if (isNullOrUndefined(value))
23567             return undefined;
23568         if (option.type === "list") {
23569             var listOption_1 = option;
23570             if (listOption_1.element.isFilePath || !ts.isString(listOption_1.element.type)) {
23571                 return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return !!v; });
23572             }
23573             return value;
23574         }
23575         else if (!ts.isString(option.type)) {
23576             return option.type.get(ts.isString(value) ? value.toLowerCase() : value);
23577         }
23578         return normalizeNonListOptionValue(option, basePath, value);
23579     }
23580     function normalizeNonListOptionValue(option, basePath, value) {
23581         if (option.isFilePath) {
23582             value = ts.getNormalizedAbsolutePath(value, basePath);
23583             if (value === "") {
23584                 value = ".";
23585             }
23586         }
23587         return value;
23588     }
23589     function convertJsonOptionOfCustomType(opt, value, errors) {
23590         if (isNullOrUndefined(value))
23591             return undefined;
23592         var key = value.toLowerCase();
23593         var val = opt.type.get(key);
23594         if (val !== undefined) {
23595             return val;
23596         }
23597         else {
23598             errors.push(createCompilerDiagnosticForInvalidCustomType(opt));
23599         }
23600     }
23601     function convertJsonOptionOfListType(option, values, basePath, errors) {
23602         return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; });
23603     }
23604     function trimString(s) {
23605         return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, "");
23606     }
23607     var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/;
23608     var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/;
23609     var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//;
23610     var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/;
23611     function matchFileNames(filesSpecs, includeSpecs, excludeSpecs, basePath, options, host, errors, extraFileExtensions, jsonSourceFile) {
23612         basePath = ts.normalizePath(basePath);
23613         var validatedIncludeSpecs, validatedExcludeSpecs;
23614         if (includeSpecs) {
23615             validatedIncludeSpecs = validateSpecs(includeSpecs, errors, false, jsonSourceFile, "include");
23616         }
23617         if (excludeSpecs) {
23618             validatedExcludeSpecs = validateSpecs(excludeSpecs, errors, true, jsonSourceFile, "exclude");
23619         }
23620         var wildcardDirectories = getWildcardDirectories(validatedIncludeSpecs, validatedExcludeSpecs, basePath, host.useCaseSensitiveFileNames);
23621         var spec = { filesSpecs: filesSpecs, includeSpecs: includeSpecs, excludeSpecs: excludeSpecs, validatedIncludeSpecs: validatedIncludeSpecs, validatedExcludeSpecs: validatedExcludeSpecs, wildcardDirectories: wildcardDirectories };
23622         return getFileNamesFromConfigSpecs(spec, basePath, options, host, extraFileExtensions);
23623     }
23624     function getFileNamesFromConfigSpecs(spec, basePath, options, host, extraFileExtensions) {
23625         if (extraFileExtensions === void 0) { extraFileExtensions = []; }
23626         basePath = ts.normalizePath(basePath);
23627         var keyMapper = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames);
23628         var literalFileMap = ts.createMap();
23629         var wildcardFileMap = ts.createMap();
23630         var wildCardJsonFileMap = ts.createMap();
23631         var filesSpecs = spec.filesSpecs, validatedIncludeSpecs = spec.validatedIncludeSpecs, validatedExcludeSpecs = spec.validatedExcludeSpecs, wildcardDirectories = spec.wildcardDirectories;
23632         var supportedExtensions = ts.getSupportedExtensions(options, extraFileExtensions);
23633         var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
23634         if (filesSpecs) {
23635             for (var _i = 0, filesSpecs_1 = filesSpecs; _i < filesSpecs_1.length; _i++) {
23636                 var fileName = filesSpecs_1[_i];
23637                 var file = ts.getNormalizedAbsolutePath(fileName, basePath);
23638                 literalFileMap.set(keyMapper(file), file);
23639             }
23640         }
23641         var jsonOnlyIncludeRegexes;
23642         if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) {
23643             var _loop_5 = function (file) {
23644                 if (ts.fileExtensionIs(file, ".json")) {
23645                     if (!jsonOnlyIncludeRegexes) {
23646                         var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json"); });
23647                         var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^" + pattern + "$"; });
23648                         jsonOnlyIncludeRegexes = includeFilePatterns ? includeFilePatterns.map(function (pattern) { return ts.getRegexFromPattern(pattern, host.useCaseSensitiveFileNames); }) : ts.emptyArray;
23649                     }
23650                     var includeIndex = ts.findIndex(jsonOnlyIncludeRegexes, function (re) { return re.test(file); });
23651                     if (includeIndex !== -1) {
23652                         var key_1 = keyMapper(file);
23653                         if (!literalFileMap.has(key_1) && !wildCardJsonFileMap.has(key_1)) {
23654                             wildCardJsonFileMap.set(key_1, file);
23655                         }
23656                     }
23657                     return "continue";
23658                 }
23659                 if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) {
23660                     return "continue";
23661                 }
23662                 removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper);
23663                 var key = keyMapper(file);
23664                 if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) {
23665                     wildcardFileMap.set(key, file);
23666                 }
23667             };
23668             for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensionsWithJsonIfResolveJsonModule, validatedExcludeSpecs, validatedIncludeSpecs, undefined); _a < _b.length; _a++) {
23669                 var file = _b[_a];
23670                 _loop_5(file);
23671             }
23672         }
23673         var literalFiles = ts.arrayFrom(literalFileMap.values());
23674         var wildcardFiles = ts.arrayFrom(wildcardFileMap.values());
23675         return {
23676             fileNames: literalFiles.concat(wildcardFiles, ts.arrayFrom(wildCardJsonFileMap.values())),
23677             wildcardDirectories: wildcardDirectories,
23678             spec: spec
23679         };
23680     }
23681     ts.getFileNamesFromConfigSpecs = getFileNamesFromConfigSpecs;
23682     function validateSpecs(specs, errors, allowTrailingRecursion, jsonSourceFile, specKey) {
23683         return specs.filter(function (spec) {
23684             var diag = specToDiagnostic(spec, allowTrailingRecursion);
23685             if (diag !== undefined) {
23686                 errors.push(createDiagnostic(diag, spec));
23687             }
23688             return diag === undefined;
23689         });
23690         function createDiagnostic(message, spec) {
23691             var element = ts.getTsConfigPropArrayElementValue(jsonSourceFile, specKey, spec);
23692             return element ?
23693                 ts.createDiagnosticForNodeInSourceFile(jsonSourceFile, element, message, spec) :
23694                 ts.createCompilerDiagnostic(message, spec);
23695         }
23696     }
23697     function specToDiagnostic(spec, allowTrailingRecursion) {
23698         if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) {
23699             return ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0;
23700         }
23701         else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) {
23702             return ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0;
23703         }
23704     }
23705     function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) {
23706         var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude");
23707         var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i");
23708         var wildcardDirectories = {};
23709         if (include !== undefined) {
23710             var recursiveKeys = [];
23711             for (var _i = 0, include_1 = include; _i < include_1.length; _i++) {
23712                 var file = include_1[_i];
23713                 var spec = ts.normalizePath(ts.combinePaths(path, file));
23714                 if (excludeRegex && excludeRegex.test(spec)) {
23715                     continue;
23716                 }
23717                 var match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames);
23718                 if (match) {
23719                     var key = match.key, flags = match.flags;
23720                     var existingFlags = wildcardDirectories[key];
23721                     if (existingFlags === undefined || existingFlags < flags) {
23722                         wildcardDirectories[key] = flags;
23723                         if (flags === 1) {
23724                             recursiveKeys.push(key);
23725                         }
23726                     }
23727                 }
23728             }
23729             for (var key in wildcardDirectories) {
23730                 if (ts.hasProperty(wildcardDirectories, key)) {
23731                     for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) {
23732                         var recursiveKey = recursiveKeys_1[_a];
23733                         if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) {
23734                             delete wildcardDirectories[key];
23735                         }
23736                     }
23737                 }
23738             }
23739         }
23740         return wildcardDirectories;
23741     }
23742     function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) {
23743         var match = wildcardDirectoryPattern.exec(spec);
23744         if (match) {
23745             return {
23746                 key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]),
23747                 flags: watchRecursivePattern.test(spec) ? 1 : 0
23748             };
23749         }
23750         if (ts.isImplicitGlob(spec)) {
23751             return { key: spec, flags: 1 };
23752         }
23753         return undefined;
23754     }
23755     function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) {
23756         var extensionPriority = ts.getExtensionPriority(file, extensions);
23757         var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority, extensions);
23758         for (var i = 0; i < adjustedExtensionPriority; i++) {
23759             var higherPriorityExtension = extensions[i];
23760             var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension));
23761             if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) {
23762                 return true;
23763             }
23764         }
23765         return false;
23766     }
23767     function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) {
23768         var extensionPriority = ts.getExtensionPriority(file, extensions);
23769         var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority, extensions);
23770         for (var i = nextExtensionPriority; i < extensions.length; i++) {
23771             var lowerPriorityExtension = extensions[i];
23772             var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension));
23773             wildcardFiles.delete(lowerPriorityPath);
23774         }
23775     }
23776     function convertCompilerOptionsForTelemetry(opts) {
23777         var out = {};
23778         for (var key in opts) {
23779             if (opts.hasOwnProperty(key)) {
23780                 var type = getOptionFromName(key);
23781                 if (type !== undefined) {
23782                     out[key] = getOptionValueWithEmptyStrings(opts[key], type);
23783                 }
23784             }
23785         }
23786         return out;
23787     }
23788     ts.convertCompilerOptionsForTelemetry = convertCompilerOptionsForTelemetry;
23789     function getOptionValueWithEmptyStrings(value, option) {
23790         switch (option.type) {
23791             case "object":
23792                 return "";
23793             case "string":
23794                 return "";
23795             case "number":
23796                 return typeof value === "number" ? value : "";
23797             case "boolean":
23798                 return typeof value === "boolean" ? value : "";
23799             case "list":
23800                 var elementType_1 = option.element;
23801                 return ts.isArray(value) ? value.map(function (v) { return getOptionValueWithEmptyStrings(v, elementType_1); }) : "";
23802             default:
23803                 return ts.forEachEntry(option.type, function (optionEnumValue, optionStringValue) {
23804                     if (optionEnumValue === value) {
23805                         return optionStringValue;
23806                     }
23807                 });
23808         }
23809     }
23810 })(ts || (ts = {}));
23811 var ts;
23812 (function (ts) {
23813     function trace(host) {
23814         host.trace(ts.formatMessage.apply(undefined, arguments));
23815     }
23816     ts.trace = trace;
23817     function isTraceEnabled(compilerOptions, host) {
23818         return !!compilerOptions.traceResolution && host.trace !== undefined;
23819     }
23820     ts.isTraceEnabled = isTraceEnabled;
23821     function withPackageId(packageInfo, r) {
23822         var packageId;
23823         if (r && packageInfo) {
23824             var packageJsonContent = packageInfo.packageJsonContent;
23825             if (typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string") {
23826                 packageId = {
23827                     name: packageJsonContent.name,
23828                     subModuleName: r.path.slice(packageInfo.packageDirectory.length + ts.directorySeparator.length),
23829                     version: packageJsonContent.version
23830                 };
23831             }
23832         }
23833         return r && { path: r.path, extension: r.ext, packageId: packageId };
23834     }
23835     function noPackageId(r) {
23836         return withPackageId(undefined, r);
23837     }
23838     function removeIgnoredPackageId(r) {
23839         if (r) {
23840             ts.Debug.assert(r.packageId === undefined);
23841             return { path: r.path, ext: r.extension };
23842         }
23843     }
23844     var Extensions;
23845     (function (Extensions) {
23846         Extensions[Extensions["TypeScript"] = 0] = "TypeScript";
23847         Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
23848         Extensions[Extensions["Json"] = 2] = "Json";
23849         Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
23850         Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
23851     })(Extensions || (Extensions = {}));
23852     function resolvedTypeScriptOnly(resolved) {
23853         if (!resolved) {
23854             return undefined;
23855         }
23856         ts.Debug.assert(ts.extensionIsTS(resolved.extension));
23857         return { fileName: resolved.path, packageId: resolved.packageId };
23858     }
23859     function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, resultFromCache) {
23860         var _a;
23861         if (resultFromCache) {
23862             (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
23863             return resultFromCache;
23864         }
23865         return {
23866             resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
23867             failedLookupLocations: failedLookupLocations
23868         };
23869     }
23870     function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
23871         if (!ts.hasProperty(jsonContent, fieldName)) {
23872             if (state.traceEnabled) {
23873                 trace(state.host, ts.Diagnostics.package_json_does_not_have_a_0_field, fieldName);
23874             }
23875             return;
23876         }
23877         var value = jsonContent[fieldName];
23878         if (typeof value !== typeOfTag || value === null) {
23879             if (state.traceEnabled) {
23880                 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);
23881             }
23882             return;
23883         }
23884         return value;
23885     }
23886     function readPackageJsonPathField(jsonContent, fieldName, baseDirectory, state) {
23887         var fileName = readPackageJsonField(jsonContent, fieldName, "string", state);
23888         if (fileName === undefined) {
23889             return;
23890         }
23891         if (!fileName) {
23892             if (state.traceEnabled) {
23893                 trace(state.host, ts.Diagnostics.package_json_had_a_falsy_0_field, fieldName);
23894             }
23895             return;
23896         }
23897         var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName));
23898         if (state.traceEnabled) {
23899             trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path);
23900         }
23901         return path;
23902     }
23903     function readPackageJsonTypesFields(jsonContent, baseDirectory, state) {
23904         return readPackageJsonPathField(jsonContent, "typings", baseDirectory, state)
23905             || readPackageJsonPathField(jsonContent, "types", baseDirectory, state);
23906     }
23907     function readPackageJsonTSConfigField(jsonContent, baseDirectory, state) {
23908         return readPackageJsonPathField(jsonContent, "tsconfig", baseDirectory, state);
23909     }
23910     function readPackageJsonMainField(jsonContent, baseDirectory, state) {
23911         return readPackageJsonPathField(jsonContent, "main", baseDirectory, state);
23912     }
23913     function readPackageJsonTypesVersionsField(jsonContent, state) {
23914         var typesVersions = readPackageJsonField(jsonContent, "typesVersions", "object", state);
23915         if (typesVersions === undefined)
23916             return;
23917         if (state.traceEnabled) {
23918             trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_field_with_version_specific_path_mappings);
23919         }
23920         return typesVersions;
23921     }
23922     function readPackageJsonTypesVersionPaths(jsonContent, state) {
23923         var typesVersions = readPackageJsonTypesVersionsField(jsonContent, state);
23924         if (typesVersions === undefined)
23925             return;
23926         if (state.traceEnabled) {
23927             for (var key in typesVersions) {
23928                 if (ts.hasProperty(typesVersions, key) && !ts.VersionRange.tryParse(key)) {
23929                     trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_is_not_a_valid_semver_range, key);
23930                 }
23931             }
23932         }
23933         var result = getPackageJsonTypesVersionsPaths(typesVersions);
23934         if (!result) {
23935             if (state.traceEnabled) {
23936                 trace(state.host, ts.Diagnostics.package_json_does_not_have_a_typesVersions_entry_that_matches_version_0, ts.versionMajorMinor);
23937             }
23938             return;
23939         }
23940         var bestVersionKey = result.version, bestVersionPaths = result.paths;
23941         if (typeof bestVersionPaths !== "object") {
23942             if (state.traceEnabled) {
23943                 trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['" + bestVersionKey + "']", "object", typeof bestVersionPaths);
23944             }
23945             return;
23946         }
23947         return result;
23948     }
23949     var typeScriptVersion;
23950     function getPackageJsonTypesVersionsPaths(typesVersions) {
23951         if (!typeScriptVersion)
23952             typeScriptVersion = new ts.Version(ts.version);
23953         for (var key in typesVersions) {
23954             if (!ts.hasProperty(typesVersions, key))
23955                 continue;
23956             var keyRange = ts.VersionRange.tryParse(key);
23957             if (keyRange === undefined) {
23958                 continue;
23959             }
23960             if (keyRange.test(typeScriptVersion)) {
23961                 return { version: key, paths: typesVersions[key] };
23962             }
23963         }
23964     }
23965     ts.getPackageJsonTypesVersionsPaths = getPackageJsonTypesVersionsPaths;
23966     function getEffectiveTypeRoots(options, host) {
23967         if (options.typeRoots) {
23968             return options.typeRoots;
23969         }
23970         var currentDirectory;
23971         if (options.configFilePath) {
23972             currentDirectory = ts.getDirectoryPath(options.configFilePath);
23973         }
23974         else if (host.getCurrentDirectory) {
23975             currentDirectory = host.getCurrentDirectory();
23976         }
23977         if (currentDirectory !== undefined) {
23978             return getDefaultTypeRoots(currentDirectory, host);
23979         }
23980     }
23981     ts.getEffectiveTypeRoots = getEffectiveTypeRoots;
23982     function getDefaultTypeRoots(currentDirectory, host) {
23983         if (!host.directoryExists) {
23984             return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)];
23985         }
23986         var typeRoots;
23987         ts.forEachAncestorDirectory(ts.normalizePath(currentDirectory), function (directory) {
23988             var atTypes = ts.combinePaths(directory, nodeModulesAtTypes);
23989             if (host.directoryExists(atTypes)) {
23990                 (typeRoots || (typeRoots = [])).push(atTypes);
23991             }
23992             return undefined;
23993         });
23994         return typeRoots;
23995     }
23996     var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types");
23997     function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) {
23998         var traceEnabled = isTraceEnabled(options, host);
23999         if (redirectedReference) {
24000             options = redirectedReference.commandLine.options;
24001         }
24002         var failedLookupLocations = [];
24003         var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
24004         var typeRoots = getEffectiveTypeRoots(options, host);
24005         if (traceEnabled) {
24006             if (containingFile === undefined) {
24007                 if (typeRoots === undefined) {
24008                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName);
24009                 }
24010                 else {
24011                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots);
24012                 }
24013             }
24014             else {
24015                 if (typeRoots === undefined) {
24016                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile);
24017                 }
24018                 else {
24019                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots);
24020                 }
24021             }
24022             if (redirectedReference) {
24023                 trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName);
24024             }
24025         }
24026         var resolved = primaryLookup();
24027         var primary = true;
24028         if (!resolved) {
24029             resolved = secondaryLookup();
24030             primary = false;
24031         }
24032         var resolvedTypeReferenceDirective;
24033         if (resolved) {
24034             var fileName = resolved.fileName, packageId = resolved.packageId;
24035             var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled);
24036             if (traceEnabled) {
24037                 if (packageId) {
24038                     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);
24039                 }
24040                 else {
24041                     trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary);
24042                 }
24043             }
24044             resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) };
24045         }
24046         return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
24047         function primaryLookup() {
24048             if (typeRoots && typeRoots.length) {
24049                 if (traceEnabled) {
24050                     trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", "));
24051                 }
24052                 return ts.firstDefined(typeRoots, function (typeRoot) {
24053                     var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName);
24054                     var candidateDirectory = ts.getDirectoryPath(candidate);
24055                     var directoryExists = ts.directoryProbablyExists(candidateDirectory, host);
24056                     if (!directoryExists && traceEnabled) {
24057                         trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory);
24058                     }
24059                     return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, !directoryExists, moduleResolutionState));
24060                 });
24061             }
24062             else {
24063                 if (traceEnabled) {
24064                     trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths);
24065                 }
24066             }
24067         }
24068         function secondaryLookup() {
24069             var initialLocationForSecondaryLookup = containingFile && ts.getDirectoryPath(containingFile);
24070             if (initialLocationForSecondaryLookup !== undefined) {
24071                 if (traceEnabled) {
24072                     trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup);
24073                 }
24074                 var result = void 0;
24075                 if (!ts.isExternalModuleNameRelative(typeReferenceDirectiveName)) {
24076                     var searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, undefined, undefined);
24077                     result = searchResult && searchResult.value;
24078                 }
24079                 else {
24080                     var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path;
24081                     result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, false, moduleResolutionState, true);
24082                 }
24083                 var resolvedFile = resolvedTypeScriptOnly(result);
24084                 if (!resolvedFile && traceEnabled) {
24085                     trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName);
24086                 }
24087                 return resolvedFile;
24088             }
24089             else {
24090                 if (traceEnabled) {
24091                     trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder);
24092                 }
24093             }
24094         }
24095     }
24096     ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective;
24097     function getAutomaticTypeDirectiveNames(options, host) {
24098         if (options.types) {
24099             return options.types;
24100         }
24101         var result = [];
24102         if (host.directoryExists && host.getDirectories) {
24103             var typeRoots = getEffectiveTypeRoots(options, host);
24104             if (typeRoots) {
24105                 for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) {
24106                     var root = typeRoots_1[_i];
24107                     if (host.directoryExists(root)) {
24108                         for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) {
24109                             var typeDirectivePath = _b[_a];
24110                             var normalized = ts.normalizePath(typeDirectivePath);
24111                             var packageJsonPath = ts.combinePaths(root, normalized, "package.json");
24112                             var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null;
24113                             if (!isNotNeededPackage) {
24114                                 var baseFileName = ts.getBaseFileName(normalized);
24115                                 if (baseFileName.charCodeAt(0) !== 46) {
24116                                     result.push(baseFileName);
24117                                 }
24118                             }
24119                         }
24120                     }
24121                 }
24122             }
24123         }
24124         return result;
24125     }
24126     ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames;
24127     function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) {
24128         return createModuleResolutionCacheWithMaps(createCacheWithRedirects(options), createCacheWithRedirects(options), currentDirectory, getCanonicalFileName);
24129     }
24130     ts.createModuleResolutionCache = createModuleResolutionCache;
24131     function createCacheWithRedirects(options) {
24132         var ownMap = ts.createMap();
24133         var redirectsMap = ts.createMap();
24134         return {
24135             ownMap: ownMap,
24136             redirectsMap: redirectsMap,
24137             getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects,
24138             clear: clear,
24139             setOwnOptions: setOwnOptions,
24140             setOwnMap: setOwnMap
24141         };
24142         function setOwnOptions(newOptions) {
24143             options = newOptions;
24144         }
24145         function setOwnMap(newOwnMap) {
24146             ownMap = newOwnMap;
24147         }
24148         function getOrCreateMapOfCacheRedirects(redirectedReference) {
24149             if (!redirectedReference) {
24150                 return ownMap;
24151             }
24152             var path = redirectedReference.sourceFile.path;
24153             var redirects = redirectsMap.get(path);
24154             if (!redirects) {
24155                 redirects = !options || ts.optionsHaveModuleResolutionChanges(options, redirectedReference.commandLine.options) ? ts.createMap() : ownMap;
24156                 redirectsMap.set(path, redirects);
24157             }
24158             return redirects;
24159         }
24160         function clear() {
24161             ownMap.clear();
24162             redirectsMap.clear();
24163         }
24164     }
24165     ts.createCacheWithRedirects = createCacheWithRedirects;
24166     function createModuleResolutionCacheWithMaps(directoryToModuleNameMap, moduleNameToDirectoryMap, currentDirectory, getCanonicalFileName) {
24167         return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, directoryToModuleNameMap: directoryToModuleNameMap, moduleNameToDirectoryMap: moduleNameToDirectoryMap };
24168         function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
24169             var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
24170             return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, ts.createMap);
24171         }
24172         function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) {
24173             ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
24174             return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache);
24175         }
24176         function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) {
24177             var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
24178             var result = cache.get(key);
24179             if (!result) {
24180                 result = create();
24181                 cache.set(key, result);
24182             }
24183             return result;
24184         }
24185         function createPerModuleNameCache() {
24186             var directoryPathMap = ts.createMap();
24187             return { get: get, set: set };
24188             function get(directory) {
24189                 return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName));
24190             }
24191             function set(directory, result) {
24192                 var path = ts.toPath(directory, currentDirectory, getCanonicalFileName);
24193                 if (directoryPathMap.has(path)) {
24194                     return;
24195                 }
24196                 directoryPathMap.set(path, result);
24197                 var resolvedFileName = result.resolvedModule &&
24198                     (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
24199                 var commonPrefix = resolvedFileName && getCommonPrefix(path, resolvedFileName);
24200                 var current = path;
24201                 while (current !== commonPrefix) {
24202                     var parent = ts.getDirectoryPath(current);
24203                     if (parent === current || directoryPathMap.has(parent)) {
24204                         break;
24205                     }
24206                     directoryPathMap.set(parent, result);
24207                     current = parent;
24208                 }
24209             }
24210             function getCommonPrefix(directory, resolution) {
24211                 var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName);
24212                 var i = 0;
24213                 var limit = Math.min(directory.length, resolutionDirectory.length);
24214                 while (i < limit && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
24215                     i++;
24216                 }
24217                 if (i === directory.length && (resolutionDirectory.length === i || resolutionDirectory[i] === ts.directorySeparator)) {
24218                     return directory;
24219                 }
24220                 var rootLength = ts.getRootLength(directory);
24221                 if (i < rootLength) {
24222                     return undefined;
24223                 }
24224                 var sep = directory.lastIndexOf(ts.directorySeparator, i - 1);
24225                 if (sep === -1) {
24226                     return undefined;
24227                 }
24228                 return directory.substr(0, Math.max(sep, rootLength));
24229             }
24230         }
24231     }
24232     ts.createModuleResolutionCacheWithMaps = createModuleResolutionCacheWithMaps;
24233     function resolveModuleNameFromCache(moduleName, containingFile, cache) {
24234         var containingDirectory = ts.getDirectoryPath(containingFile);
24235         var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory);
24236         return perFolderCache && perFolderCache.get(moduleName);
24237     }
24238     ts.resolveModuleNameFromCache = resolveModuleNameFromCache;
24239     function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
24240         var traceEnabled = isTraceEnabled(compilerOptions, host);
24241         if (redirectedReference) {
24242             compilerOptions = redirectedReference.commandLine.options;
24243         }
24244         if (traceEnabled) {
24245             trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile);
24246             if (redirectedReference) {
24247                 trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName);
24248             }
24249         }
24250         var containingDirectory = ts.getDirectoryPath(containingFile);
24251         var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference);
24252         var result = perFolderCache && perFolderCache.get(moduleName);
24253         if (result) {
24254             if (traceEnabled) {
24255                 trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
24256             }
24257         }
24258         else {
24259             var moduleResolution = compilerOptions.moduleResolution;
24260             if (moduleResolution === undefined) {
24261                 moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic;
24262                 if (traceEnabled) {
24263                     trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]);
24264                 }
24265             }
24266             else {
24267                 if (traceEnabled) {
24268                     trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]);
24269                 }
24270             }
24271             ts.perfLogger.logStartResolveModule(moduleName);
24272             switch (moduleResolution) {
24273                 case ts.ModuleResolutionKind.NodeJs:
24274                     result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference);
24275                     break;
24276                 case ts.ModuleResolutionKind.Classic:
24277                     result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference);
24278                     break;
24279                 default:
24280                     return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution);
24281             }
24282             if (result && result.resolvedModule)
24283                 ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\"");
24284             ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null");
24285             if (perFolderCache) {
24286                 perFolderCache.set(moduleName, result);
24287                 if (!ts.isExternalModuleNameRelative(moduleName)) {
24288                     cache.getOrCreateCacheForModuleName(moduleName, redirectedReference).set(containingDirectory, result);
24289                 }
24290             }
24291         }
24292         if (traceEnabled) {
24293             if (result.resolvedModule) {
24294                 if (result.resolvedModule.packageId) {
24295                     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));
24296                 }
24297                 else {
24298                     trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName);
24299                 }
24300             }
24301             else {
24302                 trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName);
24303             }
24304         }
24305         return result;
24306     }
24307     ts.resolveModuleName = resolveModuleName;
24308     function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state) {
24309         var resolved = tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state);
24310         if (resolved)
24311             return resolved.value;
24312         if (!ts.isExternalModuleNameRelative(moduleName)) {
24313             return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state);
24314         }
24315         else {
24316             return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state);
24317         }
24318     }
24319     function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state) {
24320         var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths;
24321         if (baseUrl && paths && !ts.pathIsRelative(moduleName)) {
24322             if (state.traceEnabled) {
24323                 trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName);
24324                 trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName);
24325             }
24326             return tryLoadModuleUsingPaths(extensions, moduleName, baseUrl, paths, loader, false, state);
24327         }
24328     }
24329     function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state) {
24330         if (!state.compilerOptions.rootDirs) {
24331             return undefined;
24332         }
24333         if (state.traceEnabled) {
24334             trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName);
24335         }
24336         var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName));
24337         var matchedRootDir;
24338         var matchedNormalizedPrefix;
24339         for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) {
24340             var rootDir = _a[_i];
24341             var normalizedRoot = ts.normalizePath(rootDir);
24342             if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) {
24343                 normalizedRoot += ts.directorySeparator;
24344             }
24345             var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) &&
24346                 (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length);
24347             if (state.traceEnabled) {
24348                 trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix);
24349             }
24350             if (isLongestMatchingPrefix) {
24351                 matchedNormalizedPrefix = normalizedRoot;
24352                 matchedRootDir = rootDir;
24353             }
24354         }
24355         if (matchedNormalizedPrefix) {
24356             if (state.traceEnabled) {
24357                 trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix);
24358             }
24359             var suffix = candidate.substr(matchedNormalizedPrefix.length);
24360             if (state.traceEnabled) {
24361                 trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate);
24362             }
24363             var resolvedFileName = loader(extensions, candidate, !ts.directoryProbablyExists(containingDirectory, state.host), state);
24364             if (resolvedFileName) {
24365                 return resolvedFileName;
24366             }
24367             if (state.traceEnabled) {
24368                 trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs);
24369             }
24370             for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) {
24371                 var rootDir = _c[_b];
24372                 if (rootDir === matchedRootDir) {
24373                     continue;
24374                 }
24375                 var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix);
24376                 if (state.traceEnabled) {
24377                     trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1);
24378                 }
24379                 var baseDirectory = ts.getDirectoryPath(candidate_1);
24380                 var resolvedFileName_1 = loader(extensions, candidate_1, !ts.directoryProbablyExists(baseDirectory, state.host), state);
24381                 if (resolvedFileName_1) {
24382                     return resolvedFileName_1;
24383                 }
24384             }
24385             if (state.traceEnabled) {
24386                 trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed);
24387             }
24388         }
24389         return undefined;
24390     }
24391     function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state) {
24392         var baseUrl = state.compilerOptions.baseUrl;
24393         if (!baseUrl) {
24394             return undefined;
24395         }
24396         if (state.traceEnabled) {
24397             trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName);
24398         }
24399         var candidate = ts.normalizePath(ts.combinePaths(baseUrl, moduleName));
24400         if (state.traceEnabled) {
24401             trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, baseUrl, candidate);
24402         }
24403         return loader(extensions, candidate, !ts.directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state);
24404     }
24405     function resolveJSModule(moduleName, initialDir, host) {
24406         var _a = tryResolveJSModuleWorker(moduleName, initialDir, host), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations;
24407         if (!resolvedModule) {
24408             throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", "));
24409         }
24410         return resolvedModule.resolvedFileName;
24411     }
24412     ts.resolveJSModule = resolveJSModule;
24413     function tryResolveJSModule(moduleName, initialDir, host) {
24414         var resolvedModule = tryResolveJSModuleWorker(moduleName, initialDir, host).resolvedModule;
24415         return resolvedModule && resolvedModule.resolvedFileName;
24416     }
24417     ts.tryResolveJSModule = tryResolveJSModule;
24418     var jsOnlyExtensions = [Extensions.JavaScript];
24419     var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
24420     var tsPlusJsonExtensions = __spreadArrays(tsExtensions, [Extensions.Json]);
24421     var tsconfigExtensions = [Extensions.TSConfig];
24422     function tryResolveJSModuleWorker(moduleName, initialDir, host) {
24423         return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, undefined, jsOnlyExtensions, undefined);
24424     }
24425     function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
24426         return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
24427     }
24428     ts.nodeModuleNameResolver = nodeModuleNameResolver;
24429     function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
24430         var _a, _b;
24431         var traceEnabled = isTraceEnabled(compilerOptions, host);
24432         var failedLookupLocations = [];
24433         var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
24434         var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
24435         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);
24436         function tryResolve(extensions) {
24437             var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, true); };
24438             var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
24439             if (resolved) {
24440                 return toSearchResult({ resolved: resolved, isExternalLibraryImport: pathContainsNodeModules(resolved.path) });
24441             }
24442             if (!ts.isExternalModuleNameRelative(moduleName)) {
24443                 if (traceEnabled) {
24444                     trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]);
24445                 }
24446                 var resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
24447                 if (!resolved_1)
24448                     return undefined;
24449                 var resolvedValue = resolved_1.value;
24450                 if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) {
24451                     var path = realPath(resolvedValue.path, host, traceEnabled);
24452                     var originalPath = path === resolvedValue.path ? undefined : resolvedValue.path;
24453                     resolvedValue = __assign(__assign({}, resolvedValue), { path: path, originalPath: originalPath });
24454                 }
24455                 return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } };
24456             }
24457             else {
24458                 var _a = ts.normalizePathAndParts(ts.combinePaths(containingDirectory, moduleName)), candidate = _a.path, parts = _a.parts;
24459                 var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, false, state, true);
24460                 return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") });
24461             }
24462         }
24463     }
24464     function realPath(path, host, traceEnabled) {
24465         if (!host.realpath) {
24466             return path;
24467         }
24468         var real = ts.normalizePath(host.realpath(path));
24469         if (traceEnabled) {
24470             trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real);
24471         }
24472         ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real);
24473         return real;
24474     }
24475     function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) {
24476         if (state.traceEnabled) {
24477             trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]);
24478         }
24479         if (!ts.hasTrailingDirectorySeparator(candidate)) {
24480             if (!onlyRecordFailures) {
24481                 var parentOfCandidate = ts.getDirectoryPath(candidate);
24482                 if (!ts.directoryProbablyExists(parentOfCandidate, state.host)) {
24483                     if (state.traceEnabled) {
24484                         trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate);
24485                     }
24486                     onlyRecordFailures = true;
24487                 }
24488             }
24489             var resolvedFromFile = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state);
24490             if (resolvedFromFile) {
24491                 var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined;
24492                 var packageInfo = packageDirectory ? getPackageJsonInfo(packageDirectory, false, state) : undefined;
24493                 return withPackageId(packageInfo, resolvedFromFile);
24494             }
24495         }
24496         if (!onlyRecordFailures) {
24497             var candidateExists = ts.directoryProbablyExists(candidate, state.host);
24498             if (!candidateExists) {
24499                 if (state.traceEnabled) {
24500                     trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate);
24501                 }
24502                 onlyRecordFailures = true;
24503             }
24504         }
24505         return loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson);
24506     }
24507     ts.nodeModulesPathPart = "/node_modules/";
24508     function pathContainsNodeModules(path) {
24509         return ts.stringContains(path, ts.nodeModulesPathPart);
24510     }
24511     ts.pathContainsNodeModules = pathContainsNodeModules;
24512     function parseNodeModuleFromPath(resolved) {
24513         var path = ts.normalizePath(resolved.path);
24514         var idx = path.lastIndexOf(ts.nodeModulesPathPart);
24515         if (idx === -1) {
24516             return undefined;
24517         }
24518         var indexAfterNodeModules = idx + ts.nodeModulesPathPart.length;
24519         var indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules);
24520         if (path.charCodeAt(indexAfterNodeModules) === 64) {
24521             indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName);
24522         }
24523         return path.slice(0, indexAfterPackageName);
24524     }
24525     function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex) {
24526         var nextSeparatorIndex = path.indexOf(ts.directorySeparator, prevSeparatorIndex + 1);
24527         return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex;
24528     }
24529     function loadModuleFromFileNoPackageId(extensions, candidate, onlyRecordFailures, state) {
24530         return noPackageId(loadModuleFromFile(extensions, candidate, onlyRecordFailures, state));
24531     }
24532     function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) {
24533         if (extensions === Extensions.Json || extensions === Extensions.TSConfig) {
24534             var extensionLess = ts.tryRemoveExtension(candidate, ".json");
24535             return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, onlyRecordFailures, state);
24536         }
24537         var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, onlyRecordFailures, state);
24538         if (resolvedByAddingExtension) {
24539             return resolvedByAddingExtension;
24540         }
24541         if (ts.hasJSFileExtension(candidate)) {
24542             var extensionless = ts.removeFileExtension(candidate);
24543             if (state.traceEnabled) {
24544                 var extension = candidate.substring(extensionless.length);
24545                 trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension);
24546             }
24547             return tryAddingExtensions(extensionless, extensions, onlyRecordFailures, state);
24548         }
24549     }
24550     function tryAddingExtensions(candidate, extensions, onlyRecordFailures, state) {
24551         if (!onlyRecordFailures) {
24552             var directory = ts.getDirectoryPath(candidate);
24553             if (directory) {
24554                 onlyRecordFailures = !ts.directoryProbablyExists(directory, state.host);
24555             }
24556         }
24557         switch (extensions) {
24558             case Extensions.DtsOnly:
24559                 return tryExtension(".d.ts");
24560             case Extensions.TypeScript:
24561                 return tryExtension(".ts") || tryExtension(".tsx") || tryExtension(".d.ts");
24562             case Extensions.JavaScript:
24563                 return tryExtension(".js") || tryExtension(".jsx");
24564             case Extensions.TSConfig:
24565             case Extensions.Json:
24566                 return tryExtension(".json");
24567         }
24568         function tryExtension(ext) {
24569             var path = tryFile(candidate + ext, onlyRecordFailures, state);
24570             return path === undefined ? undefined : { path: path, ext: ext };
24571         }
24572     }
24573     function tryFile(fileName, onlyRecordFailures, state) {
24574         if (!onlyRecordFailures) {
24575             if (state.host.fileExists(fileName)) {
24576                 if (state.traceEnabled) {
24577                     trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName);
24578                 }
24579                 return fileName;
24580             }
24581             else {
24582                 if (state.traceEnabled) {
24583                     trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName);
24584                 }
24585             }
24586         }
24587         state.failedLookupLocations.push(fileName);
24588         return undefined;
24589     }
24590     function loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson) {
24591         if (considerPackageJson === void 0) { considerPackageJson = true; }
24592         var packageInfo = considerPackageJson ? getPackageJsonInfo(candidate, onlyRecordFailures, state) : undefined;
24593         var packageJsonContent = packageInfo && packageInfo.packageJsonContent;
24594         var versionPaths = packageInfo && packageInfo.versionPaths;
24595         return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
24596     }
24597     function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
24598         var host = state.host, traceEnabled = state.traceEnabled;
24599         var directoryExists = !onlyRecordFailures && ts.directoryProbablyExists(packageDirectory, host);
24600         var packageJsonPath = ts.combinePaths(packageDirectory, "package.json");
24601         if (directoryExists && host.fileExists(packageJsonPath)) {
24602             var packageJsonContent = ts.readJson(packageJsonPath, host);
24603             if (traceEnabled) {
24604                 trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
24605             }
24606             var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
24607             return { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths };
24608         }
24609         else {
24610             if (directoryExists && traceEnabled) {
24611                 trace(host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath);
24612             }
24613             state.failedLookupLocations.push(packageJsonPath);
24614         }
24615     }
24616     function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) {
24617         var packageFile;
24618         if (jsonContent) {
24619             switch (extensions) {
24620                 case Extensions.JavaScript:
24621                 case Extensions.Json:
24622                     packageFile = readPackageJsonMainField(jsonContent, candidate, state);
24623                     break;
24624                 case Extensions.TypeScript:
24625                     packageFile = readPackageJsonTypesFields(jsonContent, candidate, state) || readPackageJsonMainField(jsonContent, candidate, state);
24626                     break;
24627                 case Extensions.DtsOnly:
24628                     packageFile = readPackageJsonTypesFields(jsonContent, candidate, state);
24629                     break;
24630                 case Extensions.TSConfig:
24631                     packageFile = readPackageJsonTSConfigField(jsonContent, candidate, state);
24632                     break;
24633                 default:
24634                     return ts.Debug.assertNever(extensions);
24635             }
24636         }
24637         var loader = function (extensions, candidate, onlyRecordFailures, state) {
24638             var fromFile = tryFile(candidate, onlyRecordFailures, state);
24639             if (fromFile) {
24640                 var resolved = resolvedIfExtensionMatches(extensions, fromFile);
24641                 if (resolved) {
24642                     return noPackageId(resolved);
24643                 }
24644                 if (state.traceEnabled) {
24645                     trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromFile);
24646                 }
24647             }
24648             var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions;
24649             return nodeLoadModuleByRelativeName(nextExtensions, candidate, onlyRecordFailures, state, false);
24650         };
24651         var onlyRecordFailuresForPackageFile = packageFile ? !ts.directoryProbablyExists(ts.getDirectoryPath(packageFile), state.host) : undefined;
24652         var onlyRecordFailuresForIndex = onlyRecordFailures || !ts.directoryProbablyExists(candidate, state.host);
24653         var indexPath = ts.combinePaths(candidate, extensions === Extensions.TSConfig ? "tsconfig" : "index");
24654         if (versionPaths && (!packageFile || ts.containsPath(candidate, packageFile))) {
24655             var moduleName = ts.getRelativePathFromDirectory(candidate, packageFile || indexPath, false);
24656             if (state.traceEnabled) {
24657                 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);
24658             }
24659             var result = tryLoadModuleUsingPaths(extensions, moduleName, candidate, versionPaths.paths, loader, onlyRecordFailuresForPackageFile || onlyRecordFailuresForIndex, state);
24660             if (result) {
24661                 return removeIgnoredPackageId(result.value);
24662             }
24663         }
24664         var packageFileResult = packageFile && removeIgnoredPackageId(loader(extensions, packageFile, onlyRecordFailuresForPackageFile, state));
24665         if (packageFileResult)
24666             return packageFileResult;
24667         return loadModuleFromFile(extensions, indexPath, onlyRecordFailuresForIndex, state);
24668     }
24669     function resolvedIfExtensionMatches(extensions, path) {
24670         var ext = ts.tryGetExtensionFromPath(path);
24671         return ext !== undefined && extensionIsOk(extensions, ext) ? { path: path, ext: ext } : undefined;
24672     }
24673     function extensionIsOk(extensions, extension) {
24674         switch (extensions) {
24675             case Extensions.JavaScript:
24676                 return extension === ".js" || extension === ".jsx";
24677             case Extensions.TSConfig:
24678             case Extensions.Json:
24679                 return extension === ".json";
24680             case Extensions.TypeScript:
24681                 return extension === ".ts" || extension === ".tsx" || extension === ".d.ts";
24682             case Extensions.DtsOnly:
24683                 return extension === ".d.ts";
24684         }
24685     }
24686     function parsePackageName(moduleName) {
24687         var idx = moduleName.indexOf(ts.directorySeparator);
24688         if (moduleName[0] === "@") {
24689             idx = moduleName.indexOf(ts.directorySeparator, idx + 1);
24690         }
24691         return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) };
24692     }
24693     ts.parsePackageName = parsePackageName;
24694     function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) {
24695         return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, false, cache, redirectedReference);
24696     }
24697     function loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, directory, state) {
24698         return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, true, undefined, undefined);
24699     }
24700     function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
24701         var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference);
24702         return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) {
24703             if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
24704                 var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state);
24705                 if (resolutionFromCache) {
24706                     return resolutionFromCache;
24707                 }
24708                 return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, ancestorDirectory, state, typesScopeOnly));
24709             }
24710         });
24711     }
24712     function loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, directory, state, typesScopeOnly) {
24713         var nodeModulesFolder = ts.combinePaths(directory, "node_modules");
24714         var nodeModulesFolderExists = ts.directoryProbablyExists(nodeModulesFolder, state.host);
24715         if (!nodeModulesFolderExists && state.traceEnabled) {
24716             trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder);
24717         }
24718         var packageResult = typesScopeOnly ? undefined : loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, state);
24719         if (packageResult) {
24720             return packageResult;
24721         }
24722         if (extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) {
24723             var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types");
24724             var nodeModulesAtTypesExists = nodeModulesFolderExists;
24725             if (nodeModulesFolderExists && !ts.directoryProbablyExists(nodeModulesAtTypes_1, state.host)) {
24726                 if (state.traceEnabled) {
24727                     trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1);
24728                 }
24729                 nodeModulesAtTypesExists = false;
24730             }
24731             return loadModuleFromSpecificNodeModulesDirectory(Extensions.DtsOnly, mangleScopedPackageNameWithTrace(moduleName, state), nodeModulesAtTypes_1, nodeModulesAtTypesExists, state);
24732         }
24733     }
24734     function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state) {
24735         var candidate = ts.normalizePath(ts.combinePaths(nodeModulesDirectory, moduleName));
24736         var packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
24737         if (packageInfo) {
24738             var fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state);
24739             if (fromFile) {
24740                 return noPackageId(fromFile);
24741             }
24742             var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageInfo.packageJsonContent, packageInfo.versionPaths);
24743             return withPackageId(packageInfo, fromDirectory);
24744         }
24745         var loader = function (extensions, candidate, onlyRecordFailures, state) {
24746             var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
24747                 loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
24748             return withPackageId(packageInfo, pathAndExtension);
24749         };
24750         var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
24751         if (rest !== "") {
24752             var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
24753             packageInfo = getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state);
24754             if (packageInfo && packageInfo.versionPaths) {
24755                 if (state.traceEnabled) {
24756                     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);
24757                 }
24758                 var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host);
24759                 var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, loader, !packageDirectoryExists, state);
24760                 if (fromPaths) {
24761                     return fromPaths.value;
24762                 }
24763             }
24764         }
24765         return loader(extensions, candidate, !nodeModulesDirectoryExists, state);
24766     }
24767     function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, onlyRecordFailures, state) {
24768         var matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(paths), moduleName);
24769         if (matchedPattern) {
24770             var matchedStar_1 = ts.isString(matchedPattern) ? undefined : ts.matchedText(matchedPattern, moduleName);
24771             var matchedPatternText = ts.isString(matchedPattern) ? matchedPattern : ts.patternText(matchedPattern);
24772             if (state.traceEnabled) {
24773                 trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText);
24774             }
24775             var resolved = ts.forEach(paths[matchedPatternText], function (subst) {
24776                 var path = matchedStar_1 ? subst.replace("*", matchedStar_1) : subst;
24777                 var candidate = ts.normalizePath(ts.combinePaths(baseDirectory, path));
24778                 if (state.traceEnabled) {
24779                     trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path);
24780                 }
24781                 var extension = ts.tryGetExtensionFromPath(candidate);
24782                 if (extension !== undefined) {
24783                     var path_1 = tryFile(candidate, onlyRecordFailures, state);
24784                     if (path_1 !== undefined) {
24785                         return noPackageId({ path: path_1, ext: extension });
24786                     }
24787                 }
24788                 return loader(extensions, candidate, onlyRecordFailures || !ts.directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state);
24789             });
24790             return { value: resolved };
24791         }
24792     }
24793     var mangledScopedPackageSeparator = "__";
24794     function mangleScopedPackageNameWithTrace(packageName, state) {
24795         var mangled = mangleScopedPackageName(packageName);
24796         if (state.traceEnabled && mangled !== packageName) {
24797             trace(state.host, ts.Diagnostics.Scoped_package_detected_looking_in_0, mangled);
24798         }
24799         return mangled;
24800     }
24801     function getTypesPackageName(packageName) {
24802         return "@types/" + mangleScopedPackageName(packageName);
24803     }
24804     ts.getTypesPackageName = getTypesPackageName;
24805     function mangleScopedPackageName(packageName) {
24806         if (ts.startsWith(packageName, "@")) {
24807             var replaceSlash = packageName.replace(ts.directorySeparator, mangledScopedPackageSeparator);
24808             if (replaceSlash !== packageName) {
24809                 return replaceSlash.slice(1);
24810             }
24811         }
24812         return packageName;
24813     }
24814     ts.mangleScopedPackageName = mangleScopedPackageName;
24815     function getPackageNameFromTypesPackageName(mangledName) {
24816         var withoutAtTypePrefix = ts.removePrefix(mangledName, "@types/");
24817         if (withoutAtTypePrefix !== mangledName) {
24818             return unmangleScopedPackageName(withoutAtTypePrefix);
24819         }
24820         return mangledName;
24821     }
24822     ts.getPackageNameFromTypesPackageName = getPackageNameFromTypesPackageName;
24823     function unmangleScopedPackageName(typesPackageName) {
24824         return ts.stringContains(typesPackageName, mangledScopedPackageSeparator) ?
24825             "@" + typesPackageName.replace(mangledScopedPackageSeparator, ts.directorySeparator) :
24826             typesPackageName;
24827     }
24828     ts.unmangleScopedPackageName = unmangleScopedPackageName;
24829     function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, state) {
24830         var result = cache && cache.get(containingDirectory);
24831         if (result) {
24832             if (state.traceEnabled) {
24833                 trace(state.host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
24834             }
24835             state.resultFromCache = result;
24836             return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, originalPath: result.resolvedModule.originalPath || true, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId } };
24837         }
24838     }
24839     function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
24840         var traceEnabled = isTraceEnabled(compilerOptions, host);
24841         var failedLookupLocations = [];
24842         var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
24843         var containingDirectory = ts.getDirectoryPath(containingFile);
24844         var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
24845         return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations, state.resultFromCache);
24846         function tryResolve(extensions) {
24847             var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
24848             if (resolvedUsingSettings) {
24849                 return { value: resolvedUsingSettings };
24850             }
24851             if (!ts.isExternalModuleNameRelative(moduleName)) {
24852                 var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference);
24853                 var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) {
24854                     var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state);
24855                     if (resolutionFromCache) {
24856                         return resolutionFromCache;
24857                     }
24858                     var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName));
24859                     return toSearchResult(loadModuleFromFileNoPackageId(extensions, searchName, false, state));
24860                 });
24861                 if (resolved_3) {
24862                     return resolved_3;
24863                 }
24864                 if (extensions === Extensions.TypeScript) {
24865                     return loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, containingDirectory, state);
24866                 }
24867             }
24868             else {
24869                 var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName));
24870                 return toSearchResult(loadModuleFromFileNoPackageId(extensions, candidate, false, state));
24871             }
24872         }
24873     }
24874     ts.classicNameResolver = classicNameResolver;
24875     function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) {
24876         var traceEnabled = isTraceEnabled(compilerOptions, host);
24877         if (traceEnabled) {
24878             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);
24879         }
24880         var failedLookupLocations = [];
24881         var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
24882         var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, false);
24883         return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations, state.resultFromCache);
24884     }
24885     ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
24886     function toSearchResult(value) {
24887         return value !== undefined ? { value: value } : undefined;
24888     }
24889 })(ts || (ts = {}));
24890 var ts;
24891 (function (ts) {
24892     function getModuleInstanceState(node, visited) {
24893         if (node.body && !node.body.parent) {
24894             setParentPointers(node, node.body);
24895         }
24896         return node.body ? getModuleInstanceStateCached(node.body, visited) : 1;
24897     }
24898     ts.getModuleInstanceState = getModuleInstanceState;
24899     function getModuleInstanceStateCached(node, visited) {
24900         if (visited === void 0) { visited = ts.createMap(); }
24901         var nodeId = "" + ts.getNodeId(node);
24902         if (visited.has(nodeId)) {
24903             return visited.get(nodeId) || 0;
24904         }
24905         visited.set(nodeId, undefined);
24906         var result = getModuleInstanceStateWorker(node, visited);
24907         visited.set(nodeId, result);
24908         return result;
24909     }
24910     function getModuleInstanceStateWorker(node, visited) {
24911         switch (node.kind) {
24912             case 246:
24913             case 247:
24914                 return 0;
24915             case 248:
24916                 if (ts.isEnumConst(node)) {
24917                     return 2;
24918                 }
24919                 break;
24920             case 254:
24921             case 253:
24922                 if (!(ts.hasModifier(node, 1))) {
24923                     return 0;
24924                 }
24925                 break;
24926             case 260:
24927                 var exportDeclaration = node;
24928                 if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 261) {
24929                     var state = 0;
24930                     for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) {
24931                         var specifier = _a[_i];
24932                         var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited);
24933                         if (specifierState > state) {
24934                             state = specifierState;
24935                         }
24936                         if (state === 1) {
24937                             return state;
24938                         }
24939                     }
24940                     return state;
24941                 }
24942                 break;
24943             case 250: {
24944                 var state_1 = 0;
24945                 ts.forEachChild(node, function (n) {
24946                     var childState = getModuleInstanceStateCached(n, visited);
24947                     switch (childState) {
24948                         case 0:
24949                             return;
24950                         case 2:
24951                             state_1 = 2;
24952                             return;
24953                         case 1:
24954                             state_1 = 1;
24955                             return true;
24956                         default:
24957                             ts.Debug.assertNever(childState);
24958                     }
24959                 });
24960                 return state_1;
24961             }
24962             case 249:
24963                 return getModuleInstanceState(node, visited);
24964             case 75:
24965                 if (node.isInJSDocNamespace) {
24966                     return 0;
24967                 }
24968         }
24969         return 1;
24970     }
24971     function getModuleInstanceStateForAliasTarget(specifier, visited) {
24972         var name = specifier.propertyName || specifier.name;
24973         var p = specifier.parent;
24974         while (p) {
24975             if (ts.isBlock(p) || ts.isModuleBlock(p) || ts.isSourceFile(p)) {
24976                 var statements = p.statements;
24977                 var found = void 0;
24978                 for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) {
24979                     var statement = statements_1[_i];
24980                     if (ts.nodeHasName(statement, name)) {
24981                         if (!statement.parent) {
24982                             setParentPointers(p, statement);
24983                         }
24984                         var state = getModuleInstanceStateCached(statement, visited);
24985                         if (found === undefined || state > found) {
24986                             found = state;
24987                         }
24988                         if (found === 1) {
24989                             return found;
24990                         }
24991                     }
24992                 }
24993                 if (found !== undefined) {
24994                     return found;
24995                 }
24996             }
24997             p = p.parent;
24998         }
24999         return 1;
25000     }
25001     function initFlowNode(node) {
25002         ts.Debug.attachFlowNodeDebugInfo(node);
25003         return node;
25004     }
25005     var binder = createBinder();
25006     function bindSourceFile(file, options) {
25007         ts.performance.mark("beforeBind");
25008         ts.perfLogger.logStartBindFile("" + file.fileName);
25009         binder(file, options);
25010         ts.perfLogger.logStopBindFile();
25011         ts.performance.mark("afterBind");
25012         ts.performance.measure("Bind", "beforeBind", "afterBind");
25013     }
25014     ts.bindSourceFile = bindSourceFile;
25015     function createBinder() {
25016         var file;
25017         var options;
25018         var languageVersion;
25019         var parent;
25020         var container;
25021         var thisParentContainer;
25022         var blockScopeContainer;
25023         var lastContainer;
25024         var delayedTypeAliases;
25025         var seenThisKeyword;
25026         var currentFlow;
25027         var currentBreakTarget;
25028         var currentContinueTarget;
25029         var currentReturnTarget;
25030         var currentTrueTarget;
25031         var currentFalseTarget;
25032         var currentExceptionTarget;
25033         var preSwitchCaseFlow;
25034         var activeLabelList;
25035         var hasExplicitReturn;
25036         var emitFlags;
25037         var inStrictMode;
25038         var symbolCount = 0;
25039         var Symbol;
25040         var classifiableNames;
25041         var unreachableFlow = { flags: 1 };
25042         var reportedUnreachableFlow = { flags: 1 };
25043         var subtreeTransformFlags = 0;
25044         var skipTransformFlagAggregation;
25045         function createDiagnosticForNode(node, message, arg0, arg1, arg2) {
25046             return ts.createDiagnosticForNodeInSourceFile(ts.getSourceFileOfNode(node) || file, node, message, arg0, arg1, arg2);
25047         }
25048         function bindSourceFile(f, opts) {
25049             file = f;
25050             options = opts;
25051             languageVersion = ts.getEmitScriptTarget(options);
25052             inStrictMode = bindInStrictMode(file, opts);
25053             classifiableNames = ts.createUnderscoreEscapedMap();
25054             symbolCount = 0;
25055             skipTransformFlagAggregation = file.isDeclarationFile;
25056             Symbol = ts.objectAllocator.getSymbolConstructor();
25057             ts.Debug.attachFlowNodeDebugInfo(unreachableFlow);
25058             ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow);
25059             if (!file.locals) {
25060                 bind(file);
25061                 file.symbolCount = symbolCount;
25062                 file.classifiableNames = classifiableNames;
25063                 delayedBindJSDocTypedefTag();
25064             }
25065             file = undefined;
25066             options = undefined;
25067             languageVersion = undefined;
25068             parent = undefined;
25069             container = undefined;
25070             thisParentContainer = undefined;
25071             blockScopeContainer = undefined;
25072             lastContainer = undefined;
25073             delayedTypeAliases = undefined;
25074             seenThisKeyword = false;
25075             currentFlow = undefined;
25076             currentBreakTarget = undefined;
25077             currentContinueTarget = undefined;
25078             currentReturnTarget = undefined;
25079             currentTrueTarget = undefined;
25080             currentFalseTarget = undefined;
25081             currentExceptionTarget = undefined;
25082             activeLabelList = undefined;
25083             hasExplicitReturn = false;
25084             emitFlags = 0;
25085             subtreeTransformFlags = 0;
25086         }
25087         return bindSourceFile;
25088         function bindInStrictMode(file, opts) {
25089             if (ts.getStrictOptionValue(opts, "alwaysStrict") && !file.isDeclarationFile) {
25090                 return true;
25091             }
25092             else {
25093                 return !!file.externalModuleIndicator;
25094             }
25095         }
25096         function createSymbol(flags, name) {
25097             symbolCount++;
25098             return new Symbol(flags, name);
25099         }
25100         function addDeclarationToSymbol(symbol, node, symbolFlags) {
25101             symbol.flags |= symbolFlags;
25102             node.symbol = symbol;
25103             symbol.declarations = ts.appendIfUnique(symbol.declarations, node);
25104             if (symbolFlags & (32 | 384 | 1536 | 3) && !symbol.exports) {
25105                 symbol.exports = ts.createSymbolTable();
25106             }
25107             if (symbolFlags & (32 | 64 | 2048 | 4096) && !symbol.members) {
25108                 symbol.members = ts.createSymbolTable();
25109             }
25110             if (symbol.constEnumOnlyModule && (symbol.flags & (16 | 32 | 256))) {
25111                 symbol.constEnumOnlyModule = false;
25112             }
25113             if (symbolFlags & 111551) {
25114                 ts.setValueDeclaration(symbol, node);
25115             }
25116         }
25117         function getDeclarationName(node) {
25118             if (node.kind === 259) {
25119                 return node.isExportEquals ? "export=" : "default";
25120             }
25121             var name = ts.getNameOfDeclaration(node);
25122             if (name) {
25123                 if (ts.isAmbientModule(node)) {
25124                     var moduleName = ts.getTextOfIdentifierOrLiteral(name);
25125                     return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\"");
25126                 }
25127                 if (name.kind === 154) {
25128                     var nameExpression = name.expression;
25129                     if (ts.isStringOrNumericLiteralLike(nameExpression)) {
25130                         return ts.escapeLeadingUnderscores(nameExpression.text);
25131                     }
25132                     if (ts.isSignedNumericLiteral(nameExpression)) {
25133                         return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text;
25134                     }
25135                     ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression));
25136                     return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name));
25137                 }
25138                 if (ts.isWellKnownSymbolSyntactically(name)) {
25139                     return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name));
25140                 }
25141                 if (ts.isPrivateIdentifier(name)) {
25142                     var containingClass = ts.getContainingClass(node);
25143                     if (!containingClass) {
25144                         return undefined;
25145                     }
25146                     var containingClassSymbol = containingClass.symbol;
25147                     return ts.getSymbolNameForPrivateIdentifier(containingClassSymbol, name.escapedText);
25148                 }
25149                 return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined;
25150             }
25151             switch (node.kind) {
25152                 case 162:
25153                     return "__constructor";
25154                 case 170:
25155                 case 165:
25156                 case 305:
25157                     return "__call";
25158                 case 171:
25159                 case 166:
25160                     return "__new";
25161                 case 167:
25162                     return "__index";
25163                 case 260:
25164                     return "__export";
25165                 case 290:
25166                     return "export=";
25167                 case 209:
25168                     if (ts.getAssignmentDeclarationKind(node) === 2) {
25169                         return "export=";
25170                     }
25171                     ts.Debug.fail("Unknown binary declaration kind");
25172                     break;
25173                 case 300:
25174                     return (ts.isJSDocConstructSignature(node) ? "__new" : "__call");
25175                 case 156:
25176                     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"; });
25177                     var functionType = node.parent;
25178                     var index = functionType.parameters.indexOf(node);
25179                     return "arg" + index;
25180             }
25181         }
25182         function getDisplayName(node) {
25183             return ts.isNamedDeclaration(node) ? ts.declarationNameToString(node.name) : ts.unescapeLeadingUnderscores(ts.Debug.checkDefined(getDeclarationName(node)));
25184         }
25185         function declareSymbol(symbolTable, parent, node, includes, excludes, isReplaceableByMethod) {
25186             ts.Debug.assert(!ts.hasDynamicName(node));
25187             var isDefaultExport = ts.hasModifier(node, 512) || ts.isExportSpecifier(node) && node.name.escapedText === "default";
25188             var name = isDefaultExport && parent ? "default" : getDeclarationName(node);
25189             var symbol;
25190             if (name === undefined) {
25191                 symbol = createSymbol(0, "__missing");
25192             }
25193             else {
25194                 symbol = symbolTable.get(name);
25195                 if (includes & 2885600) {
25196                     classifiableNames.set(name, true);
25197                 }
25198                 if (!symbol) {
25199                     symbolTable.set(name, symbol = createSymbol(0, name));
25200                     if (isReplaceableByMethod)
25201                         symbol.isReplaceableByMethod = true;
25202                 }
25203                 else if (isReplaceableByMethod && !symbol.isReplaceableByMethod) {
25204                     return symbol;
25205                 }
25206                 else if (symbol.flags & excludes) {
25207                     if (symbol.isReplaceableByMethod) {
25208                         symbolTable.set(name, symbol = createSymbol(0, name));
25209                     }
25210                     else if (!(includes & 3 && symbol.flags & 67108864)) {
25211                         if (ts.isNamedDeclaration(node)) {
25212                             node.name.parent = node;
25213                         }
25214                         var message_1 = symbol.flags & 2
25215                             ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
25216                             : ts.Diagnostics.Duplicate_identifier_0;
25217                         var messageNeedsName_1 = true;
25218                         if (symbol.flags & 384 || includes & 384) {
25219                             message_1 = ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations;
25220                             messageNeedsName_1 = false;
25221                         }
25222                         var multipleDefaultExports_1 = false;
25223                         if (ts.length(symbol.declarations)) {
25224                             if (isDefaultExport) {
25225                                 message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports;
25226                                 messageNeedsName_1 = false;
25227                                 multipleDefaultExports_1 = true;
25228                             }
25229                             else {
25230                                 if (symbol.declarations && symbol.declarations.length &&
25231                                     (node.kind === 259 && !node.isExportEquals)) {
25232                                     message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports;
25233                                     messageNeedsName_1 = false;
25234                                     multipleDefaultExports_1 = true;
25235                                 }
25236                             }
25237                         }
25238                         var relatedInformation_1 = [];
25239                         if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasModifier(node, 1) && symbol.flags & (2097152 | 788968 | 1920)) {
25240                             relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { " + ts.unescapeLeadingUnderscores(node.name.escapedText) + " }"));
25241                         }
25242                         var declarationName_1 = ts.getNameOfDeclaration(node) || node;
25243                         ts.forEach(symbol.declarations, function (declaration, index) {
25244                             var decl = ts.getNameOfDeclaration(declaration) || declaration;
25245                             var diag = createDiagnosticForNode(decl, message_1, messageNeedsName_1 ? getDisplayName(declaration) : undefined);
25246                             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);
25247                             if (multipleDefaultExports_1) {
25248                                 relatedInformation_1.push(createDiagnosticForNode(decl, ts.Diagnostics.The_first_export_default_is_here));
25249                             }
25250                         });
25251                         var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined);
25252                         file.bindDiagnostics.push(ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInformation_1)));
25253                         symbol = createSymbol(0, name);
25254                     }
25255                 }
25256             }
25257             addDeclarationToSymbol(symbol, node, includes);
25258             if (symbol.parent) {
25259                 ts.Debug.assert(symbol.parent === parent, "Existing symbol parent should match new one");
25260             }
25261             else {
25262                 symbol.parent = parent;
25263             }
25264             return symbol;
25265         }
25266         function declareModuleMember(node, symbolFlags, symbolExcludes) {
25267             var hasExportModifier = ts.getCombinedModifierFlags(node) & 1;
25268             if (symbolFlags & 2097152) {
25269                 if (node.kind === 263 || (node.kind === 253 && hasExportModifier)) {
25270                     return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
25271                 }
25272                 else {
25273                     return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
25274                 }
25275             }
25276             else {
25277                 if (ts.isJSDocTypeAlias(node))
25278                     ts.Debug.assert(ts.isInJSFile(node));
25279                 if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64)) || ts.isJSDocTypeAlias(node)) {
25280                     if (!container.locals || (ts.hasModifier(node, 512) && !getDeclarationName(node))) {
25281                         return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
25282                     }
25283                     var exportKind = symbolFlags & 111551 ? 1048576 : 0;
25284                     var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes);
25285                     local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
25286                     node.localSymbol = local;
25287                     return local;
25288                 }
25289                 else {
25290                     return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
25291                 }
25292             }
25293         }
25294         function bindContainer(node, containerFlags) {
25295             var saveContainer = container;
25296             var saveThisParentContainer = thisParentContainer;
25297             var savedBlockScopeContainer = blockScopeContainer;
25298             if (containerFlags & 1) {
25299                 if (node.kind !== 202) {
25300                     thisParentContainer = container;
25301                 }
25302                 container = blockScopeContainer = node;
25303                 if (containerFlags & 32) {
25304                     container.locals = ts.createSymbolTable();
25305                 }
25306                 addToContainerChain(container);
25307             }
25308             else if (containerFlags & 2) {
25309                 blockScopeContainer = node;
25310                 blockScopeContainer.locals = undefined;
25311             }
25312             if (containerFlags & 4) {
25313                 var saveCurrentFlow = currentFlow;
25314                 var saveBreakTarget = currentBreakTarget;
25315                 var saveContinueTarget = currentContinueTarget;
25316                 var saveReturnTarget = currentReturnTarget;
25317                 var saveExceptionTarget = currentExceptionTarget;
25318                 var saveActiveLabelList = activeLabelList;
25319                 var saveHasExplicitReturn = hasExplicitReturn;
25320                 var isIIFE = containerFlags & 16 && !ts.hasModifier(node, 256) &&
25321                     !node.asteriskToken && !!ts.getImmediatelyInvokedFunctionExpression(node);
25322                 if (!isIIFE) {
25323                     currentFlow = initFlowNode({ flags: 2 });
25324                     if (containerFlags & (16 | 128)) {
25325                         currentFlow.node = node;
25326                     }
25327                 }
25328                 currentReturnTarget = isIIFE || node.kind === 162 ? createBranchLabel() : undefined;
25329                 currentExceptionTarget = undefined;
25330                 currentBreakTarget = undefined;
25331                 currentContinueTarget = undefined;
25332                 activeLabelList = undefined;
25333                 hasExplicitReturn = false;
25334                 bindChildren(node);
25335                 node.flags &= ~2816;
25336                 if (!(currentFlow.flags & 1) && containerFlags & 8 && ts.nodeIsPresent(node.body)) {
25337                     node.flags |= 256;
25338                     if (hasExplicitReturn)
25339                         node.flags |= 512;
25340                     node.endFlowNode = currentFlow;
25341                 }
25342                 if (node.kind === 290) {
25343                     node.flags |= emitFlags;
25344                 }
25345                 if (currentReturnTarget) {
25346                     addAntecedent(currentReturnTarget, currentFlow);
25347                     currentFlow = finishFlowLabel(currentReturnTarget);
25348                     if (node.kind === 162) {
25349                         node.returnFlowNode = currentFlow;
25350                     }
25351                 }
25352                 if (!isIIFE) {
25353                     currentFlow = saveCurrentFlow;
25354                 }
25355                 currentBreakTarget = saveBreakTarget;
25356                 currentContinueTarget = saveContinueTarget;
25357                 currentReturnTarget = saveReturnTarget;
25358                 currentExceptionTarget = saveExceptionTarget;
25359                 activeLabelList = saveActiveLabelList;
25360                 hasExplicitReturn = saveHasExplicitReturn;
25361             }
25362             else if (containerFlags & 64) {
25363                 seenThisKeyword = false;
25364                 bindChildren(node);
25365                 node.flags = seenThisKeyword ? node.flags | 128 : node.flags & ~128;
25366             }
25367             else {
25368                 bindChildren(node);
25369             }
25370             container = saveContainer;
25371             thisParentContainer = saveThisParentContainer;
25372             blockScopeContainer = savedBlockScopeContainer;
25373         }
25374         function bindChildren(node) {
25375             if (skipTransformFlagAggregation) {
25376                 bindChildrenWorker(node);
25377             }
25378             else if (node.transformFlags & 536870912) {
25379                 skipTransformFlagAggregation = true;
25380                 bindChildrenWorker(node);
25381                 skipTransformFlagAggregation = false;
25382                 subtreeTransformFlags |= node.transformFlags & ~getTransformFlagsSubtreeExclusions(node.kind);
25383             }
25384             else {
25385                 var savedSubtreeTransformFlags = subtreeTransformFlags;
25386                 subtreeTransformFlags = 0;
25387                 bindChildrenWorker(node);
25388                 subtreeTransformFlags = savedSubtreeTransformFlags | computeTransformFlagsForNode(node, subtreeTransformFlags);
25389             }
25390         }
25391         function bindEachFunctionsFirst(nodes) {
25392             bindEach(nodes, function (n) { return n.kind === 244 ? bind(n) : undefined; });
25393             bindEach(nodes, function (n) { return n.kind !== 244 ? bind(n) : undefined; });
25394         }
25395         function bindEach(nodes, bindFunction) {
25396             if (bindFunction === void 0) { bindFunction = bind; }
25397             if (nodes === undefined) {
25398                 return;
25399             }
25400             if (skipTransformFlagAggregation) {
25401                 ts.forEach(nodes, bindFunction);
25402             }
25403             else {
25404                 var savedSubtreeTransformFlags = subtreeTransformFlags;
25405                 subtreeTransformFlags = 0;
25406                 var nodeArrayFlags = 0;
25407                 for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
25408                     var node = nodes_2[_i];
25409                     bindFunction(node);
25410                     nodeArrayFlags |= node.transformFlags & ~536870912;
25411                 }
25412                 nodes.transformFlags = nodeArrayFlags | 536870912;
25413                 subtreeTransformFlags |= savedSubtreeTransformFlags;
25414             }
25415         }
25416         function bindEachChild(node) {
25417             ts.forEachChild(node, bind, bindEach);
25418         }
25419         function bindChildrenWorker(node) {
25420             if (checkUnreachable(node)) {
25421                 bindEachChild(node);
25422                 bindJSDoc(node);
25423                 return;
25424             }
25425             if (node.kind >= 225 && node.kind <= 241 && !options.allowUnreachableCode) {
25426                 node.flowNode = currentFlow;
25427             }
25428             switch (node.kind) {
25429                 case 229:
25430                     bindWhileStatement(node);
25431                     break;
25432                 case 228:
25433                     bindDoStatement(node);
25434                     break;
25435                 case 230:
25436                     bindForStatement(node);
25437                     break;
25438                 case 231:
25439                 case 232:
25440                     bindForInOrForOfStatement(node);
25441                     break;
25442                 case 227:
25443                     bindIfStatement(node);
25444                     break;
25445                 case 235:
25446                 case 239:
25447                     bindReturnOrThrow(node);
25448                     break;
25449                 case 234:
25450                 case 233:
25451                     bindBreakOrContinueStatement(node);
25452                     break;
25453                 case 240:
25454                     bindTryStatement(node);
25455                     break;
25456                 case 237:
25457                     bindSwitchStatement(node);
25458                     break;
25459                 case 251:
25460                     bindCaseBlock(node);
25461                     break;
25462                 case 277:
25463                     bindCaseClause(node);
25464                     break;
25465                 case 226:
25466                     bindExpressionStatement(node);
25467                     break;
25468                 case 238:
25469                     bindLabeledStatement(node);
25470                     break;
25471                 case 207:
25472                     bindPrefixUnaryExpressionFlow(node);
25473                     break;
25474                 case 208:
25475                     bindPostfixUnaryExpressionFlow(node);
25476                     break;
25477                 case 209:
25478                     bindBinaryExpressionFlow(node);
25479                     break;
25480                 case 203:
25481                     bindDeleteExpressionFlow(node);
25482                     break;
25483                 case 210:
25484                     bindConditionalExpressionFlow(node);
25485                     break;
25486                 case 242:
25487                     bindVariableDeclarationFlow(node);
25488                     break;
25489                 case 194:
25490                 case 195:
25491                     bindAccessExpressionFlow(node);
25492                     break;
25493                 case 196:
25494                     bindCallExpressionFlow(node);
25495                     break;
25496                 case 218:
25497                     bindNonNullExpressionFlow(node);
25498                     break;
25499                 case 322:
25500                 case 315:
25501                 case 316:
25502                     bindJSDocTypeAlias(node);
25503                     break;
25504                 case 290: {
25505                     bindEachFunctionsFirst(node.statements);
25506                     bind(node.endOfFileToken);
25507                     break;
25508                 }
25509                 case 223:
25510                 case 250:
25511                     bindEachFunctionsFirst(node.statements);
25512                     break;
25513                 default:
25514                     bindEachChild(node);
25515                     break;
25516             }
25517             bindJSDoc(node);
25518         }
25519         function isNarrowingExpression(expr) {
25520             switch (expr.kind) {
25521                 case 75:
25522                 case 104:
25523                 case 194:
25524                 case 195:
25525                     return containsNarrowableReference(expr);
25526                 case 196:
25527                     return hasNarrowableArgument(expr);
25528                 case 200:
25529                     return isNarrowingExpression(expr.expression);
25530                 case 209:
25531                     return isNarrowingBinaryExpression(expr);
25532                 case 207:
25533                     return expr.operator === 53 && isNarrowingExpression(expr.operand);
25534                 case 204:
25535                     return isNarrowingExpression(expr.expression);
25536             }
25537             return false;
25538         }
25539         function isNarrowableReference(expr) {
25540             return expr.kind === 75 || expr.kind === 104 || expr.kind === 102 ||
25541                 (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) ||
25542                 ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression);
25543         }
25544         function containsNarrowableReference(expr) {
25545             return isNarrowableReference(expr) || ts.isOptionalChain(expr) && containsNarrowableReference(expr.expression);
25546         }
25547         function hasNarrowableArgument(expr) {
25548             if (expr.arguments) {
25549                 for (var _i = 0, _a = expr.arguments; _i < _a.length; _i++) {
25550                     var argument = _a[_i];
25551                     if (containsNarrowableReference(argument)) {
25552                         return true;
25553                     }
25554                 }
25555             }
25556             if (expr.expression.kind === 194 &&
25557                 containsNarrowableReference(expr.expression.expression)) {
25558                 return true;
25559             }
25560             return false;
25561         }
25562         function isNarrowingTypeofOperands(expr1, expr2) {
25563             return ts.isTypeOfExpression(expr1) && isNarrowableOperand(expr1.expression) && ts.isStringLiteralLike(expr2);
25564         }
25565         function isNarrowableInOperands(left, right) {
25566             return ts.isStringLiteralLike(left) && isNarrowingExpression(right);
25567         }
25568         function isNarrowingBinaryExpression(expr) {
25569             switch (expr.operatorToken.kind) {
25570                 case 62:
25571                     return containsNarrowableReference(expr.left);
25572                 case 34:
25573                 case 35:
25574                 case 36:
25575                 case 37:
25576                     return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) ||
25577                         isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right);
25578                 case 98:
25579                     return isNarrowableOperand(expr.left);
25580                 case 97:
25581                     return isNarrowableInOperands(expr.left, expr.right);
25582                 case 27:
25583                     return isNarrowingExpression(expr.right);
25584             }
25585             return false;
25586         }
25587         function isNarrowableOperand(expr) {
25588             switch (expr.kind) {
25589                 case 200:
25590                     return isNarrowableOperand(expr.expression);
25591                 case 209:
25592                     switch (expr.operatorToken.kind) {
25593                         case 62:
25594                             return isNarrowableOperand(expr.left);
25595                         case 27:
25596                             return isNarrowableOperand(expr.right);
25597                     }
25598             }
25599             return containsNarrowableReference(expr);
25600         }
25601         function createBranchLabel() {
25602             return initFlowNode({ flags: 4, antecedents: undefined });
25603         }
25604         function createLoopLabel() {
25605             return initFlowNode({ flags: 8, antecedents: undefined });
25606         }
25607         function createReduceLabel(target, antecedents, antecedent) {
25608             return initFlowNode({ flags: 1024, target: target, antecedents: antecedents, antecedent: antecedent });
25609         }
25610         function setFlowNodeReferenced(flow) {
25611             flow.flags |= flow.flags & 2048 ? 4096 : 2048;
25612         }
25613         function addAntecedent(label, antecedent) {
25614             if (!(antecedent.flags & 1) && !ts.contains(label.antecedents, antecedent)) {
25615                 (label.antecedents || (label.antecedents = [])).push(antecedent);
25616                 setFlowNodeReferenced(antecedent);
25617             }
25618         }
25619         function createFlowCondition(flags, antecedent, expression) {
25620             if (antecedent.flags & 1) {
25621                 return antecedent;
25622             }
25623             if (!expression) {
25624                 return flags & 32 ? antecedent : unreachableFlow;
25625             }
25626             if ((expression.kind === 106 && flags & 64 ||
25627                 expression.kind === 91 && flags & 32) &&
25628                 !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) {
25629                 return unreachableFlow;
25630             }
25631             if (!isNarrowingExpression(expression)) {
25632                 return antecedent;
25633             }
25634             setFlowNodeReferenced(antecedent);
25635             return initFlowNode({ flags: flags, antecedent: antecedent, node: expression });
25636         }
25637         function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) {
25638             setFlowNodeReferenced(antecedent);
25639             return initFlowNode({ flags: 128, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd });
25640         }
25641         function createFlowMutation(flags, antecedent, node) {
25642             setFlowNodeReferenced(antecedent);
25643             var result = initFlowNode({ flags: flags, antecedent: antecedent, node: node });
25644             if (currentExceptionTarget) {
25645                 addAntecedent(currentExceptionTarget, result);
25646             }
25647             return result;
25648         }
25649         function createFlowCall(antecedent, node) {
25650             setFlowNodeReferenced(antecedent);
25651             return initFlowNode({ flags: 512, antecedent: antecedent, node: node });
25652         }
25653         function finishFlowLabel(flow) {
25654             var antecedents = flow.antecedents;
25655             if (!antecedents) {
25656                 return unreachableFlow;
25657             }
25658             if (antecedents.length === 1) {
25659                 return antecedents[0];
25660             }
25661             return flow;
25662         }
25663         function isStatementCondition(node) {
25664             var parent = node.parent;
25665             switch (parent.kind) {
25666                 case 227:
25667                 case 229:
25668                 case 228:
25669                     return parent.expression === node;
25670                 case 230:
25671                 case 210:
25672                     return parent.condition === node;
25673             }
25674             return false;
25675         }
25676         function isLogicalExpression(node) {
25677             while (true) {
25678                 if (node.kind === 200) {
25679                     node = node.expression;
25680                 }
25681                 else if (node.kind === 207 && node.operator === 53) {
25682                     node = node.operand;
25683                 }
25684                 else {
25685                     return node.kind === 209 && (node.operatorToken.kind === 55 ||
25686                         node.operatorToken.kind === 56 ||
25687                         node.operatorToken.kind === 60);
25688                 }
25689             }
25690         }
25691         function isTopLevelLogicalExpression(node) {
25692             while (ts.isParenthesizedExpression(node.parent) ||
25693                 ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53) {
25694                 node = node.parent;
25695             }
25696             return !isStatementCondition(node) &&
25697                 !isLogicalExpression(node.parent) &&
25698                 !(ts.isOptionalChain(node.parent) && node.parent.expression === node);
25699         }
25700         function doWithConditionalBranches(action, value, trueTarget, falseTarget) {
25701             var savedTrueTarget = currentTrueTarget;
25702             var savedFalseTarget = currentFalseTarget;
25703             currentTrueTarget = trueTarget;
25704             currentFalseTarget = falseTarget;
25705             action(value);
25706             currentTrueTarget = savedTrueTarget;
25707             currentFalseTarget = savedFalseTarget;
25708         }
25709         function bindCondition(node, trueTarget, falseTarget) {
25710             doWithConditionalBranches(bind, node, trueTarget, falseTarget);
25711             if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) {
25712                 addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node));
25713                 addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node));
25714             }
25715         }
25716         function bindIterativeStatement(node, breakTarget, continueTarget) {
25717             var saveBreakTarget = currentBreakTarget;
25718             var saveContinueTarget = currentContinueTarget;
25719             currentBreakTarget = breakTarget;
25720             currentContinueTarget = continueTarget;
25721             bind(node);
25722             currentBreakTarget = saveBreakTarget;
25723             currentContinueTarget = saveContinueTarget;
25724         }
25725         function setContinueTarget(node, target) {
25726             var label = activeLabelList;
25727             while (label && node.parent.kind === 238) {
25728                 label.continueTarget = target;
25729                 label = label.next;
25730                 node = node.parent;
25731             }
25732             return target;
25733         }
25734         function bindWhileStatement(node) {
25735             var preWhileLabel = setContinueTarget(node, createLoopLabel());
25736             var preBodyLabel = createBranchLabel();
25737             var postWhileLabel = createBranchLabel();
25738             addAntecedent(preWhileLabel, currentFlow);
25739             currentFlow = preWhileLabel;
25740             bindCondition(node.expression, preBodyLabel, postWhileLabel);
25741             currentFlow = finishFlowLabel(preBodyLabel);
25742             bindIterativeStatement(node.statement, postWhileLabel, preWhileLabel);
25743             addAntecedent(preWhileLabel, currentFlow);
25744             currentFlow = finishFlowLabel(postWhileLabel);
25745         }
25746         function bindDoStatement(node) {
25747             var preDoLabel = createLoopLabel();
25748             var preConditionLabel = setContinueTarget(node, createBranchLabel());
25749             var postDoLabel = createBranchLabel();
25750             addAntecedent(preDoLabel, currentFlow);
25751             currentFlow = preDoLabel;
25752             bindIterativeStatement(node.statement, postDoLabel, preConditionLabel);
25753             addAntecedent(preConditionLabel, currentFlow);
25754             currentFlow = finishFlowLabel(preConditionLabel);
25755             bindCondition(node.expression, preDoLabel, postDoLabel);
25756             currentFlow = finishFlowLabel(postDoLabel);
25757         }
25758         function bindForStatement(node) {
25759             var preLoopLabel = setContinueTarget(node, createLoopLabel());
25760             var preBodyLabel = createBranchLabel();
25761             var postLoopLabel = createBranchLabel();
25762             bind(node.initializer);
25763             addAntecedent(preLoopLabel, currentFlow);
25764             currentFlow = preLoopLabel;
25765             bindCondition(node.condition, preBodyLabel, postLoopLabel);
25766             currentFlow = finishFlowLabel(preBodyLabel);
25767             bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel);
25768             bind(node.incrementor);
25769             addAntecedent(preLoopLabel, currentFlow);
25770             currentFlow = finishFlowLabel(postLoopLabel);
25771         }
25772         function bindForInOrForOfStatement(node) {
25773             var preLoopLabel = setContinueTarget(node, createLoopLabel());
25774             var postLoopLabel = createBranchLabel();
25775             bind(node.expression);
25776             addAntecedent(preLoopLabel, currentFlow);
25777             currentFlow = preLoopLabel;
25778             if (node.kind === 232) {
25779                 bind(node.awaitModifier);
25780             }
25781             addAntecedent(postLoopLabel, currentFlow);
25782             bind(node.initializer);
25783             if (node.initializer.kind !== 243) {
25784                 bindAssignmentTargetFlow(node.initializer);
25785             }
25786             bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel);
25787             addAntecedent(preLoopLabel, currentFlow);
25788             currentFlow = finishFlowLabel(postLoopLabel);
25789         }
25790         function bindIfStatement(node) {
25791             var thenLabel = createBranchLabel();
25792             var elseLabel = createBranchLabel();
25793             var postIfLabel = createBranchLabel();
25794             bindCondition(node.expression, thenLabel, elseLabel);
25795             currentFlow = finishFlowLabel(thenLabel);
25796             bind(node.thenStatement);
25797             addAntecedent(postIfLabel, currentFlow);
25798             currentFlow = finishFlowLabel(elseLabel);
25799             bind(node.elseStatement);
25800             addAntecedent(postIfLabel, currentFlow);
25801             currentFlow = finishFlowLabel(postIfLabel);
25802         }
25803         function bindReturnOrThrow(node) {
25804             bind(node.expression);
25805             if (node.kind === 235) {
25806                 hasExplicitReturn = true;
25807                 if (currentReturnTarget) {
25808                     addAntecedent(currentReturnTarget, currentFlow);
25809                 }
25810             }
25811             currentFlow = unreachableFlow;
25812         }
25813         function findActiveLabel(name) {
25814             for (var label = activeLabelList; label; label = label.next) {
25815                 if (label.name === name) {
25816                     return label;
25817                 }
25818             }
25819             return undefined;
25820         }
25821         function bindBreakOrContinueFlow(node, breakTarget, continueTarget) {
25822             var flowLabel = node.kind === 234 ? breakTarget : continueTarget;
25823             if (flowLabel) {
25824                 addAntecedent(flowLabel, currentFlow);
25825                 currentFlow = unreachableFlow;
25826             }
25827         }
25828         function bindBreakOrContinueStatement(node) {
25829             bind(node.label);
25830             if (node.label) {
25831                 var activeLabel = findActiveLabel(node.label.escapedText);
25832                 if (activeLabel) {
25833                     activeLabel.referenced = true;
25834                     bindBreakOrContinueFlow(node, activeLabel.breakTarget, activeLabel.continueTarget);
25835                 }
25836             }
25837             else {
25838                 bindBreakOrContinueFlow(node, currentBreakTarget, currentContinueTarget);
25839             }
25840         }
25841         function bindTryStatement(node) {
25842             var saveReturnTarget = currentReturnTarget;
25843             var saveExceptionTarget = currentExceptionTarget;
25844             var normalExitLabel = createBranchLabel();
25845             var returnLabel = createBranchLabel();
25846             var exceptionLabel = createBranchLabel();
25847             if (node.finallyBlock) {
25848                 currentReturnTarget = returnLabel;
25849             }
25850             addAntecedent(exceptionLabel, currentFlow);
25851             currentExceptionTarget = exceptionLabel;
25852             bind(node.tryBlock);
25853             addAntecedent(normalExitLabel, currentFlow);
25854             if (node.catchClause) {
25855                 currentFlow = finishFlowLabel(exceptionLabel);
25856                 exceptionLabel = createBranchLabel();
25857                 addAntecedent(exceptionLabel, currentFlow);
25858                 currentExceptionTarget = exceptionLabel;
25859                 bind(node.catchClause);
25860                 addAntecedent(normalExitLabel, currentFlow);
25861             }
25862             currentReturnTarget = saveReturnTarget;
25863             currentExceptionTarget = saveExceptionTarget;
25864             if (node.finallyBlock) {
25865                 var finallyLabel = createBranchLabel();
25866                 finallyLabel.antecedents = ts.concatenate(ts.concatenate(normalExitLabel.antecedents, exceptionLabel.antecedents), returnLabel.antecedents);
25867                 currentFlow = finallyLabel;
25868                 bind(node.finallyBlock);
25869                 if (currentFlow.flags & 1) {
25870                     currentFlow = unreachableFlow;
25871                 }
25872                 else {
25873                     if (currentReturnTarget && returnLabel.antecedents) {
25874                         addAntecedent(currentReturnTarget, createReduceLabel(finallyLabel, returnLabel.antecedents, currentFlow));
25875                     }
25876                     currentFlow = normalExitLabel.antecedents ? createReduceLabel(finallyLabel, normalExitLabel.antecedents, currentFlow) : unreachableFlow;
25877                 }
25878             }
25879             else {
25880                 currentFlow = finishFlowLabel(normalExitLabel);
25881             }
25882         }
25883         function bindSwitchStatement(node) {
25884             var postSwitchLabel = createBranchLabel();
25885             bind(node.expression);
25886             var saveBreakTarget = currentBreakTarget;
25887             var savePreSwitchCaseFlow = preSwitchCaseFlow;
25888             currentBreakTarget = postSwitchLabel;
25889             preSwitchCaseFlow = currentFlow;
25890             bind(node.caseBlock);
25891             addAntecedent(postSwitchLabel, currentFlow);
25892             var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 278; });
25893             node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents;
25894             if (!hasDefault) {
25895                 addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0));
25896             }
25897             currentBreakTarget = saveBreakTarget;
25898             preSwitchCaseFlow = savePreSwitchCaseFlow;
25899             currentFlow = finishFlowLabel(postSwitchLabel);
25900         }
25901         function bindCaseBlock(node) {
25902             var savedSubtreeTransformFlags = subtreeTransformFlags;
25903             subtreeTransformFlags = 0;
25904             var clauses = node.clauses;
25905             var isNarrowingSwitch = isNarrowingExpression(node.parent.expression);
25906             var fallthroughFlow = unreachableFlow;
25907             for (var i = 0; i < clauses.length; i++) {
25908                 var clauseStart = i;
25909                 while (!clauses[i].statements.length && i + 1 < clauses.length) {
25910                     bind(clauses[i]);
25911                     i++;
25912                 }
25913                 var preCaseLabel = createBranchLabel();
25914                 addAntecedent(preCaseLabel, isNarrowingSwitch ? createFlowSwitchClause(preSwitchCaseFlow, node.parent, clauseStart, i + 1) : preSwitchCaseFlow);
25915                 addAntecedent(preCaseLabel, fallthroughFlow);
25916                 currentFlow = finishFlowLabel(preCaseLabel);
25917                 var clause = clauses[i];
25918                 bind(clause);
25919                 fallthroughFlow = currentFlow;
25920                 if (!(currentFlow.flags & 1) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) {
25921                     clause.fallthroughFlowNode = currentFlow;
25922                 }
25923             }
25924             clauses.transformFlags = subtreeTransformFlags | 536870912;
25925             subtreeTransformFlags |= savedSubtreeTransformFlags;
25926         }
25927         function bindCaseClause(node) {
25928             var saveCurrentFlow = currentFlow;
25929             currentFlow = preSwitchCaseFlow;
25930             bind(node.expression);
25931             currentFlow = saveCurrentFlow;
25932             bindEach(node.statements);
25933         }
25934         function bindExpressionStatement(node) {
25935             bind(node.expression);
25936             if (node.expression.kind === 196) {
25937                 var call = node.expression;
25938                 if (ts.isDottedName(call.expression)) {
25939                     currentFlow = createFlowCall(currentFlow, call);
25940                 }
25941             }
25942         }
25943         function bindLabeledStatement(node) {
25944             var postStatementLabel = createBranchLabel();
25945             activeLabelList = {
25946                 next: activeLabelList,
25947                 name: node.label.escapedText,
25948                 breakTarget: postStatementLabel,
25949                 continueTarget: undefined,
25950                 referenced: false
25951             };
25952             bind(node.label);
25953             bind(node.statement);
25954             if (!activeLabelList.referenced && !options.allowUnusedLabels) {
25955                 errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label);
25956             }
25957             activeLabelList = activeLabelList.next;
25958             addAntecedent(postStatementLabel, currentFlow);
25959             currentFlow = finishFlowLabel(postStatementLabel);
25960         }
25961         function bindDestructuringTargetFlow(node) {
25962             if (node.kind === 209 && node.operatorToken.kind === 62) {
25963                 bindAssignmentTargetFlow(node.left);
25964             }
25965             else {
25966                 bindAssignmentTargetFlow(node);
25967             }
25968         }
25969         function bindAssignmentTargetFlow(node) {
25970             if (isNarrowableReference(node)) {
25971                 currentFlow = createFlowMutation(16, currentFlow, node);
25972             }
25973             else if (node.kind === 192) {
25974                 for (var _i = 0, _a = node.elements; _i < _a.length; _i++) {
25975                     var e = _a[_i];
25976                     if (e.kind === 213) {
25977                         bindAssignmentTargetFlow(e.expression);
25978                     }
25979                     else {
25980                         bindDestructuringTargetFlow(e);
25981                     }
25982                 }
25983             }
25984             else if (node.kind === 193) {
25985                 for (var _b = 0, _c = node.properties; _b < _c.length; _b++) {
25986                     var p = _c[_b];
25987                     if (p.kind === 281) {
25988                         bindDestructuringTargetFlow(p.initializer);
25989                     }
25990                     else if (p.kind === 282) {
25991                         bindAssignmentTargetFlow(p.name);
25992                     }
25993                     else if (p.kind === 283) {
25994                         bindAssignmentTargetFlow(p.expression);
25995                     }
25996                 }
25997             }
25998         }
25999         function bindLogicalExpression(node, trueTarget, falseTarget) {
26000             var preRightLabel = createBranchLabel();
26001             if (node.operatorToken.kind === 55) {
26002                 bindCondition(node.left, preRightLabel, falseTarget);
26003             }
26004             else {
26005                 bindCondition(node.left, trueTarget, preRightLabel);
26006             }
26007             currentFlow = finishFlowLabel(preRightLabel);
26008             bind(node.operatorToken);
26009             bindCondition(node.right, trueTarget, falseTarget);
26010         }
26011         function bindPrefixUnaryExpressionFlow(node) {
26012             if (node.operator === 53) {
26013                 var saveTrueTarget = currentTrueTarget;
26014                 currentTrueTarget = currentFalseTarget;
26015                 currentFalseTarget = saveTrueTarget;
26016                 bindEachChild(node);
26017                 currentFalseTarget = currentTrueTarget;
26018                 currentTrueTarget = saveTrueTarget;
26019             }
26020             else {
26021                 bindEachChild(node);
26022                 if (node.operator === 45 || node.operator === 46) {
26023                     bindAssignmentTargetFlow(node.operand);
26024                 }
26025             }
26026         }
26027         function bindPostfixUnaryExpressionFlow(node) {
26028             bindEachChild(node);
26029             if (node.operator === 45 || node.operator === 46) {
26030                 bindAssignmentTargetFlow(node.operand);
26031             }
26032         }
26033         function bindBinaryExpressionFlow(node) {
26034             var workStacks = {
26035                 expr: [node],
26036                 state: [1],
26037                 inStrictMode: [undefined],
26038                 parent: [undefined],
26039                 subtreeFlags: [undefined]
26040             };
26041             var stackIndex = 0;
26042             while (stackIndex >= 0) {
26043                 node = workStacks.expr[stackIndex];
26044                 switch (workStacks.state[stackIndex]) {
26045                     case 0: {
26046                         node.parent = parent;
26047                         var saveInStrictMode = inStrictMode;
26048                         bindWorker(node);
26049                         var saveParent = parent;
26050                         parent = node;
26051                         var subtreeFlagsState = void 0;
26052                         if (skipTransformFlagAggregation) {
26053                         }
26054                         else if (node.transformFlags & 536870912) {
26055                             skipTransformFlagAggregation = true;
26056                             subtreeFlagsState = -1;
26057                         }
26058                         else {
26059                             var savedSubtreeTransformFlags = subtreeTransformFlags;
26060                             subtreeTransformFlags = 0;
26061                             subtreeFlagsState = savedSubtreeTransformFlags;
26062                         }
26063                         advanceState(1, saveInStrictMode, saveParent, subtreeFlagsState);
26064                         break;
26065                     }
26066                     case 1: {
26067                         var operator = node.operatorToken.kind;
26068                         if (operator === 55 || operator === 56 || operator === 60) {
26069                             if (isTopLevelLogicalExpression(node)) {
26070                                 var postExpressionLabel = createBranchLabel();
26071                                 bindLogicalExpression(node, postExpressionLabel, postExpressionLabel);
26072                                 currentFlow = finishFlowLabel(postExpressionLabel);
26073                             }
26074                             else {
26075                                 bindLogicalExpression(node, currentTrueTarget, currentFalseTarget);
26076                             }
26077                             completeNode();
26078                         }
26079                         else {
26080                             advanceState(2);
26081                             maybeBind(node.left);
26082                         }
26083                         break;
26084                     }
26085                     case 2: {
26086                         advanceState(3);
26087                         maybeBind(node.operatorToken);
26088                         break;
26089                     }
26090                     case 3: {
26091                         advanceState(4);
26092                         maybeBind(node.right);
26093                         break;
26094                     }
26095                     case 4: {
26096                         var operator = node.operatorToken.kind;
26097                         if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) {
26098                             bindAssignmentTargetFlow(node.left);
26099                             if (operator === 62 && node.left.kind === 195) {
26100                                 var elementAccess = node.left;
26101                                 if (isNarrowableOperand(elementAccess.expression)) {
26102                                     currentFlow = createFlowMutation(256, currentFlow, node);
26103                                 }
26104                             }
26105                         }
26106                         completeNode();
26107                         break;
26108                     }
26109                     default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for bindBinaryExpressionFlow");
26110                 }
26111             }
26112             function advanceState(state, isInStrictMode, parent, subtreeFlags) {
26113                 workStacks.state[stackIndex] = state;
26114                 if (isInStrictMode !== undefined) {
26115                     workStacks.inStrictMode[stackIndex] = isInStrictMode;
26116                 }
26117                 if (parent !== undefined) {
26118                     workStacks.parent[stackIndex] = parent;
26119                 }
26120                 if (subtreeFlags !== undefined) {
26121                     workStacks.subtreeFlags[stackIndex] = subtreeFlags;
26122                 }
26123             }
26124             function completeNode() {
26125                 if (workStacks.inStrictMode[stackIndex] !== undefined) {
26126                     if (workStacks.subtreeFlags[stackIndex] === -1) {
26127                         skipTransformFlagAggregation = false;
26128                         subtreeTransformFlags |= node.transformFlags & ~getTransformFlagsSubtreeExclusions(node.kind);
26129                     }
26130                     else if (workStacks.subtreeFlags[stackIndex] !== undefined) {
26131                         subtreeTransformFlags = workStacks.subtreeFlags[stackIndex] | computeTransformFlagsForNode(node, subtreeTransformFlags);
26132                     }
26133                     inStrictMode = workStacks.inStrictMode[stackIndex];
26134                     parent = workStacks.parent[stackIndex];
26135                 }
26136                 stackIndex--;
26137             }
26138             function maybeBind(node) {
26139                 if (node && ts.isBinaryExpression(node)) {
26140                     stackIndex++;
26141                     workStacks.expr[stackIndex] = node;
26142                     workStacks.state[stackIndex] = 0;
26143                     workStacks.inStrictMode[stackIndex] = undefined;
26144                     workStacks.parent[stackIndex] = undefined;
26145                     workStacks.subtreeFlags[stackIndex] = undefined;
26146                 }
26147                 else {
26148                     bind(node);
26149                 }
26150             }
26151         }
26152         function bindDeleteExpressionFlow(node) {
26153             bindEachChild(node);
26154             if (node.expression.kind === 194) {
26155                 bindAssignmentTargetFlow(node.expression);
26156             }
26157         }
26158         function bindConditionalExpressionFlow(node) {
26159             var trueLabel = createBranchLabel();
26160             var falseLabel = createBranchLabel();
26161             var postExpressionLabel = createBranchLabel();
26162             bindCondition(node.condition, trueLabel, falseLabel);
26163             currentFlow = finishFlowLabel(trueLabel);
26164             bind(node.questionToken);
26165             bind(node.whenTrue);
26166             addAntecedent(postExpressionLabel, currentFlow);
26167             currentFlow = finishFlowLabel(falseLabel);
26168             bind(node.colonToken);
26169             bind(node.whenFalse);
26170             addAntecedent(postExpressionLabel, currentFlow);
26171             currentFlow = finishFlowLabel(postExpressionLabel);
26172         }
26173         function bindInitializedVariableFlow(node) {
26174             var name = !ts.isOmittedExpression(node) ? node.name : undefined;
26175             if (ts.isBindingPattern(name)) {
26176                 for (var _i = 0, _a = name.elements; _i < _a.length; _i++) {
26177                     var child = _a[_i];
26178                     bindInitializedVariableFlow(child);
26179                 }
26180             }
26181             else {
26182                 currentFlow = createFlowMutation(16, currentFlow, node);
26183             }
26184         }
26185         function bindVariableDeclarationFlow(node) {
26186             bindEachChild(node);
26187             if (node.initializer || ts.isForInOrOfStatement(node.parent.parent)) {
26188                 bindInitializedVariableFlow(node);
26189             }
26190         }
26191         function bindJSDocTypeAlias(node) {
26192             node.tagName.parent = node;
26193             if (node.kind !== 316 && node.fullName) {
26194                 setParentPointers(node, node.fullName);
26195             }
26196         }
26197         function bindJSDocClassTag(node) {
26198             bindEachChild(node);
26199             var host = ts.getHostSignatureFromJSDoc(node);
26200             if (host && host.kind !== 161) {
26201                 addDeclarationToSymbol(host.symbol, host, 32);
26202             }
26203         }
26204         function bindOptionalExpression(node, trueTarget, falseTarget) {
26205             doWithConditionalBranches(bind, node, trueTarget, falseTarget);
26206             if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) {
26207                 addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node));
26208                 addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node));
26209             }
26210         }
26211         function bindOptionalChainRest(node) {
26212             switch (node.kind) {
26213                 case 194:
26214                     bind(node.questionDotToken);
26215                     bind(node.name);
26216                     break;
26217                 case 195:
26218                     bind(node.questionDotToken);
26219                     bind(node.argumentExpression);
26220                     break;
26221                 case 196:
26222                     bind(node.questionDotToken);
26223                     bindEach(node.typeArguments);
26224                     bindEach(node.arguments);
26225                     break;
26226             }
26227         }
26228         function bindOptionalChain(node, trueTarget, falseTarget) {
26229             var preChainLabel = ts.isOptionalChainRoot(node) ? createBranchLabel() : undefined;
26230             bindOptionalExpression(node.expression, preChainLabel || trueTarget, falseTarget);
26231             if (preChainLabel) {
26232                 currentFlow = finishFlowLabel(preChainLabel);
26233             }
26234             doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget);
26235             if (ts.isOutermostOptionalChain(node)) {
26236                 addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node));
26237                 addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node));
26238             }
26239         }
26240         function bindOptionalChainFlow(node) {
26241             if (isTopLevelLogicalExpression(node)) {
26242                 var postExpressionLabel = createBranchLabel();
26243                 bindOptionalChain(node, postExpressionLabel, postExpressionLabel);
26244                 currentFlow = finishFlowLabel(postExpressionLabel);
26245             }
26246             else {
26247                 bindOptionalChain(node, currentTrueTarget, currentFalseTarget);
26248             }
26249         }
26250         function bindNonNullExpressionFlow(node) {
26251             if (ts.isOptionalChain(node)) {
26252                 bindOptionalChainFlow(node);
26253             }
26254             else {
26255                 bindEachChild(node);
26256             }
26257         }
26258         function bindAccessExpressionFlow(node) {
26259             if (ts.isOptionalChain(node)) {
26260                 bindOptionalChainFlow(node);
26261             }
26262             else {
26263                 bindEachChild(node);
26264             }
26265         }
26266         function bindCallExpressionFlow(node) {
26267             if (ts.isOptionalChain(node)) {
26268                 bindOptionalChainFlow(node);
26269             }
26270             else {
26271                 var expr = ts.skipParentheses(node.expression);
26272                 if (expr.kind === 201 || expr.kind === 202) {
26273                     bindEach(node.typeArguments);
26274                     bindEach(node.arguments);
26275                     bind(node.expression);
26276                 }
26277                 else {
26278                     bindEachChild(node);
26279                 }
26280             }
26281             if (node.expression.kind === 194) {
26282                 var propertyAccess = node.expression;
26283                 if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) {
26284                     currentFlow = createFlowMutation(256, currentFlow, node);
26285                 }
26286             }
26287         }
26288         function getContainerFlags(node) {
26289             switch (node.kind) {
26290                 case 214:
26291                 case 245:
26292                 case 248:
26293                 case 193:
26294                 case 173:
26295                 case 304:
26296                 case 274:
26297                     return 1;
26298                 case 246:
26299                     return 1 | 64;
26300                 case 249:
26301                 case 247:
26302                 case 186:
26303                     return 1 | 32;
26304                 case 290:
26305                     return 1 | 4 | 32;
26306                 case 161:
26307                     if (ts.isObjectLiteralOrClassExpressionMethod(node)) {
26308                         return 1 | 4 | 32 | 8 | 128;
26309                     }
26310                 case 162:
26311                 case 244:
26312                 case 160:
26313                 case 163:
26314                 case 164:
26315                 case 165:
26316                 case 305:
26317                 case 300:
26318                 case 170:
26319                 case 166:
26320                 case 167:
26321                 case 171:
26322                     return 1 | 4 | 32 | 8;
26323                 case 201:
26324                 case 202:
26325                     return 1 | 4 | 32 | 8 | 16;
26326                 case 250:
26327                     return 4;
26328                 case 159:
26329                     return node.initializer ? 4 : 0;
26330                 case 280:
26331                 case 230:
26332                 case 231:
26333                 case 232:
26334                 case 251:
26335                     return 2;
26336                 case 223:
26337                     return ts.isFunctionLike(node.parent) ? 0 : 2;
26338             }
26339             return 0;
26340         }
26341         function addToContainerChain(next) {
26342             if (lastContainer) {
26343                 lastContainer.nextContainer = next;
26344             }
26345             lastContainer = next;
26346         }
26347         function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) {
26348             switch (container.kind) {
26349                 case 249:
26350                     return declareModuleMember(node, symbolFlags, symbolExcludes);
26351                 case 290:
26352                     return declareSourceFileMember(node, symbolFlags, symbolExcludes);
26353                 case 214:
26354                 case 245:
26355                     return declareClassMember(node, symbolFlags, symbolExcludes);
26356                 case 248:
26357                     return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
26358                 case 173:
26359                 case 304:
26360                 case 193:
26361                 case 246:
26362                 case 274:
26363                     return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes);
26364                 case 170:
26365                 case 171:
26366                 case 165:
26367                 case 166:
26368                 case 305:
26369                 case 167:
26370                 case 161:
26371                 case 160:
26372                 case 162:
26373                 case 163:
26374                 case 164:
26375                 case 244:
26376                 case 201:
26377                 case 202:
26378                 case 300:
26379                 case 322:
26380                 case 315:
26381                 case 247:
26382                 case 186:
26383                     return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
26384             }
26385         }
26386         function declareClassMember(node, symbolFlags, symbolExcludes) {
26387             return ts.hasModifier(node, 32)
26388                 ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes)
26389                 : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes);
26390         }
26391         function declareSourceFileMember(node, symbolFlags, symbolExcludes) {
26392             return ts.isExternalModule(file)
26393                 ? declareModuleMember(node, symbolFlags, symbolExcludes)
26394                 : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes);
26395         }
26396         function hasExportDeclarations(node) {
26397             var body = ts.isSourceFile(node) ? node : ts.tryCast(node.body, ts.isModuleBlock);
26398             return !!body && body.statements.some(function (s) { return ts.isExportDeclaration(s) || ts.isExportAssignment(s); });
26399         }
26400         function setExportContextFlag(node) {
26401             if (node.flags & 8388608 && !hasExportDeclarations(node)) {
26402                 node.flags |= 64;
26403             }
26404             else {
26405                 node.flags &= ~64;
26406             }
26407         }
26408         function bindModuleDeclaration(node) {
26409             setExportContextFlag(node);
26410             if (ts.isAmbientModule(node)) {
26411                 if (ts.hasModifier(node, 1)) {
26412                     errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible);
26413                 }
26414                 if (ts.isModuleAugmentationExternal(node)) {
26415                     declareModuleSymbol(node);
26416                 }
26417                 else {
26418                     var pattern = void 0;
26419                     if (node.name.kind === 10) {
26420                         var text = node.name.text;
26421                         if (ts.hasZeroOrOneAsteriskCharacter(text)) {
26422                             pattern = ts.tryParsePattern(text);
26423                         }
26424                         else {
26425                             errorOnFirstToken(node.name, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, text);
26426                         }
26427                     }
26428                     var symbol = declareSymbolAndAddToSymbolTable(node, 512, 110735);
26429                     file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && { pattern: pattern, symbol: symbol });
26430                 }
26431             }
26432             else {
26433                 var state = declareModuleSymbol(node);
26434                 if (state !== 0) {
26435                     var symbol = node.symbol;
26436                     symbol.constEnumOnlyModule = (!(symbol.flags & (16 | 32 | 256)))
26437                         && state === 2
26438                         && symbol.constEnumOnlyModule !== false;
26439                 }
26440             }
26441         }
26442         function declareModuleSymbol(node) {
26443             var state = getModuleInstanceState(node);
26444             var instantiated = state !== 0;
26445             declareSymbolAndAddToSymbolTable(node, instantiated ? 512 : 1024, instantiated ? 110735 : 0);
26446             return state;
26447         }
26448         function bindFunctionOrConstructorType(node) {
26449             var symbol = createSymbol(131072, getDeclarationName(node));
26450             addDeclarationToSymbol(symbol, node, 131072);
26451             var typeLiteralSymbol = createSymbol(2048, "__type");
26452             addDeclarationToSymbol(typeLiteralSymbol, node, 2048);
26453             typeLiteralSymbol.members = ts.createSymbolTable();
26454             typeLiteralSymbol.members.set(symbol.escapedName, symbol);
26455         }
26456         function bindObjectLiteralExpression(node) {
26457             if (inStrictMode && !ts.isAssignmentTarget(node)) {
26458                 var seen = ts.createUnderscoreEscapedMap();
26459                 for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
26460                     var prop = _a[_i];
26461                     if (prop.kind === 283 || prop.name.kind !== 75) {
26462                         continue;
26463                     }
26464                     var identifier = prop.name;
26465                     var currentKind = prop.kind === 281 || prop.kind === 282 || prop.kind === 161
26466                         ? 1
26467                         : 2;
26468                     var existingKind = seen.get(identifier.escapedText);
26469                     if (!existingKind) {
26470                         seen.set(identifier.escapedText, currentKind);
26471                         continue;
26472                     }
26473                     if (currentKind === 1 && existingKind === 1) {
26474                         var span = ts.getErrorSpanForNode(file, identifier);
26475                         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));
26476                     }
26477                 }
26478             }
26479             return bindAnonymousDeclaration(node, 4096, "__object");
26480         }
26481         function bindJsxAttributes(node) {
26482             return bindAnonymousDeclaration(node, 4096, "__jsxAttributes");
26483         }
26484         function bindJsxAttribute(node, symbolFlags, symbolExcludes) {
26485             return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
26486         }
26487         function bindAnonymousDeclaration(node, symbolFlags, name) {
26488             var symbol = createSymbol(symbolFlags, name);
26489             if (symbolFlags & (8 | 106500)) {
26490                 symbol.parent = container.symbol;
26491             }
26492             addDeclarationToSymbol(symbol, node, symbolFlags);
26493             return symbol;
26494         }
26495         function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) {
26496             switch (blockScopeContainer.kind) {
26497                 case 249:
26498                     declareModuleMember(node, symbolFlags, symbolExcludes);
26499                     break;
26500                 case 290:
26501                     if (ts.isExternalOrCommonJsModule(container)) {
26502                         declareModuleMember(node, symbolFlags, symbolExcludes);
26503                         break;
26504                     }
26505                 default:
26506                     if (!blockScopeContainer.locals) {
26507                         blockScopeContainer.locals = ts.createSymbolTable();
26508                         addToContainerChain(blockScopeContainer);
26509                     }
26510                     declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes);
26511             }
26512         }
26513         function delayedBindJSDocTypedefTag() {
26514             if (!delayedTypeAliases) {
26515                 return;
26516             }
26517             var saveContainer = container;
26518             var saveLastContainer = lastContainer;
26519             var saveBlockScopeContainer = blockScopeContainer;
26520             var saveParent = parent;
26521             var saveCurrentFlow = currentFlow;
26522             for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) {
26523                 var typeAlias = delayedTypeAliases_1[_i];
26524                 var host = ts.getJSDocHost(typeAlias);
26525                 container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1); }) || file;
26526                 blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file;
26527                 currentFlow = initFlowNode({ flags: 2 });
26528                 parent = typeAlias;
26529                 bind(typeAlias.typeExpression);
26530                 var declName = ts.getNameOfDeclaration(typeAlias);
26531                 if ((ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName) && declName && ts.isPropertyAccessEntityNameExpression(declName.parent)) {
26532                     var isTopLevel = isTopLevelNamespaceAssignment(declName.parent);
26533                     if (isTopLevel) {
26534                         bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), false);
26535                         var oldContainer = container;
26536                         switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) {
26537                             case 1:
26538                             case 2:
26539                                 if (!ts.isExternalOrCommonJsModule(file)) {
26540                                     container = undefined;
26541                                 }
26542                                 else {
26543                                     container = file;
26544                                 }
26545                                 break;
26546                             case 4:
26547                                 container = declName.parent.expression;
26548                                 break;
26549                             case 3:
26550                                 container = declName.parent.expression.name;
26551                                 break;
26552                             case 5:
26553                                 container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file
26554                                     : ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name
26555                                         : declName.parent.expression;
26556                                 break;
26557                             case 0:
26558                                 return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration");
26559                         }
26560                         if (container) {
26561                             declareModuleMember(typeAlias, 524288, 788968);
26562                         }
26563                         container = oldContainer;
26564                     }
26565                 }
26566                 else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 75) {
26567                     parent = typeAlias.parent;
26568                     bindBlockScopedDeclaration(typeAlias, 524288, 788968);
26569                 }
26570                 else {
26571                     bind(typeAlias.fullName);
26572                 }
26573             }
26574             container = saveContainer;
26575             lastContainer = saveLastContainer;
26576             blockScopeContainer = saveBlockScopeContainer;
26577             parent = saveParent;
26578             currentFlow = saveCurrentFlow;
26579         }
26580         function checkStrictModeIdentifier(node) {
26581             if (inStrictMode &&
26582                 node.originalKeywordKind >= 113 &&
26583                 node.originalKeywordKind <= 121 &&
26584                 !ts.isIdentifierName(node) &&
26585                 !(node.flags & 8388608) &&
26586                 !(node.flags & 4194304)) {
26587                 if (!file.parseDiagnostics.length) {
26588                     file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node)));
26589                 }
26590             }
26591         }
26592         function getStrictModeIdentifierMessage(node) {
26593             if (ts.getContainingClass(node)) {
26594                 return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode;
26595             }
26596             if (file.externalModuleIndicator) {
26597                 return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode;
26598             }
26599             return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode;
26600         }
26601         function checkPrivateIdentifier(node) {
26602             if (node.escapedText === "#constructor") {
26603                 if (!file.parseDiagnostics.length) {
26604                     file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.constructor_is_a_reserved_word, ts.declarationNameToString(node)));
26605                 }
26606             }
26607         }
26608         function checkStrictModeBinaryExpression(node) {
26609             if (inStrictMode && ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) {
26610                 checkStrictModeEvalOrArguments(node, node.left);
26611             }
26612         }
26613         function checkStrictModeCatchClause(node) {
26614             if (inStrictMode && node.variableDeclaration) {
26615                 checkStrictModeEvalOrArguments(node, node.variableDeclaration.name);
26616             }
26617         }
26618         function checkStrictModeDeleteExpression(node) {
26619             if (inStrictMode && node.expression.kind === 75) {
26620                 var span = ts.getErrorSpanForNode(file, node.expression);
26621                 file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode));
26622             }
26623         }
26624         function isEvalOrArgumentsIdentifier(node) {
26625             return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments");
26626         }
26627         function checkStrictModeEvalOrArguments(contextNode, name) {
26628             if (name && name.kind === 75) {
26629                 var identifier = name;
26630                 if (isEvalOrArgumentsIdentifier(identifier)) {
26631                     var span = ts.getErrorSpanForNode(file, name);
26632                     file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), ts.idText(identifier)));
26633                 }
26634             }
26635         }
26636         function getStrictModeEvalOrArgumentsMessage(node) {
26637             if (ts.getContainingClass(node)) {
26638                 return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode;
26639             }
26640             if (file.externalModuleIndicator) {
26641                 return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode;
26642             }
26643             return ts.Diagnostics.Invalid_use_of_0_in_strict_mode;
26644         }
26645         function checkStrictModeFunctionName(node) {
26646             if (inStrictMode) {
26647                 checkStrictModeEvalOrArguments(node, node.name);
26648             }
26649         }
26650         function getStrictModeBlockScopeFunctionDeclarationMessage(node) {
26651             if (ts.getContainingClass(node)) {
26652                 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;
26653             }
26654             if (file.externalModuleIndicator) {
26655                 return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode;
26656             }
26657             return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5;
26658         }
26659         function checkStrictModeFunctionDeclaration(node) {
26660             if (languageVersion < 2) {
26661                 if (blockScopeContainer.kind !== 290 &&
26662                     blockScopeContainer.kind !== 249 &&
26663                     !ts.isFunctionLike(blockScopeContainer)) {
26664                     var errorSpan = ts.getErrorSpanForNode(file, node);
26665                     file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node)));
26666                 }
26667             }
26668         }
26669         function checkStrictModeNumericLiteral(node) {
26670             if (inStrictMode && node.numericLiteralFlags & 32) {
26671                 file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode));
26672             }
26673         }
26674         function checkStrictModePostfixUnaryExpression(node) {
26675             if (inStrictMode) {
26676                 checkStrictModeEvalOrArguments(node, node.operand);
26677             }
26678         }
26679         function checkStrictModePrefixUnaryExpression(node) {
26680             if (inStrictMode) {
26681                 if (node.operator === 45 || node.operator === 46) {
26682                     checkStrictModeEvalOrArguments(node, node.operand);
26683                 }
26684             }
26685         }
26686         function checkStrictModeWithStatement(node) {
26687             if (inStrictMode) {
26688                 errorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode);
26689             }
26690         }
26691         function checkStrictModeLabeledStatement(node) {
26692             if (inStrictMode && options.target >= 2) {
26693                 if (ts.isDeclarationStatement(node.statement) || ts.isVariableStatement(node.statement)) {
26694                     errorOnFirstToken(node.label, ts.Diagnostics.A_label_is_not_allowed_here);
26695                 }
26696             }
26697         }
26698         function errorOnFirstToken(node, message, arg0, arg1, arg2) {
26699             var span = ts.getSpanOfTokenAtPosition(file, node.pos);
26700             file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2));
26701         }
26702         function errorOrSuggestionOnNode(isError, node, message) {
26703             errorOrSuggestionOnRange(isError, node, node, message);
26704         }
26705         function errorOrSuggestionOnRange(isError, startNode, endNode, message) {
26706             addErrorOrSuggestionDiagnostic(isError, { pos: ts.getTokenPosOfNode(startNode, file), end: endNode.end }, message);
26707         }
26708         function addErrorOrSuggestionDiagnostic(isError, range, message) {
26709             var diag = ts.createFileDiagnostic(file, range.pos, range.end - range.pos, message);
26710             if (isError) {
26711                 file.bindDiagnostics.push(diag);
26712             }
26713             else {
26714                 file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion }));
26715             }
26716         }
26717         function bind(node) {
26718             if (!node) {
26719                 return;
26720             }
26721             node.parent = parent;
26722             var saveInStrictMode = inStrictMode;
26723             bindWorker(node);
26724             if (node.kind > 152) {
26725                 var saveParent = parent;
26726                 parent = node;
26727                 var containerFlags = getContainerFlags(node);
26728                 if (containerFlags === 0) {
26729                     bindChildren(node);
26730                 }
26731                 else {
26732                     bindContainer(node, containerFlags);
26733                 }
26734                 parent = saveParent;
26735             }
26736             else if (!skipTransformFlagAggregation && (node.transformFlags & 536870912) === 0) {
26737                 subtreeTransformFlags |= computeTransformFlagsForNode(node, 0);
26738                 var saveParent = parent;
26739                 if (node.kind === 1)
26740                     parent = node;
26741                 bindJSDoc(node);
26742                 parent = saveParent;
26743             }
26744             inStrictMode = saveInStrictMode;
26745         }
26746         function bindJSDoc(node) {
26747             if (ts.hasJSDocNodes(node)) {
26748                 if (ts.isInJSFile(node)) {
26749                     for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
26750                         var j = _a[_i];
26751                         bind(j);
26752                     }
26753                 }
26754                 else {
26755                     for (var _b = 0, _c = node.jsDoc; _b < _c.length; _b++) {
26756                         var j = _c[_b];
26757                         setParentPointers(node, j);
26758                     }
26759                 }
26760             }
26761         }
26762         function updateStrictModeStatementList(statements) {
26763             if (!inStrictMode) {
26764                 for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) {
26765                     var statement = statements_2[_i];
26766                     if (!ts.isPrologueDirective(statement)) {
26767                         return;
26768                     }
26769                     if (isUseStrictPrologueDirective(statement)) {
26770                         inStrictMode = true;
26771                         return;
26772                     }
26773                 }
26774             }
26775         }
26776         function isUseStrictPrologueDirective(node) {
26777             var nodeText = ts.getSourceTextOfNodeFromSourceFile(file, node.expression);
26778             return nodeText === '"use strict"' || nodeText === "'use strict'";
26779         }
26780         function bindWorker(node) {
26781             switch (node.kind) {
26782                 case 75:
26783                     if (node.isInJSDocNamespace) {
26784                         var parentNode = node.parent;
26785                         while (parentNode && !ts.isJSDocTypeAlias(parentNode)) {
26786                             parentNode = parentNode.parent;
26787                         }
26788                         bindBlockScopedDeclaration(parentNode, 524288, 788968);
26789                         break;
26790                     }
26791                 case 104:
26792                     if (currentFlow && (ts.isExpression(node) || parent.kind === 282)) {
26793                         node.flowNode = currentFlow;
26794                     }
26795                     return checkStrictModeIdentifier(node);
26796                 case 76:
26797                     return checkPrivateIdentifier(node);
26798                 case 194:
26799                 case 195:
26800                     var expr = node;
26801                     if (currentFlow && isNarrowableReference(expr)) {
26802                         expr.flowNode = currentFlow;
26803                     }
26804                     if (ts.isSpecialPropertyDeclaration(expr)) {
26805                         bindSpecialPropertyDeclaration(expr);
26806                     }
26807                     if (ts.isInJSFile(expr) &&
26808                         file.commonJsModuleIndicator &&
26809                         ts.isModuleExportsAccessExpression(expr) &&
26810                         !lookupSymbolForNameWorker(blockScopeContainer, "module")) {
26811                         declareSymbol(file.locals, undefined, expr.expression, 1 | 134217728, 111550);
26812                     }
26813                     break;
26814                 case 209:
26815                     var specialKind = ts.getAssignmentDeclarationKind(node);
26816                     switch (specialKind) {
26817                         case 1:
26818                             bindExportsPropertyAssignment(node);
26819                             break;
26820                         case 2:
26821                             bindModuleExportsAssignment(node);
26822                             break;
26823                         case 3:
26824                             bindPrototypePropertyAssignment(node.left, node);
26825                             break;
26826                         case 6:
26827                             bindPrototypeAssignment(node);
26828                             break;
26829                         case 4:
26830                             bindThisPropertyAssignment(node);
26831                             break;
26832                         case 5:
26833                             bindSpecialPropertyAssignment(node);
26834                             break;
26835                         case 0:
26836                             break;
26837                         default:
26838                             ts.Debug.fail("Unknown binary expression special property assignment kind");
26839                     }
26840                     return checkStrictModeBinaryExpression(node);
26841                 case 280:
26842                     return checkStrictModeCatchClause(node);
26843                 case 203:
26844                     return checkStrictModeDeleteExpression(node);
26845                 case 8:
26846                     return checkStrictModeNumericLiteral(node);
26847                 case 208:
26848                     return checkStrictModePostfixUnaryExpression(node);
26849                 case 207:
26850                     return checkStrictModePrefixUnaryExpression(node);
26851                 case 236:
26852                     return checkStrictModeWithStatement(node);
26853                 case 238:
26854                     return checkStrictModeLabeledStatement(node);
26855                 case 183:
26856                     seenThisKeyword = true;
26857                     return;
26858                 case 168:
26859                     break;
26860                 case 155:
26861                     return bindTypeParameter(node);
26862                 case 156:
26863                     return bindParameter(node);
26864                 case 242:
26865                     return bindVariableDeclarationOrBindingElement(node);
26866                 case 191:
26867                     node.flowNode = currentFlow;
26868                     return bindVariableDeclarationOrBindingElement(node);
26869                 case 159:
26870                 case 158:
26871                     return bindPropertyWorker(node);
26872                 case 281:
26873                 case 282:
26874                     return bindPropertyOrMethodOrAccessor(node, 4, 0);
26875                 case 284:
26876                     return bindPropertyOrMethodOrAccessor(node, 8, 900095);
26877                 case 165:
26878                 case 166:
26879                 case 167:
26880                     return declareSymbolAndAddToSymbolTable(node, 131072, 0);
26881                 case 161:
26882                 case 160:
26883                     return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 16777216 : 0), ts.isObjectLiteralMethod(node) ? 0 : 103359);
26884                 case 244:
26885                     return bindFunctionDeclaration(node);
26886                 case 162:
26887                     return declareSymbolAndAddToSymbolTable(node, 16384, 0);
26888                 case 163:
26889                     return bindPropertyOrMethodOrAccessor(node, 32768, 46015);
26890                 case 164:
26891                     return bindPropertyOrMethodOrAccessor(node, 65536, 78783);
26892                 case 170:
26893                 case 300:
26894                 case 305:
26895                 case 171:
26896                     return bindFunctionOrConstructorType(node);
26897                 case 173:
26898                 case 304:
26899                 case 186:
26900                     return bindAnonymousTypeWorker(node);
26901                 case 310:
26902                     return bindJSDocClassTag(node);
26903                 case 193:
26904                     return bindObjectLiteralExpression(node);
26905                 case 201:
26906                 case 202:
26907                     return bindFunctionExpression(node);
26908                 case 196:
26909                     var assignmentKind = ts.getAssignmentDeclarationKind(node);
26910                     switch (assignmentKind) {
26911                         case 7:
26912                             return bindObjectDefinePropertyAssignment(node);
26913                         case 8:
26914                             return bindObjectDefinePropertyExport(node);
26915                         case 9:
26916                             return bindObjectDefinePrototypeProperty(node);
26917                         case 0:
26918                             break;
26919                         default:
26920                             return ts.Debug.fail("Unknown call expression assignment declaration kind");
26921                     }
26922                     if (ts.isInJSFile(node)) {
26923                         bindCallExpression(node);
26924                     }
26925                     break;
26926                 case 214:
26927                 case 245:
26928                     inStrictMode = true;
26929                     return bindClassLikeDeclaration(node);
26930                 case 246:
26931                     return bindBlockScopedDeclaration(node, 64, 788872);
26932                 case 247:
26933                     return bindBlockScopedDeclaration(node, 524288, 788968);
26934                 case 248:
26935                     return bindEnumDeclaration(node);
26936                 case 249:
26937                     return bindModuleDeclaration(node);
26938                 case 274:
26939                     return bindJsxAttributes(node);
26940                 case 273:
26941                     return bindJsxAttribute(node, 4, 0);
26942                 case 253:
26943                 case 256:
26944                 case 258:
26945                 case 263:
26946                     return declareSymbolAndAddToSymbolTable(node, 2097152, 2097152);
26947                 case 252:
26948                     return bindNamespaceExportDeclaration(node);
26949                 case 255:
26950                     return bindImportClause(node);
26951                 case 260:
26952                     return bindExportDeclaration(node);
26953                 case 259:
26954                     return bindExportAssignment(node);
26955                 case 290:
26956                     updateStrictModeStatementList(node.statements);
26957                     return bindSourceFileIfExternalModule();
26958                 case 223:
26959                     if (!ts.isFunctionLike(node.parent)) {
26960                         return;
26961                     }
26962                 case 250:
26963                     return updateStrictModeStatementList(node.statements);
26964                 case 317:
26965                     if (node.parent.kind === 305) {
26966                         return bindParameter(node);
26967                     }
26968                     if (node.parent.kind !== 304) {
26969                         break;
26970                     }
26971                 case 323:
26972                     var propTag = node;
26973                     var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 299 ?
26974                         4 | 16777216 :
26975                         4;
26976                     return declareSymbolAndAddToSymbolTable(propTag, flags, 0);
26977                 case 322:
26978                 case 315:
26979                 case 316:
26980                     return (delayedTypeAliases || (delayedTypeAliases = [])).push(node);
26981             }
26982         }
26983         function bindPropertyWorker(node) {
26984             return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 16777216 : 0), 0);
26985         }
26986         function bindAnonymousTypeWorker(node) {
26987             return bindAnonymousDeclaration(node, 2048, "__type");
26988         }
26989         function bindSourceFileIfExternalModule() {
26990             setExportContextFlag(file);
26991             if (ts.isExternalModule(file)) {
26992                 bindSourceFileAsExternalModule();
26993             }
26994             else if (ts.isJsonSourceFile(file)) {
26995                 bindSourceFileAsExternalModule();
26996                 var originalSymbol = file.symbol;
26997                 declareSymbol(file.symbol.exports, file.symbol, file, 4, 67108863);
26998                 file.symbol = originalSymbol;
26999             }
27000         }
27001         function bindSourceFileAsExternalModule() {
27002             bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\"");
27003         }
27004         function bindExportAssignment(node) {
27005             if (!container.symbol || !container.symbol.exports) {
27006                 bindAnonymousDeclaration(node, 2097152, getDeclarationName(node));
27007             }
27008             else {
27009                 var flags = ts.exportAssignmentIsAlias(node)
27010                     ? 2097152
27011                     : 4;
27012                 var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863);
27013                 if (node.isExportEquals) {
27014                     ts.setValueDeclaration(symbol, node);
27015                 }
27016             }
27017         }
27018         function bindNamespaceExportDeclaration(node) {
27019             if (node.modifiers && node.modifiers.length) {
27020                 file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here));
27021             }
27022             var diag = !ts.isSourceFile(node.parent) ? ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level
27023                 : !ts.isExternalModule(node.parent) ? ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files
27024                     : !node.parent.isDeclarationFile ? ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files
27025                         : undefined;
27026             if (diag) {
27027                 file.bindDiagnostics.push(createDiagnosticForNode(node, diag));
27028             }
27029             else {
27030                 file.symbol.globalExports = file.symbol.globalExports || ts.createSymbolTable();
27031                 declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152, 2097152);
27032             }
27033         }
27034         function bindExportDeclaration(node) {
27035             if (!container.symbol || !container.symbol.exports) {
27036                 bindAnonymousDeclaration(node, 8388608, getDeclarationName(node));
27037             }
27038             else if (!node.exportClause) {
27039                 declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 0);
27040             }
27041             else if (ts.isNamespaceExport(node.exportClause)) {
27042                 node.exportClause.parent = node;
27043                 declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152, 2097152);
27044             }
27045         }
27046         function bindImportClause(node) {
27047             if (node.name) {
27048                 declareSymbolAndAddToSymbolTable(node, 2097152, 2097152);
27049             }
27050         }
27051         function setCommonJsModuleIndicator(node) {
27052             if (file.externalModuleIndicator) {
27053                 return false;
27054             }
27055             if (!file.commonJsModuleIndicator) {
27056                 file.commonJsModuleIndicator = node;
27057                 bindSourceFileAsExternalModule();
27058             }
27059             return true;
27060         }
27061         function bindObjectDefinePropertyExport(node) {
27062             if (!setCommonJsModuleIndicator(node)) {
27063                 return;
27064             }
27065             var symbol = forEachIdentifierInEntityName(node.arguments[0], undefined, function (id, symbol) {
27066                 if (symbol) {
27067                     addDeclarationToSymbol(symbol, id, 1536 | 67108864);
27068                 }
27069                 return symbol;
27070             });
27071             if (symbol) {
27072                 var flags = 4 | 1048576;
27073                 declareSymbol(symbol.exports, symbol, node, flags, 0);
27074             }
27075         }
27076         function bindExportsPropertyAssignment(node) {
27077             if (!setCommonJsModuleIndicator(node)) {
27078                 return;
27079             }
27080             var symbol = forEachIdentifierInEntityName(node.left.expression, undefined, function (id, symbol) {
27081                 if (symbol) {
27082                     addDeclarationToSymbol(symbol, id, 1536 | 67108864);
27083                 }
27084                 return symbol;
27085             });
27086             if (symbol) {
27087                 var flags = ts.isClassExpression(node.right) ?
27088                     4 | 1048576 | 32 :
27089                     4 | 1048576;
27090                 declareSymbol(symbol.exports, symbol, node.left, flags, 0);
27091             }
27092         }
27093         function bindModuleExportsAssignment(node) {
27094             if (!setCommonJsModuleIndicator(node)) {
27095                 return;
27096             }
27097             var assignedExpression = ts.getRightMostAssignedExpression(node.right);
27098             if (ts.isEmptyObjectLiteral(assignedExpression) || container === file && isExportsOrModuleExportsOrAlias(file, assignedExpression)) {
27099                 return;
27100             }
27101             var flags = ts.exportAssignmentIsAlias(node)
27102                 ? 2097152
27103                 : 4 | 1048576 | 512;
27104             var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864, 0);
27105             ts.setValueDeclaration(symbol, node);
27106         }
27107         function bindThisPropertyAssignment(node) {
27108             ts.Debug.assert(ts.isInJSFile(node));
27109             var hasPrivateIdentifier = (ts.isBinaryExpression(node) && ts.isPropertyAccessExpression(node.left) && ts.isPrivateIdentifier(node.left.name))
27110                 || (ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name));
27111             if (hasPrivateIdentifier) {
27112                 return;
27113             }
27114             var thisContainer = ts.getThisContainer(node, false);
27115             switch (thisContainer.kind) {
27116                 case 244:
27117                 case 201:
27118                     var constructorSymbol = thisContainer.symbol;
27119                     if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 62) {
27120                         var l = thisContainer.parent.left;
27121                         if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) {
27122                             constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer);
27123                         }
27124                     }
27125                     if (constructorSymbol && constructorSymbol.valueDeclaration) {
27126                         constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable();
27127                         if (ts.hasDynamicName(node)) {
27128                             bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol);
27129                         }
27130                         else {
27131                             declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 | 67108864, 0 & ~4);
27132                         }
27133                         addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32);
27134                     }
27135                     break;
27136                 case 162:
27137                 case 159:
27138                 case 161:
27139                 case 163:
27140                 case 164:
27141                     var containingClass = thisContainer.parent;
27142                     var symbolTable = ts.hasModifier(thisContainer, 32) ? containingClass.symbol.exports : containingClass.symbol.members;
27143                     if (ts.hasDynamicName(node)) {
27144                         bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol);
27145                     }
27146                     else {
27147                         declareSymbol(symbolTable, containingClass.symbol, node, 4 | 67108864, 0, true);
27148                     }
27149                     break;
27150                 case 290:
27151                     if (ts.hasDynamicName(node)) {
27152                         break;
27153                     }
27154                     else if (thisContainer.commonJsModuleIndicator) {
27155                         declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 | 1048576, 0);
27156                     }
27157                     else {
27158                         declareSymbolAndAddToSymbolTable(node, 1, 111550);
27159                     }
27160                     break;
27161                 default:
27162                     ts.Debug.failBadSyntaxKind(thisContainer);
27163             }
27164         }
27165         function bindDynamicallyNamedThisPropertyAssignment(node, symbol) {
27166             bindAnonymousDeclaration(node, 4, "__computed");
27167             addLateBoundAssignmentDeclarationToSymbol(node, symbol);
27168         }
27169         function addLateBoundAssignmentDeclarationToSymbol(node, symbol) {
27170             if (symbol) {
27171                 var members = symbol.assignmentDeclarationMembers || (symbol.assignmentDeclarationMembers = ts.createMap());
27172                 members.set("" + ts.getNodeId(node), node);
27173             }
27174         }
27175         function bindSpecialPropertyDeclaration(node) {
27176             if (node.expression.kind === 104) {
27177                 bindThisPropertyAssignment(node);
27178             }
27179             else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 290) {
27180                 if (ts.isPrototypeAccess(node.expression)) {
27181                     bindPrototypePropertyAssignment(node, node.parent);
27182                 }
27183                 else {
27184                     bindStaticPropertyAssignment(node);
27185                 }
27186             }
27187         }
27188         function bindPrototypeAssignment(node) {
27189             node.left.parent = node;
27190             node.right.parent = node;
27191             bindPropertyAssignment(node.left.expression, node.left, false, true);
27192         }
27193         function bindObjectDefinePrototypeProperty(node) {
27194             var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression);
27195             if (namespaceSymbol && namespaceSymbol.valueDeclaration) {
27196                 addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32);
27197             }
27198             bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, true);
27199         }
27200         function bindPrototypePropertyAssignment(lhs, parent) {
27201             var classPrototype = lhs.expression;
27202             var constructorFunction = classPrototype.expression;
27203             lhs.parent = parent;
27204             constructorFunction.parent = classPrototype;
27205             classPrototype.parent = lhs;
27206             bindPropertyAssignment(constructorFunction, lhs, true, true);
27207         }
27208         function bindObjectDefinePropertyAssignment(node) {
27209             var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]);
27210             var isToplevel = node.parent.parent.kind === 290;
27211             namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, false, false);
27212             bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, false);
27213         }
27214         function bindSpecialPropertyAssignment(node) {
27215             var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression);
27216             if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) {
27217                 return;
27218             }
27219             node.left.parent = node;
27220             node.right.parent = node;
27221             if (ts.isIdentifier(node.left.expression) && container === file && isExportsOrModuleExportsOrAlias(file, node.left.expression)) {
27222                 bindExportsPropertyAssignment(node);
27223             }
27224             else if (ts.hasDynamicName(node)) {
27225                 bindAnonymousDeclaration(node, 4 | 67108864, "__computed");
27226                 var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), false, false);
27227                 addLateBoundAssignmentDeclarationToSymbol(node, sym);
27228             }
27229             else {
27230                 bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticNameExpression));
27231             }
27232         }
27233         function bindStaticPropertyAssignment(node) {
27234             ts.Debug.assert(!ts.isIdentifier(node));
27235             node.expression.parent = node;
27236             bindPropertyAssignment(node.expression, node, false, false);
27237         }
27238         function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) {
27239             if (isToplevel && !isPrototypeProperty) {
27240                 var flags_1 = 1536 | 67108864;
27241                 var excludeFlags_1 = 110735 & ~67108864;
27242                 namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) {
27243                     if (symbol) {
27244                         addDeclarationToSymbol(symbol, id, flags_1);
27245                         return symbol;
27246                     }
27247                     else {
27248                         var table = parent ? parent.exports :
27249                             file.jsGlobalAugmentations || (file.jsGlobalAugmentations = ts.createSymbolTable());
27250                         return declareSymbol(table, parent, id, flags_1, excludeFlags_1);
27251                     }
27252                 });
27253             }
27254             if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) {
27255                 addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32);
27256             }
27257             return namespaceSymbol;
27258         }
27259         function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) {
27260             if (!namespaceSymbol || !isExpandoSymbol(namespaceSymbol)) {
27261                 return;
27262             }
27263             var symbolTable = isPrototypeProperty ?
27264                 (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) :
27265                 (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable()));
27266             var includes = 0;
27267             var excludes = 0;
27268             if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) {
27269                 includes = 8192;
27270                 excludes = 103359;
27271             }
27272             else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) {
27273                 if (ts.some(declaration.arguments[2].properties, function (p) {
27274                     var id = ts.getNameOfDeclaration(p);
27275                     return !!id && ts.isIdentifier(id) && ts.idText(id) === "set";
27276                 })) {
27277                     includes |= 65536 | 4;
27278                     excludes |= 78783;
27279                 }
27280                 if (ts.some(declaration.arguments[2].properties, function (p) {
27281                     var id = ts.getNameOfDeclaration(p);
27282                     return !!id && ts.isIdentifier(id) && ts.idText(id) === "get";
27283                 })) {
27284                     includes |= 32768 | 4;
27285                     excludes |= 46015;
27286                 }
27287             }
27288             if (includes === 0) {
27289                 includes = 4;
27290                 excludes = 0;
27291             }
27292             declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864, excludes & ~67108864);
27293         }
27294         function isTopLevelNamespaceAssignment(propertyAccess) {
27295             return ts.isBinaryExpression(propertyAccess.parent)
27296                 ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 290
27297                 : propertyAccess.parent.parent.kind === 290;
27298         }
27299         function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) {
27300             var namespaceSymbol = lookupSymbolForPropertyAccess(name);
27301             var isToplevel = isTopLevelNamespaceAssignment(propertyAccess);
27302             namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass);
27303             bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty);
27304         }
27305         function isExpandoSymbol(symbol) {
27306             if (symbol.flags & (16 | 32 | 1024)) {
27307                 return true;
27308             }
27309             var node = symbol.valueDeclaration;
27310             if (node && ts.isCallExpression(node)) {
27311                 return !!ts.getAssignedExpandoInitializer(node);
27312             }
27313             var init = !node ? undefined :
27314                 ts.isVariableDeclaration(node) ? node.initializer :
27315                     ts.isBinaryExpression(node) ? node.right :
27316                         ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) ? node.parent.right :
27317                             undefined;
27318             init = init && ts.getRightMostAssignedExpression(init);
27319             if (init) {
27320                 var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node);
27321                 return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 || init.operatorToken.kind === 60) ? init.right : init, isPrototypeAssignment);
27322             }
27323             return false;
27324         }
27325         function getParentOfBinaryExpression(expr) {
27326             while (ts.isBinaryExpression(expr.parent)) {
27327                 expr = expr.parent;
27328             }
27329             return expr.parent;
27330         }
27331         function lookupSymbolForPropertyAccess(node, lookupContainer) {
27332             if (lookupContainer === void 0) { lookupContainer = container; }
27333             if (ts.isIdentifier(node)) {
27334                 return lookupSymbolForNameWorker(lookupContainer, node.escapedText);
27335             }
27336             else {
27337                 var symbol = lookupSymbolForPropertyAccess(node.expression);
27338                 return symbol && symbol.exports && symbol.exports.get(ts.getElementOrPropertyAccessName(node));
27339             }
27340         }
27341         function forEachIdentifierInEntityName(e, parent, action) {
27342             if (isExportsOrModuleExportsOrAlias(file, e)) {
27343                 return file.symbol;
27344             }
27345             else if (ts.isIdentifier(e)) {
27346                 return action(e, lookupSymbolForPropertyAccess(e), parent);
27347             }
27348             else {
27349                 var s = forEachIdentifierInEntityName(e.expression, parent, action);
27350                 var name = ts.getNameOrArgument(e);
27351                 if (ts.isPrivateIdentifier(name)) {
27352                     ts.Debug.fail("unexpected PrivateIdentifier");
27353                 }
27354                 return action(name, s && s.exports && s.exports.get(ts.getElementOrPropertyAccessName(e)), s);
27355             }
27356         }
27357         function bindCallExpression(node) {
27358             if (!file.commonJsModuleIndicator && ts.isRequireCall(node, false)) {
27359                 setCommonJsModuleIndicator(node);
27360             }
27361         }
27362         function bindClassLikeDeclaration(node) {
27363             if (node.kind === 245) {
27364                 bindBlockScopedDeclaration(node, 32, 899503);
27365             }
27366             else {
27367                 var bindingName = node.name ? node.name.escapedText : "__class";
27368                 bindAnonymousDeclaration(node, 32, bindingName);
27369                 if (node.name) {
27370                     classifiableNames.set(node.name.escapedText, true);
27371                 }
27372             }
27373             var symbol = node.symbol;
27374             var prototypeSymbol = createSymbol(4 | 4194304, "prototype");
27375             var symbolExport = symbol.exports.get(prototypeSymbol.escapedName);
27376             if (symbolExport) {
27377                 if (node.name) {
27378                     node.name.parent = node;
27379                 }
27380                 file.bindDiagnostics.push(createDiagnosticForNode(symbolExport.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(prototypeSymbol)));
27381             }
27382             symbol.exports.set(prototypeSymbol.escapedName, prototypeSymbol);
27383             prototypeSymbol.parent = symbol;
27384         }
27385         function bindEnumDeclaration(node) {
27386             return ts.isEnumConst(node)
27387                 ? bindBlockScopedDeclaration(node, 128, 899967)
27388                 : bindBlockScopedDeclaration(node, 256, 899327);
27389         }
27390         function bindVariableDeclarationOrBindingElement(node) {
27391             if (inStrictMode) {
27392                 checkStrictModeEvalOrArguments(node, node.name);
27393             }
27394             if (!ts.isBindingPattern(node.name)) {
27395                 if (ts.isBlockOrCatchScoped(node)) {
27396                     bindBlockScopedDeclaration(node, 2, 111551);
27397                 }
27398                 else if (ts.isParameterDeclaration(node)) {
27399                     declareSymbolAndAddToSymbolTable(node, 1, 111551);
27400                 }
27401                 else {
27402                     declareSymbolAndAddToSymbolTable(node, 1, 111550);
27403                 }
27404             }
27405         }
27406         function bindParameter(node) {
27407             if (node.kind === 317 && container.kind !== 305) {
27408                 return;
27409             }
27410             if (inStrictMode && !(node.flags & 8388608)) {
27411                 checkStrictModeEvalOrArguments(node, node.name);
27412             }
27413             if (ts.isBindingPattern(node.name)) {
27414                 bindAnonymousDeclaration(node, 1, "__" + node.parent.parameters.indexOf(node));
27415             }
27416             else {
27417                 declareSymbolAndAddToSymbolTable(node, 1, 111551);
27418             }
27419             if (ts.isParameterPropertyDeclaration(node, node.parent)) {
27420                 var classDeclaration = node.parent.parent;
27421                 declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 | (node.questionToken ? 16777216 : 0), 0);
27422             }
27423         }
27424         function bindFunctionDeclaration(node) {
27425             if (!file.isDeclarationFile && !(node.flags & 8388608)) {
27426                 if (ts.isAsyncFunction(node)) {
27427                     emitFlags |= 2048;
27428                 }
27429             }
27430             checkStrictModeFunctionName(node);
27431             if (inStrictMode) {
27432                 checkStrictModeFunctionDeclaration(node);
27433                 bindBlockScopedDeclaration(node, 16, 110991);
27434             }
27435             else {
27436                 declareSymbolAndAddToSymbolTable(node, 16, 110991);
27437             }
27438         }
27439         function bindFunctionExpression(node) {
27440             if (!file.isDeclarationFile && !(node.flags & 8388608)) {
27441                 if (ts.isAsyncFunction(node)) {
27442                     emitFlags |= 2048;
27443                 }
27444             }
27445             if (currentFlow) {
27446                 node.flowNode = currentFlow;
27447             }
27448             checkStrictModeFunctionName(node);
27449             var bindingName = node.name ? node.name.escapedText : "__function";
27450             return bindAnonymousDeclaration(node, 16, bindingName);
27451         }
27452         function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) {
27453             if (!file.isDeclarationFile && !(node.flags & 8388608) && ts.isAsyncFunction(node)) {
27454                 emitFlags |= 2048;
27455             }
27456             if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) {
27457                 node.flowNode = currentFlow;
27458             }
27459             return ts.hasDynamicName(node)
27460                 ? bindAnonymousDeclaration(node, symbolFlags, "__computed")
27461                 : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
27462         }
27463         function getInferTypeContainer(node) {
27464             var extendsType = ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && n.parent.extendsType === n; });
27465             return extendsType && extendsType.parent;
27466         }
27467         function bindTypeParameter(node) {
27468             if (ts.isJSDocTemplateTag(node.parent)) {
27469                 var container_1 = ts.find(node.parent.parent.tags, ts.isJSDocTypeAlias) || ts.getHostSignatureFromJSDoc(node.parent);
27470                 if (container_1) {
27471                     if (!container_1.locals) {
27472                         container_1.locals = ts.createSymbolTable();
27473                     }
27474                     declareSymbol(container_1.locals, undefined, node, 262144, 526824);
27475                 }
27476                 else {
27477                     declareSymbolAndAddToSymbolTable(node, 262144, 526824);
27478                 }
27479             }
27480             else if (node.parent.kind === 181) {
27481                 var container_2 = getInferTypeContainer(node.parent);
27482                 if (container_2) {
27483                     if (!container_2.locals) {
27484                         container_2.locals = ts.createSymbolTable();
27485                     }
27486                     declareSymbol(container_2.locals, undefined, node, 262144, 526824);
27487                 }
27488                 else {
27489                     bindAnonymousDeclaration(node, 262144, getDeclarationName(node));
27490                 }
27491             }
27492             else {
27493                 declareSymbolAndAddToSymbolTable(node, 262144, 526824);
27494             }
27495         }
27496         function shouldReportErrorOnModuleDeclaration(node) {
27497             var instanceState = getModuleInstanceState(node);
27498             return instanceState === 1 || (instanceState === 2 && !!options.preserveConstEnums);
27499         }
27500         function checkUnreachable(node) {
27501             if (!(currentFlow.flags & 1)) {
27502                 return false;
27503             }
27504             if (currentFlow === unreachableFlow) {
27505                 var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 224) ||
27506                     node.kind === 245 ||
27507                     (node.kind === 249 && shouldReportErrorOnModuleDeclaration(node));
27508                 if (reportError) {
27509                     currentFlow = reportedUnreachableFlow;
27510                     if (!options.allowUnreachableCode) {
27511                         var isError_1 = ts.unreachableCodeIsError(options) &&
27512                             !(node.flags & 8388608) &&
27513                             (!ts.isVariableStatement(node) ||
27514                                 !!(ts.getCombinedNodeFlags(node.declarationList) & 3) ||
27515                                 node.declarationList.declarations.some(function (d) { return !!d.initializer; }));
27516                         eachUnreachableRange(node, function (start, end) { return errorOrSuggestionOnRange(isError_1, start, end, ts.Diagnostics.Unreachable_code_detected); });
27517                     }
27518                 }
27519             }
27520             return true;
27521         }
27522     }
27523     function eachUnreachableRange(node, cb) {
27524         if (ts.isStatement(node) && isExecutableStatement(node) && ts.isBlock(node.parent)) {
27525             var statements = node.parent.statements;
27526             var slice_1 = ts.sliceAfter(statements, node);
27527             ts.getRangesWhere(slice_1, isExecutableStatement, function (start, afterEnd) { return cb(slice_1[start], slice_1[afterEnd - 1]); });
27528         }
27529         else {
27530             cb(node, node);
27531         }
27532     }
27533     function isExecutableStatement(s) {
27534         return !ts.isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && !ts.isEnumDeclaration(s) &&
27535             !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 | 2)) && s.declarationList.declarations.some(function (d) { return !d.initializer; }));
27536     }
27537     function isPurelyTypeDeclaration(s) {
27538         switch (s.kind) {
27539             case 246:
27540             case 247:
27541                 return true;
27542             case 249:
27543                 return getModuleInstanceState(s) !== 1;
27544             case 248:
27545                 return ts.hasModifier(s, 2048);
27546             default:
27547                 return false;
27548         }
27549     }
27550     function isExportsOrModuleExportsOrAlias(sourceFile, node) {
27551         var i = 0;
27552         var q = [node];
27553         while (q.length && i < 100) {
27554             i++;
27555             node = q.shift();
27556             if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) {
27557                 return true;
27558             }
27559             else if (ts.isIdentifier(node)) {
27560                 var symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText);
27561                 if (!!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) {
27562                     var init = symbol.valueDeclaration.initializer;
27563                     q.push(init);
27564                     if (ts.isAssignmentExpression(init, true)) {
27565                         q.push(init.left);
27566                         q.push(init.right);
27567                     }
27568                 }
27569             }
27570         }
27571         return false;
27572     }
27573     ts.isExportsOrModuleExportsOrAlias = isExportsOrModuleExportsOrAlias;
27574     function lookupSymbolForNameWorker(container, name) {
27575         var local = container.locals && container.locals.get(name);
27576         if (local) {
27577             return local.exportSymbol || local;
27578         }
27579         if (ts.isSourceFile(container) && container.jsGlobalAugmentations && container.jsGlobalAugmentations.has(name)) {
27580             return container.jsGlobalAugmentations.get(name);
27581         }
27582         return container.symbol && container.symbol.exports && container.symbol.exports.get(name);
27583     }
27584     function computeTransformFlagsForNode(node, subtreeFlags) {
27585         var kind = node.kind;
27586         switch (kind) {
27587             case 196:
27588                 return computeCallExpression(node, subtreeFlags);
27589             case 197:
27590                 return computeNewExpression(node, subtreeFlags);
27591             case 249:
27592                 return computeModuleDeclaration(node, subtreeFlags);
27593             case 200:
27594                 return computeParenthesizedExpression(node, subtreeFlags);
27595             case 209:
27596                 return computeBinaryExpression(node, subtreeFlags);
27597             case 226:
27598                 return computeExpressionStatement(node, subtreeFlags);
27599             case 156:
27600                 return computeParameter(node, subtreeFlags);
27601             case 202:
27602                 return computeArrowFunction(node, subtreeFlags);
27603             case 201:
27604                 return computeFunctionExpression(node, subtreeFlags);
27605             case 244:
27606                 return computeFunctionDeclaration(node, subtreeFlags);
27607             case 242:
27608                 return computeVariableDeclaration(node, subtreeFlags);
27609             case 243:
27610                 return computeVariableDeclarationList(node, subtreeFlags);
27611             case 225:
27612                 return computeVariableStatement(node, subtreeFlags);
27613             case 238:
27614                 return computeLabeledStatement(node, subtreeFlags);
27615             case 245:
27616                 return computeClassDeclaration(node, subtreeFlags);
27617             case 214:
27618                 return computeClassExpression(node, subtreeFlags);
27619             case 279:
27620                 return computeHeritageClause(node, subtreeFlags);
27621             case 280:
27622                 return computeCatchClause(node, subtreeFlags);
27623             case 216:
27624                 return computeExpressionWithTypeArguments(node, subtreeFlags);
27625             case 162:
27626                 return computeConstructor(node, subtreeFlags);
27627             case 159:
27628                 return computePropertyDeclaration(node, subtreeFlags);
27629             case 161:
27630                 return computeMethod(node, subtreeFlags);
27631             case 163:
27632             case 164:
27633                 return computeAccessor(node, subtreeFlags);
27634             case 253:
27635                 return computeImportEquals(node, subtreeFlags);
27636             case 194:
27637                 return computePropertyAccess(node, subtreeFlags);
27638             case 195:
27639                 return computeElementAccess(node, subtreeFlags);
27640             case 267:
27641             case 268:
27642                 return computeJsxOpeningLikeElement(node, subtreeFlags);
27643             default:
27644                 return computeOther(node, kind, subtreeFlags);
27645         }
27646     }
27647     ts.computeTransformFlagsForNode = computeTransformFlagsForNode;
27648     function computeCallExpression(node, subtreeFlags) {
27649         var transformFlags = subtreeFlags;
27650         var callee = ts.skipOuterExpressions(node.expression);
27651         var expression = node.expression;
27652         if (node.flags & 32) {
27653             transformFlags |= 8;
27654         }
27655         if (node.typeArguments) {
27656             transformFlags |= 1;
27657         }
27658         if (subtreeFlags & 8192 || ts.isSuperOrSuperProperty(callee)) {
27659             transformFlags |= 256;
27660             if (ts.isSuperProperty(callee)) {
27661                 transformFlags |= 4096;
27662             }
27663         }
27664         if (expression.kind === 96) {
27665             transformFlags |= 2097152;
27666         }
27667         node.transformFlags = transformFlags | 536870912;
27668         return transformFlags & ~536879104;
27669     }
27670     function computeNewExpression(node, subtreeFlags) {
27671         var transformFlags = subtreeFlags;
27672         if (node.typeArguments) {
27673             transformFlags |= 1;
27674         }
27675         if (subtreeFlags & 8192) {
27676             transformFlags |= 256;
27677         }
27678         node.transformFlags = transformFlags | 536870912;
27679         return transformFlags & ~536879104;
27680     }
27681     function computeJsxOpeningLikeElement(node, subtreeFlags) {
27682         var transformFlags = subtreeFlags | 2;
27683         if (node.typeArguments) {
27684             transformFlags |= 1;
27685         }
27686         node.transformFlags = transformFlags | 536870912;
27687         return transformFlags & ~536870912;
27688     }
27689     function computeBinaryExpression(node, subtreeFlags) {
27690         var transformFlags = subtreeFlags;
27691         var operatorTokenKind = node.operatorToken.kind;
27692         var leftKind = node.left.kind;
27693         if (operatorTokenKind === 60) {
27694             transformFlags |= 8;
27695         }
27696         else if (operatorTokenKind === 62 && leftKind === 193) {
27697             transformFlags |= 32 | 256 | 1024;
27698         }
27699         else if (operatorTokenKind === 62 && leftKind === 192) {
27700             transformFlags |= 256 | 1024;
27701         }
27702         else if (operatorTokenKind === 42
27703             || operatorTokenKind === 66) {
27704             transformFlags |= 128;
27705         }
27706         node.transformFlags = transformFlags | 536870912;
27707         return transformFlags & ~536870912;
27708     }
27709     function computeParameter(node, subtreeFlags) {
27710         var transformFlags = subtreeFlags;
27711         var name = node.name;
27712         var initializer = node.initializer;
27713         var dotDotDotToken = node.dotDotDotToken;
27714         if (node.questionToken
27715             || node.type
27716             || (subtreeFlags & 2048 && ts.some(node.decorators))
27717             || ts.isThisIdentifier(name)) {
27718             transformFlags |= 1;
27719         }
27720         if (ts.hasModifier(node, 92)) {
27721             transformFlags |= 1 | 2048;
27722         }
27723         if (subtreeFlags & 16384) {
27724             transformFlags |= 32;
27725         }
27726         if (subtreeFlags & 131072 || initializer || dotDotDotToken) {
27727             transformFlags |= 256;
27728         }
27729         node.transformFlags = transformFlags | 536870912;
27730         return transformFlags & ~536870912;
27731     }
27732     function computeParenthesizedExpression(node, subtreeFlags) {
27733         var transformFlags = subtreeFlags;
27734         var expression = node.expression;
27735         var expressionKind = expression.kind;
27736         if (expressionKind === 217
27737             || expressionKind === 199) {
27738             transformFlags |= 1;
27739         }
27740         node.transformFlags = transformFlags | 536870912;
27741         return transformFlags & ~536870912;
27742     }
27743     function computeClassDeclaration(node, subtreeFlags) {
27744         var transformFlags;
27745         if (ts.hasModifier(node, 2)) {
27746             transformFlags = 1;
27747         }
27748         else {
27749             transformFlags = subtreeFlags | 256;
27750             if ((subtreeFlags & 2048)
27751                 || node.typeParameters) {
27752                 transformFlags |= 1;
27753             }
27754         }
27755         node.transformFlags = transformFlags | 536870912;
27756         return transformFlags & ~536905728;
27757     }
27758     function computeClassExpression(node, subtreeFlags) {
27759         var transformFlags = subtreeFlags | 256;
27760         if (subtreeFlags & 2048
27761             || node.typeParameters) {
27762             transformFlags |= 1;
27763         }
27764         node.transformFlags = transformFlags | 536870912;
27765         return transformFlags & ~536905728;
27766     }
27767     function computeHeritageClause(node, subtreeFlags) {
27768         var transformFlags = subtreeFlags;
27769         switch (node.token) {
27770             case 90:
27771                 transformFlags |= 256;
27772                 break;
27773             case 113:
27774                 transformFlags |= 1;
27775                 break;
27776             default:
27777                 ts.Debug.fail("Unexpected token for heritage clause");
27778                 break;
27779         }
27780         node.transformFlags = transformFlags | 536870912;
27781         return transformFlags & ~536870912;
27782     }
27783     function computeCatchClause(node, subtreeFlags) {
27784         var transformFlags = subtreeFlags;
27785         if (!node.variableDeclaration) {
27786             transformFlags |= 16;
27787         }
27788         else if (ts.isBindingPattern(node.variableDeclaration.name)) {
27789             transformFlags |= 256;
27790         }
27791         node.transformFlags = transformFlags | 536870912;
27792         return transformFlags & ~536887296;
27793     }
27794     function computeExpressionWithTypeArguments(node, subtreeFlags) {
27795         var transformFlags = subtreeFlags | 256;
27796         if (node.typeArguments) {
27797             transformFlags |= 1;
27798         }
27799         node.transformFlags = transformFlags | 536870912;
27800         return transformFlags & ~536870912;
27801     }
27802     function computeConstructor(node, subtreeFlags) {
27803         var transformFlags = subtreeFlags;
27804         if (ts.hasModifier(node, 2270)
27805             || !node.body) {
27806             transformFlags |= 1;
27807         }
27808         if (subtreeFlags & 16384) {
27809             transformFlags |= 32;
27810         }
27811         node.transformFlags = transformFlags | 536870912;
27812         return transformFlags & ~538923008;
27813     }
27814     function computeMethod(node, subtreeFlags) {
27815         var transformFlags = subtreeFlags | 256;
27816         if (node.decorators
27817             || ts.hasModifier(node, 2270)
27818             || node.typeParameters
27819             || node.type
27820             || !node.body
27821             || node.questionToken) {
27822             transformFlags |= 1;
27823         }
27824         if (subtreeFlags & 16384) {
27825             transformFlags |= 32;
27826         }
27827         if (ts.hasModifier(node, 256)) {
27828             transformFlags |= node.asteriskToken ? 32 : 64;
27829         }
27830         if (node.asteriskToken) {
27831             transformFlags |= 512;
27832         }
27833         node.transformFlags = transformFlags | 536870912;
27834         return propagatePropertyNameFlags(node.name, transformFlags & ~538923008);
27835     }
27836     function computeAccessor(node, subtreeFlags) {
27837         var transformFlags = subtreeFlags;
27838         if (node.decorators
27839             || ts.hasModifier(node, 2270)
27840             || node.type
27841             || !node.body) {
27842             transformFlags |= 1;
27843         }
27844         if (subtreeFlags & 16384) {
27845             transformFlags |= 32;
27846         }
27847         node.transformFlags = transformFlags | 536870912;
27848         return propagatePropertyNameFlags(node.name, transformFlags & ~538923008);
27849     }
27850     function computePropertyDeclaration(node, subtreeFlags) {
27851         var transformFlags = subtreeFlags | 4194304;
27852         if (ts.some(node.decorators) || ts.hasModifier(node, 2270) || node.type || node.questionToken || node.exclamationToken) {
27853             transformFlags |= 1;
27854         }
27855         if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) {
27856             transformFlags |= 2048;
27857         }
27858         node.transformFlags = transformFlags | 536870912;
27859         return propagatePropertyNameFlags(node.name, transformFlags & ~536875008);
27860     }
27861     function computeFunctionDeclaration(node, subtreeFlags) {
27862         var transformFlags;
27863         var modifierFlags = ts.getModifierFlags(node);
27864         var body = node.body;
27865         if (!body || (modifierFlags & 2)) {
27866             transformFlags = 1;
27867         }
27868         else {
27869             transformFlags = subtreeFlags | 1048576;
27870             if (modifierFlags & 2270
27871                 || node.typeParameters
27872                 || node.type) {
27873                 transformFlags |= 1;
27874             }
27875             if (modifierFlags & 256) {
27876                 transformFlags |= node.asteriskToken ? 32 : 64;
27877             }
27878             if (subtreeFlags & 16384) {
27879                 transformFlags |= 32;
27880             }
27881             if (node.asteriskToken) {
27882                 transformFlags |= 512;
27883             }
27884         }
27885         node.transformFlags = transformFlags | 536870912;
27886         return transformFlags & ~538925056;
27887     }
27888     function computeFunctionExpression(node, subtreeFlags) {
27889         var transformFlags = subtreeFlags;
27890         if (ts.hasModifier(node, 2270)
27891             || node.typeParameters
27892             || node.type) {
27893             transformFlags |= 1;
27894         }
27895         if (ts.hasModifier(node, 256)) {
27896             transformFlags |= node.asteriskToken ? 32 : 64;
27897         }
27898         if (subtreeFlags & 16384) {
27899             transformFlags |= 32;
27900         }
27901         if (node.asteriskToken) {
27902             transformFlags |= 512;
27903         }
27904         node.transformFlags = transformFlags | 536870912;
27905         return transformFlags & ~538925056;
27906     }
27907     function computeArrowFunction(node, subtreeFlags) {
27908         var transformFlags = subtreeFlags | 256;
27909         if (ts.hasModifier(node, 2270)
27910             || node.typeParameters
27911             || node.type) {
27912             transformFlags |= 1;
27913         }
27914         if (ts.hasModifier(node, 256)) {
27915             transformFlags |= 64;
27916         }
27917         if (subtreeFlags & 16384) {
27918             transformFlags |= 32;
27919         }
27920         node.transformFlags = transformFlags | 536870912;
27921         return transformFlags & ~538920960;
27922     }
27923     function computePropertyAccess(node, subtreeFlags) {
27924         var transformFlags = subtreeFlags;
27925         if (node.flags & 32) {
27926             transformFlags |= 8;
27927         }
27928         if (node.expression.kind === 102) {
27929             transformFlags |= 64 | 32;
27930         }
27931         node.transformFlags = transformFlags | 536870912;
27932         return transformFlags & ~536870912;
27933     }
27934     function computeElementAccess(node, subtreeFlags) {
27935         var transformFlags = subtreeFlags;
27936         if (node.flags & 32) {
27937             transformFlags |= 8;
27938         }
27939         if (node.expression.kind === 102) {
27940             transformFlags |= 64 | 32;
27941         }
27942         node.transformFlags = transformFlags | 536870912;
27943         return transformFlags & ~536870912;
27944     }
27945     function computeVariableDeclaration(node, subtreeFlags) {
27946         var transformFlags = subtreeFlags;
27947         transformFlags |= 256 | 131072;
27948         if (subtreeFlags & 16384) {
27949             transformFlags |= 32;
27950         }
27951         if (node.type || node.exclamationToken) {
27952             transformFlags |= 1;
27953         }
27954         node.transformFlags = transformFlags | 536870912;
27955         return transformFlags & ~536870912;
27956     }
27957     function computeVariableStatement(node, subtreeFlags) {
27958         var transformFlags;
27959         var declarationListTransformFlags = node.declarationList.transformFlags;
27960         if (ts.hasModifier(node, 2)) {
27961             transformFlags = 1;
27962         }
27963         else {
27964             transformFlags = subtreeFlags;
27965             if (declarationListTransformFlags & 131072) {
27966                 transformFlags |= 256;
27967             }
27968         }
27969         node.transformFlags = transformFlags | 536870912;
27970         return transformFlags & ~536870912;
27971     }
27972     function computeLabeledStatement(node, subtreeFlags) {
27973         var transformFlags = subtreeFlags;
27974         if (subtreeFlags & 65536
27975             && ts.isIterationStatement(node, true)) {
27976             transformFlags |= 256;
27977         }
27978         node.transformFlags = transformFlags | 536870912;
27979         return transformFlags & ~536870912;
27980     }
27981     function computeImportEquals(node, subtreeFlags) {
27982         var transformFlags = subtreeFlags;
27983         if (!ts.isExternalModuleImportEqualsDeclaration(node)) {
27984             transformFlags |= 1;
27985         }
27986         node.transformFlags = transformFlags | 536870912;
27987         return transformFlags & ~536870912;
27988     }
27989     function computeExpressionStatement(node, subtreeFlags) {
27990         var transformFlags = subtreeFlags;
27991         node.transformFlags = transformFlags | 536870912;
27992         return transformFlags & ~536870912;
27993     }
27994     function computeModuleDeclaration(node, subtreeFlags) {
27995         var transformFlags = 1;
27996         var modifierFlags = ts.getModifierFlags(node);
27997         if ((modifierFlags & 2) === 0) {
27998             transformFlags |= subtreeFlags;
27999         }
28000         node.transformFlags = transformFlags | 536870912;
28001         return transformFlags & ~537991168;
28002     }
28003     function computeVariableDeclarationList(node, subtreeFlags) {
28004         var transformFlags = subtreeFlags | 1048576;
28005         if (subtreeFlags & 131072) {
28006             transformFlags |= 256;
28007         }
28008         if (node.flags & 3) {
28009             transformFlags |= 256 | 65536;
28010         }
28011         node.transformFlags = transformFlags | 536870912;
28012         return transformFlags & ~537018368;
28013     }
28014     function computeOther(node, kind, subtreeFlags) {
28015         var transformFlags = subtreeFlags;
28016         var excludeFlags = 536870912;
28017         switch (kind) {
28018             case 126:
28019                 transformFlags |= 32 | 64;
28020                 break;
28021             case 206:
28022                 transformFlags |= 32 | 64 | 524288;
28023                 break;
28024             case 199:
28025             case 217:
28026             case 326:
28027                 transformFlags |= 1;
28028                 excludeFlags = 536870912;
28029                 break;
28030             case 119:
28031             case 117:
28032             case 118:
28033             case 122:
28034             case 130:
28035             case 81:
28036             case 248:
28037             case 284:
28038             case 218:
28039             case 138:
28040                 transformFlags |= 1;
28041                 break;
28042             case 266:
28043             case 11:
28044             case 269:
28045             case 270:
28046             case 271:
28047             case 272:
28048             case 273:
28049             case 274:
28050             case 275:
28051             case 276:
28052                 transformFlags |= 2;
28053                 break;
28054             case 14:
28055             case 15:
28056             case 16:
28057             case 17:
28058                 if (node.templateFlags) {
28059                     transformFlags |= 32;
28060                     break;
28061                 }
28062             case 198:
28063                 if (ts.hasInvalidEscape(node.template)) {
28064                     transformFlags |= 32;
28065                     break;
28066                 }
28067             case 211:
28068             case 282:
28069             case 120:
28070             case 219:
28071                 transformFlags |= 256;
28072                 break;
28073             case 10:
28074                 if (node.hasExtendedUnicodeEscape) {
28075                     transformFlags |= 256;
28076                 }
28077                 break;
28078             case 8:
28079                 if (node.numericLiteralFlags & 384) {
28080                     transformFlags |= 256;
28081                 }
28082                 break;
28083             case 9:
28084                 transformFlags |= 4;
28085                 break;
28086             case 232:
28087                 if (node.awaitModifier) {
28088                     transformFlags |= 32;
28089                 }
28090                 transformFlags |= 256;
28091                 break;
28092             case 212:
28093                 transformFlags |= 32 | 256 | 262144;
28094                 break;
28095             case 125:
28096             case 140:
28097             case 151:
28098             case 137:
28099             case 141:
28100             case 143:
28101             case 128:
28102             case 144:
28103             case 110:
28104             case 155:
28105             case 158:
28106             case 160:
28107             case 165:
28108             case 166:
28109             case 167:
28110             case 168:
28111             case 169:
28112             case 170:
28113             case 171:
28114             case 172:
28115             case 173:
28116             case 174:
28117             case 175:
28118             case 176:
28119             case 177:
28120             case 178:
28121             case 179:
28122             case 180:
28123             case 181:
28124             case 182:
28125             case 246:
28126             case 247:
28127             case 183:
28128             case 184:
28129             case 185:
28130             case 186:
28131             case 187:
28132             case 252:
28133                 transformFlags = 1;
28134                 excludeFlags = -2;
28135                 break;
28136             case 154:
28137                 transformFlags |= 32768;
28138                 break;
28139             case 213:
28140                 transformFlags |= 256 | 8192;
28141                 break;
28142             case 283:
28143                 transformFlags |= 32 | 16384;
28144                 break;
28145             case 102:
28146                 transformFlags |= 256;
28147                 excludeFlags = 536870912;
28148                 break;
28149             case 104:
28150                 transformFlags |= 4096;
28151                 break;
28152             case 189:
28153                 transformFlags |= 256 | 131072;
28154                 if (subtreeFlags & 8192) {
28155                     transformFlags |= 32 | 16384;
28156                 }
28157                 excludeFlags = 536879104;
28158                 break;
28159             case 190:
28160                 transformFlags |= 256 | 131072;
28161                 excludeFlags = 536879104;
28162                 break;
28163             case 191:
28164                 transformFlags |= 256;
28165                 if (node.dotDotDotToken) {
28166                     transformFlags |= 8192;
28167                 }
28168                 break;
28169             case 157:
28170                 transformFlags |= 1 | 2048;
28171                 break;
28172             case 193:
28173                 excludeFlags = 536922112;
28174                 if (subtreeFlags & 32768) {
28175                     transformFlags |= 256;
28176                 }
28177                 if (subtreeFlags & 16384) {
28178                     transformFlags |= 32;
28179                 }
28180                 break;
28181             case 192:
28182                 excludeFlags = 536879104;
28183                 break;
28184             case 228:
28185             case 229:
28186             case 230:
28187             case 231:
28188                 if (subtreeFlags & 65536) {
28189                     transformFlags |= 256;
28190                 }
28191                 break;
28192             case 290:
28193                 break;
28194             case 262:
28195                 transformFlags |= 4;
28196                 break;
28197             case 235:
28198                 transformFlags |= 1048576 | 32;
28199                 break;
28200             case 233:
28201             case 234:
28202                 transformFlags |= 1048576;
28203                 break;
28204             case 76:
28205                 transformFlags |= 4194304;
28206                 break;
28207         }
28208         node.transformFlags = transformFlags | 536870912;
28209         return transformFlags & ~excludeFlags;
28210     }
28211     function propagatePropertyNameFlags(node, transformFlags) {
28212         return transformFlags | (node.transformFlags & 4096);
28213     }
28214     function getTransformFlagsSubtreeExclusions(kind) {
28215         if (kind >= 168 && kind <= 188) {
28216             return -2;
28217         }
28218         switch (kind) {
28219             case 196:
28220             case 197:
28221             case 192:
28222                 return 536879104;
28223             case 249:
28224                 return 537991168;
28225             case 156:
28226                 return 536870912;
28227             case 202:
28228                 return 538920960;
28229             case 201:
28230             case 244:
28231                 return 538925056;
28232             case 243:
28233                 return 537018368;
28234             case 245:
28235             case 214:
28236                 return 536905728;
28237             case 162:
28238                 return 538923008;
28239             case 161:
28240             case 163:
28241             case 164:
28242                 return 538923008;
28243             case 125:
28244             case 140:
28245             case 151:
28246             case 137:
28247             case 143:
28248             case 141:
28249             case 128:
28250             case 144:
28251             case 110:
28252             case 155:
28253             case 158:
28254             case 160:
28255             case 165:
28256             case 166:
28257             case 167:
28258             case 246:
28259             case 247:
28260                 return -2;
28261             case 193:
28262                 return 536922112;
28263             case 280:
28264                 return 536887296;
28265             case 189:
28266             case 190:
28267                 return 536879104;
28268             case 199:
28269             case 217:
28270             case 326:
28271             case 200:
28272             case 102:
28273                 return 536870912;
28274             case 194:
28275             case 195:
28276                 return 536870912;
28277             default:
28278                 return 536870912;
28279         }
28280     }
28281     ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions;
28282     function setParentPointers(parent, child) {
28283         child.parent = parent;
28284         ts.forEachChild(child, function (grandchild) { return setParentPointers(child, grandchild); });
28285     }
28286 })(ts || (ts = {}));
28287 var ts;
28288 (function (ts) {
28289     function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments) {
28290         return getSymbolWalker;
28291         function getSymbolWalker(accept) {
28292             if (accept === void 0) { accept = function () { return true; }; }
28293             var visitedTypes = [];
28294             var visitedSymbols = [];
28295             return {
28296                 walkType: function (type) {
28297                     try {
28298                         visitType(type);
28299                         return { visitedTypes: ts.getOwnValues(visitedTypes), visitedSymbols: ts.getOwnValues(visitedSymbols) };
28300                     }
28301                     finally {
28302                         ts.clear(visitedTypes);
28303                         ts.clear(visitedSymbols);
28304                     }
28305                 },
28306                 walkSymbol: function (symbol) {
28307                     try {
28308                         visitSymbol(symbol);
28309                         return { visitedTypes: ts.getOwnValues(visitedTypes), visitedSymbols: ts.getOwnValues(visitedSymbols) };
28310                     }
28311                     finally {
28312                         ts.clear(visitedTypes);
28313                         ts.clear(visitedSymbols);
28314                     }
28315                 },
28316             };
28317             function visitType(type) {
28318                 if (!type) {
28319                     return;
28320                 }
28321                 if (visitedTypes[type.id]) {
28322                     return;
28323                 }
28324                 visitedTypes[type.id] = type;
28325                 var shouldBail = visitSymbol(type.symbol);
28326                 if (shouldBail)
28327                     return;
28328                 if (type.flags & 524288) {
28329                     var objectType = type;
28330                     var objectFlags = objectType.objectFlags;
28331                     if (objectFlags & 4) {
28332                         visitTypeReference(type);
28333                     }
28334                     if (objectFlags & 32) {
28335                         visitMappedType(type);
28336                     }
28337                     if (objectFlags & (1 | 2)) {
28338                         visitInterfaceType(type);
28339                     }
28340                     if (objectFlags & (8 | 16)) {
28341                         visitObjectType(objectType);
28342                     }
28343                 }
28344                 if (type.flags & 262144) {
28345                     visitTypeParameter(type);
28346                 }
28347                 if (type.flags & 3145728) {
28348                     visitUnionOrIntersectionType(type);
28349                 }
28350                 if (type.flags & 4194304) {
28351                     visitIndexType(type);
28352                 }
28353                 if (type.flags & 8388608) {
28354                     visitIndexedAccessType(type);
28355                 }
28356             }
28357             function visitTypeReference(type) {
28358                 visitType(type.target);
28359                 ts.forEach(getTypeArguments(type), visitType);
28360             }
28361             function visitTypeParameter(type) {
28362                 visitType(getConstraintOfTypeParameter(type));
28363             }
28364             function visitUnionOrIntersectionType(type) {
28365                 ts.forEach(type.types, visitType);
28366             }
28367             function visitIndexType(type) {
28368                 visitType(type.type);
28369             }
28370             function visitIndexedAccessType(type) {
28371                 visitType(type.objectType);
28372                 visitType(type.indexType);
28373                 visitType(type.constraint);
28374             }
28375             function visitMappedType(type) {
28376                 visitType(type.typeParameter);
28377                 visitType(type.constraintType);
28378                 visitType(type.templateType);
28379                 visitType(type.modifiersType);
28380             }
28381             function visitSignature(signature) {
28382                 var typePredicate = getTypePredicateOfSignature(signature);
28383                 if (typePredicate) {
28384                     visitType(typePredicate.type);
28385                 }
28386                 ts.forEach(signature.typeParameters, visitType);
28387                 for (var _i = 0, _a = signature.parameters; _i < _a.length; _i++) {
28388                     var parameter = _a[_i];
28389                     visitSymbol(parameter);
28390                 }
28391                 visitType(getRestTypeOfSignature(signature));
28392                 visitType(getReturnTypeOfSignature(signature));
28393             }
28394             function visitInterfaceType(interfaceT) {
28395                 visitObjectType(interfaceT);
28396                 ts.forEach(interfaceT.typeParameters, visitType);
28397                 ts.forEach(getBaseTypes(interfaceT), visitType);
28398                 visitType(interfaceT.thisType);
28399             }
28400             function visitObjectType(type) {
28401                 var stringIndexType = getIndexTypeOfStructuredType(type, 0);
28402                 visitType(stringIndexType);
28403                 var numberIndexType = getIndexTypeOfStructuredType(type, 1);
28404                 visitType(numberIndexType);
28405                 var resolved = resolveStructuredTypeMembers(type);
28406                 for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) {
28407                     var signature = _a[_i];
28408                     visitSignature(signature);
28409                 }
28410                 for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) {
28411                     var signature = _c[_b];
28412                     visitSignature(signature);
28413                 }
28414                 for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) {
28415                     var p = _e[_d];
28416                     visitSymbol(p);
28417                 }
28418             }
28419             function visitSymbol(symbol) {
28420                 if (!symbol) {
28421                     return false;
28422                 }
28423                 var symbolId = ts.getSymbolId(symbol);
28424                 if (visitedSymbols[symbolId]) {
28425                     return false;
28426                 }
28427                 visitedSymbols[symbolId] = symbol;
28428                 if (!accept(symbol)) {
28429                     return true;
28430                 }
28431                 var t = getTypeOfSymbol(symbol);
28432                 visitType(t);
28433                 if (symbol.exports) {
28434                     symbol.exports.forEach(visitSymbol);
28435                 }
28436                 ts.forEach(symbol.declarations, function (d) {
28437                     if (d.type && d.type.kind === 172) {
28438                         var query = d.type;
28439                         var entity = getResolvedSymbol(getFirstIdentifier(query.exprName));
28440                         visitSymbol(entity);
28441                     }
28442                 });
28443                 return false;
28444             }
28445         }
28446     }
28447     ts.createGetSymbolWalker = createGetSymbolWalker;
28448 })(ts || (ts = {}));
28449 var ts;
28450 (function (ts) {
28451     var ambientModuleSymbolRegex = /^".+"$/;
28452     var anon = "(anonymous)";
28453     var nextSymbolId = 1;
28454     var nextNodeId = 1;
28455     var nextMergeId = 1;
28456     var nextFlowId = 1;
28457     var typeofEQFacts = ts.createMapFromTemplate({
28458         string: 1,
28459         number: 2,
28460         bigint: 4,
28461         boolean: 8,
28462         symbol: 16,
28463         undefined: 65536,
28464         object: 32,
28465         function: 64
28466     });
28467     var typeofNEFacts = ts.createMapFromTemplate({
28468         string: 256,
28469         number: 512,
28470         bigint: 1024,
28471         boolean: 2048,
28472         symbol: 4096,
28473         undefined: 524288,
28474         object: 8192,
28475         function: 16384
28476     });
28477     var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor);
28478     function SymbolLinks() {
28479     }
28480     function NodeLinks() {
28481         this.flags = 0;
28482     }
28483     function getNodeId(node) {
28484         if (!node.id) {
28485             node.id = nextNodeId;
28486             nextNodeId++;
28487         }
28488         return node.id;
28489     }
28490     ts.getNodeId = getNodeId;
28491     function getSymbolId(symbol) {
28492         if (!symbol.id) {
28493             symbol.id = nextSymbolId;
28494             nextSymbolId++;
28495         }
28496         return symbol.id;
28497     }
28498     ts.getSymbolId = getSymbolId;
28499     function isInstantiatedModule(node, preserveConstEnums) {
28500         var moduleState = ts.getModuleInstanceState(node);
28501         return moduleState === 1 ||
28502             (preserveConstEnums && moduleState === 2);
28503     }
28504     ts.isInstantiatedModule = isInstantiatedModule;
28505     function createTypeChecker(host, produceDiagnostics) {
28506         var getPackagesSet = ts.memoize(function () {
28507             var set = ts.createMap();
28508             host.getSourceFiles().forEach(function (sf) {
28509                 if (!sf.resolvedModules)
28510                     return;
28511                 ts.forEachEntry(sf.resolvedModules, function (r) {
28512                     if (r && r.packageId)
28513                         set.set(r.packageId.name, true);
28514                 });
28515             });
28516             return set;
28517         });
28518         var cancellationToken;
28519         var requestedExternalEmitHelpers;
28520         var externalHelpersModule;
28521         var Symbol = ts.objectAllocator.getSymbolConstructor();
28522         var Type = ts.objectAllocator.getTypeConstructor();
28523         var Signature = ts.objectAllocator.getSignatureConstructor();
28524         var typeCount = 0;
28525         var symbolCount = 0;
28526         var enumCount = 0;
28527         var totalInstantiationCount = 0;
28528         var instantiationCount = 0;
28529         var instantiationDepth = 0;
28530         var constraintDepth = 0;
28531         var currentNode;
28532         var emptySymbols = ts.createSymbolTable();
28533         var arrayVariances = [1];
28534         var compilerOptions = host.getCompilerOptions();
28535         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
28536         var moduleKind = ts.getEmitModuleKind(compilerOptions);
28537         var allowSyntheticDefaultImports = ts.getAllowSyntheticDefaultImports(compilerOptions);
28538         var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
28539         var strictFunctionTypes = ts.getStrictOptionValue(compilerOptions, "strictFunctionTypes");
28540         var strictBindCallApply = ts.getStrictOptionValue(compilerOptions, "strictBindCallApply");
28541         var strictPropertyInitialization = ts.getStrictOptionValue(compilerOptions, "strictPropertyInitialization");
28542         var noImplicitAny = ts.getStrictOptionValue(compilerOptions, "noImplicitAny");
28543         var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis");
28544         var keyofStringsOnly = !!compilerOptions.keyofStringsOnly;
28545         var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 32768;
28546         var emitResolver = createResolver();
28547         var nodeBuilder = createNodeBuilder();
28548         var globals = ts.createSymbolTable();
28549         var undefinedSymbol = createSymbol(4, "undefined");
28550         undefinedSymbol.declarations = [];
28551         var globalThisSymbol = createSymbol(1536, "globalThis", 8);
28552         globalThisSymbol.exports = globals;
28553         globalThisSymbol.declarations = [];
28554         globals.set(globalThisSymbol.escapedName, globalThisSymbol);
28555         var argumentsSymbol = createSymbol(4, "arguments");
28556         var requireSymbol = createSymbol(4, "require");
28557         var apparentArgumentCount;
28558         var checker = {
28559             getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); },
28560             getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); },
28561             getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; },
28562             getTypeCount: function () { return typeCount; },
28563             getInstantiationCount: function () { return totalInstantiationCount; },
28564             getRelationCacheSizes: function () { return ({
28565                 assignable: assignableRelation.size,
28566                 identity: identityRelation.size,
28567                 subtype: subtypeRelation.size,
28568                 strictSubtype: strictSubtypeRelation.size,
28569             }); },
28570             isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; },
28571             isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; },
28572             isUnknownSymbol: function (symbol) { return symbol === unknownSymbol; },
28573             getMergedSymbol: getMergedSymbol,
28574             getDiagnostics: getDiagnostics,
28575             getGlobalDiagnostics: getGlobalDiagnostics,
28576             getTypeOfSymbolAtLocation: function (symbol, location) {
28577                 location = ts.getParseTreeNode(location);
28578                 return location ? getTypeOfSymbolAtLocation(symbol, location) : errorType;
28579             },
28580             getSymbolsOfParameterPropertyDeclaration: function (parameterIn, parameterName) {
28581                 var parameter = ts.getParseTreeNode(parameterIn, ts.isParameter);
28582                 if (parameter === undefined)
28583                     return ts.Debug.fail("Cannot get symbols of a synthetic parameter that cannot be resolved to a parse-tree node.");
28584                 return getSymbolsOfParameterPropertyDeclaration(parameter, ts.escapeLeadingUnderscores(parameterName));
28585             },
28586             getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol,
28587             getPropertiesOfType: getPropertiesOfType,
28588             getPropertyOfType: function (type, name) { return getPropertyOfType(type, ts.escapeLeadingUnderscores(name)); },
28589             getPrivateIdentifierPropertyOfType: function (leftType, name, location) {
28590                 var node = ts.getParseTreeNode(location);
28591                 if (!node) {
28592                     return undefined;
28593                 }
28594                 var propName = ts.escapeLeadingUnderscores(name);
28595                 var lexicallyScopedIdentifier = lookupSymbolForPrivateIdentifierDeclaration(propName, node);
28596                 return lexicallyScopedIdentifier ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) : undefined;
28597             },
28598             getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); },
28599             getIndexInfoOfType: getIndexInfoOfType,
28600             getSignaturesOfType: getSignaturesOfType,
28601             getIndexTypeOfType: getIndexTypeOfType,
28602             getBaseTypes: getBaseTypes,
28603             getBaseTypeOfLiteralType: getBaseTypeOfLiteralType,
28604             getWidenedType: getWidenedType,
28605             getTypeFromTypeNode: function (nodeIn) {
28606                 var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
28607                 return node ? getTypeFromTypeNode(node) : errorType;
28608             },
28609             getParameterType: getTypeAtPosition,
28610             getPromisedTypeOfPromise: getPromisedTypeOfPromise,
28611             getReturnTypeOfSignature: getReturnTypeOfSignature,
28612             isNullableType: isNullableType,
28613             getNullableType: getNullableType,
28614             getNonNullableType: getNonNullableType,
28615             getNonOptionalType: removeOptionalTypeMarker,
28616             getTypeArguments: getTypeArguments,
28617             typeToTypeNode: nodeBuilder.typeToTypeNode,
28618             indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration,
28619             signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration,
28620             symbolToEntityName: nodeBuilder.symbolToEntityName,
28621             symbolToExpression: nodeBuilder.symbolToExpression,
28622             symbolToTypeParameterDeclarations: nodeBuilder.symbolToTypeParameterDeclarations,
28623             symbolToParameterDeclaration: nodeBuilder.symbolToParameterDeclaration,
28624             typeParameterToDeclaration: nodeBuilder.typeParameterToDeclaration,
28625             getSymbolsInScope: function (location, meaning) {
28626                 location = ts.getParseTreeNode(location);
28627                 return location ? getSymbolsInScope(location, meaning) : [];
28628             },
28629             getSymbolAtLocation: function (node) {
28630                 node = ts.getParseTreeNode(node);
28631                 return node ? getSymbolAtLocation(node, true) : undefined;
28632             },
28633             getShorthandAssignmentValueSymbol: function (node) {
28634                 node = ts.getParseTreeNode(node);
28635                 return node ? getShorthandAssignmentValueSymbol(node) : undefined;
28636             },
28637             getExportSpecifierLocalTargetSymbol: function (nodeIn) {
28638                 var node = ts.getParseTreeNode(nodeIn, ts.isExportSpecifier);
28639                 return node ? getExportSpecifierLocalTargetSymbol(node) : undefined;
28640             },
28641             getExportSymbolOfSymbol: function (symbol) {
28642                 return getMergedSymbol(symbol.exportSymbol || symbol);
28643             },
28644             getTypeAtLocation: function (node) {
28645                 node = ts.getParseTreeNode(node);
28646                 return node ? getTypeOfNode(node) : errorType;
28647             },
28648             getTypeOfAssignmentPattern: function (nodeIn) {
28649                 var node = ts.getParseTreeNode(nodeIn, ts.isAssignmentPattern);
28650                 return node && getTypeOfAssignmentPattern(node) || errorType;
28651             },
28652             getPropertySymbolOfDestructuringAssignment: function (locationIn) {
28653                 var location = ts.getParseTreeNode(locationIn, ts.isIdentifier);
28654                 return location ? getPropertySymbolOfDestructuringAssignment(location) : undefined;
28655             },
28656             signatureToString: function (signature, enclosingDeclaration, flags, kind) {
28657                 return signatureToString(signature, ts.getParseTreeNode(enclosingDeclaration), flags, kind);
28658             },
28659             typeToString: function (type, enclosingDeclaration, flags) {
28660                 return typeToString(type, ts.getParseTreeNode(enclosingDeclaration), flags);
28661             },
28662             symbolToString: function (symbol, enclosingDeclaration, meaning, flags) {
28663                 return symbolToString(symbol, ts.getParseTreeNode(enclosingDeclaration), meaning, flags);
28664             },
28665             typePredicateToString: function (predicate, enclosingDeclaration, flags) {
28666                 return typePredicateToString(predicate, ts.getParseTreeNode(enclosingDeclaration), flags);
28667             },
28668             writeSignature: function (signature, enclosingDeclaration, flags, kind, writer) {
28669                 return signatureToString(signature, ts.getParseTreeNode(enclosingDeclaration), flags, kind, writer);
28670             },
28671             writeType: function (type, enclosingDeclaration, flags, writer) {
28672                 return typeToString(type, ts.getParseTreeNode(enclosingDeclaration), flags, writer);
28673             },
28674             writeSymbol: function (symbol, enclosingDeclaration, meaning, flags, writer) {
28675                 return symbolToString(symbol, ts.getParseTreeNode(enclosingDeclaration), meaning, flags, writer);
28676             },
28677             writeTypePredicate: function (predicate, enclosingDeclaration, flags, writer) {
28678                 return typePredicateToString(predicate, ts.getParseTreeNode(enclosingDeclaration), flags, writer);
28679             },
28680             getAugmentedPropertiesOfType: getAugmentedPropertiesOfType,
28681             getRootSymbols: getRootSymbols,
28682             getContextualType: function (nodeIn, contextFlags) {
28683                 var node = ts.getParseTreeNode(nodeIn, ts.isExpression);
28684                 if (!node) {
28685                     return undefined;
28686                 }
28687                 var containingCall = ts.findAncestor(node, ts.isCallLikeExpression);
28688                 var containingCallResolvedSignature = containingCall && getNodeLinks(containingCall).resolvedSignature;
28689                 if (contextFlags & 4 && containingCall) {
28690                     var toMarkSkip = node;
28691                     do {
28692                         getNodeLinks(toMarkSkip).skipDirectInference = true;
28693                         toMarkSkip = toMarkSkip.parent;
28694                     } while (toMarkSkip && toMarkSkip !== containingCall);
28695                     getNodeLinks(containingCall).resolvedSignature = undefined;
28696                 }
28697                 var result = getContextualType(node, contextFlags);
28698                 if (contextFlags & 4 && containingCall) {
28699                     var toMarkSkip = node;
28700                     do {
28701                         getNodeLinks(toMarkSkip).skipDirectInference = undefined;
28702                         toMarkSkip = toMarkSkip.parent;
28703                     } while (toMarkSkip && toMarkSkip !== containingCall);
28704                     getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
28705                 }
28706                 return result;
28707             },
28708             getContextualTypeForObjectLiteralElement: function (nodeIn) {
28709                 var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
28710                 return node ? getContextualTypeForObjectLiteralElement(node) : undefined;
28711             },
28712             getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) {
28713                 var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
28714                 return node && getContextualTypeForArgumentAtIndex(node, argIndex);
28715             },
28716             getContextualTypeForJsxAttribute: function (nodeIn) {
28717                 var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike);
28718                 return node && getContextualTypeForJsxAttribute(node);
28719             },
28720             isContextSensitive: isContextSensitive,
28721             getFullyQualifiedName: getFullyQualifiedName,
28722             getResolvedSignature: function (node, candidatesOutArray, argumentCount) {
28723                 return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0);
28724             },
28725             getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) {
28726                 return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16);
28727             },
28728             getExpandedParameters: getExpandedParameters,
28729             hasEffectiveRestParameter: hasEffectiveRestParameter,
28730             getConstantValue: function (nodeIn) {
28731                 var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue);
28732                 return node ? getConstantValue(node) : undefined;
28733             },
28734             isValidPropertyAccess: function (nodeIn, propertyName) {
28735                 var node = ts.getParseTreeNode(nodeIn, ts.isPropertyAccessOrQualifiedNameOrImportTypeNode);
28736                 return !!node && isValidPropertyAccess(node, ts.escapeLeadingUnderscores(propertyName));
28737             },
28738             isValidPropertyAccessForCompletions: function (nodeIn, type, property) {
28739                 var node = ts.getParseTreeNode(nodeIn, ts.isPropertyAccessExpression);
28740                 return !!node && isValidPropertyAccessForCompletions(node, type, property);
28741             },
28742             getSignatureFromDeclaration: function (declarationIn) {
28743                 var declaration = ts.getParseTreeNode(declarationIn, ts.isFunctionLike);
28744                 return declaration ? getSignatureFromDeclaration(declaration) : undefined;
28745             },
28746             isImplementationOfOverload: function (node) {
28747                 var parsed = ts.getParseTreeNode(node, ts.isFunctionLike);
28748                 return parsed ? isImplementationOfOverload(parsed) : undefined;
28749             },
28750             getImmediateAliasedSymbol: getImmediateAliasedSymbol,
28751             getAliasedSymbol: resolveAlias,
28752             getEmitResolver: getEmitResolver,
28753             getExportsOfModule: getExportsOfModuleAsArray,
28754             getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule,
28755             getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, ts.getFirstIdentifier, getTypeArguments),
28756             getAmbientModules: getAmbientModules,
28757             getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt,
28758             isOptionalParameter: function (nodeIn) {
28759                 var node = ts.getParseTreeNode(nodeIn, ts.isParameter);
28760                 return node ? isOptionalParameter(node) : false;
28761             },
28762             tryGetMemberInModuleExports: function (name, symbol) { return tryGetMemberInModuleExports(ts.escapeLeadingUnderscores(name), symbol); },
28763             tryGetMemberInModuleExportsAndProperties: function (name, symbol) { return tryGetMemberInModuleExportsAndProperties(ts.escapeLeadingUnderscores(name), symbol); },
28764             tryFindAmbientModuleWithoutAugmentations: function (moduleName) {
28765                 return tryFindAmbientModule(moduleName, false);
28766             },
28767             getApparentType: getApparentType,
28768             getUnionType: getUnionType,
28769             isTypeAssignableTo: isTypeAssignableTo,
28770             createAnonymousType: createAnonymousType,
28771             createSignature: createSignature,
28772             createSymbol: createSymbol,
28773             createIndexInfo: createIndexInfo,
28774             getAnyType: function () { return anyType; },
28775             getStringType: function () { return stringType; },
28776             getNumberType: function () { return numberType; },
28777             createPromiseType: createPromiseType,
28778             createArrayType: createArrayType,
28779             getElementTypeOfArrayType: getElementTypeOfArrayType,
28780             getBooleanType: function () { return booleanType; },
28781             getFalseType: function (fresh) { return fresh ? falseType : regularFalseType; },
28782             getTrueType: function (fresh) { return fresh ? trueType : regularTrueType; },
28783             getVoidType: function () { return voidType; },
28784             getUndefinedType: function () { return undefinedType; },
28785             getNullType: function () { return nullType; },
28786             getESSymbolType: function () { return esSymbolType; },
28787             getNeverType: function () { return neverType; },
28788             getOptionalType: function () { return optionalType; },
28789             isSymbolAccessible: isSymbolAccessible,
28790             isArrayType: isArrayType,
28791             isTupleType: isTupleType,
28792             isArrayLikeType: isArrayLikeType,
28793             isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant,
28794             getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes,
28795             getSuggestedSymbolForNonexistentProperty: getSuggestedSymbolForNonexistentProperty,
28796             getSuggestionForNonexistentProperty: getSuggestionForNonexistentProperty,
28797             getSuggestedSymbolForNonexistentSymbol: function (location, name, meaning) { return getSuggestedSymbolForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); },
28798             getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); },
28799             getSuggestedSymbolForNonexistentModule: getSuggestedSymbolForNonexistentModule,
28800             getSuggestionForNonexistentExport: getSuggestionForNonexistentExport,
28801             getBaseConstraintOfType: getBaseConstraintOfType,
28802             getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 ? getDefaultFromTypeParameter(type) : undefined; },
28803             resolveName: function (name, location, meaning, excludeGlobals) {
28804                 return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, undefined, undefined, false, excludeGlobals);
28805             },
28806             getJsxNamespace: function (n) { return ts.unescapeLeadingUnderscores(getJsxNamespace(n)); },
28807             getAccessibleSymbolChain: getAccessibleSymbolChain,
28808             getTypePredicateOfSignature: getTypePredicateOfSignature,
28809             resolveExternalModuleName: function (moduleSpecifier) {
28810                 return resolveExternalModuleName(moduleSpecifier, moduleSpecifier, true);
28811             },
28812             resolveExternalModuleSymbol: resolveExternalModuleSymbol,
28813             tryGetThisTypeAt: function (node, includeGlobalThis) {
28814                 node = ts.getParseTreeNode(node);
28815                 return node && tryGetThisTypeAt(node, includeGlobalThis);
28816             },
28817             getTypeArgumentConstraint: function (nodeIn) {
28818                 var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
28819                 return node && getTypeArgumentConstraint(node);
28820             },
28821             getSuggestionDiagnostics: function (file, ct) {
28822                 if (ts.skipTypeChecking(file, compilerOptions, host)) {
28823                     return ts.emptyArray;
28824                 }
28825                 var diagnostics;
28826                 try {
28827                     cancellationToken = ct;
28828                     checkSourceFile(file);
28829                     ts.Debug.assert(!!(getNodeLinks(file).flags & 1));
28830                     diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName));
28831                     checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) {
28832                         if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 8388608))) {
28833                             (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion }));
28834                         }
28835                     });
28836                     return diagnostics || ts.emptyArray;
28837                 }
28838                 finally {
28839                     cancellationToken = undefined;
28840                 }
28841             },
28842             runWithCancellationToken: function (token, callback) {
28843                 try {
28844                     cancellationToken = token;
28845                     return callback(checker);
28846                 }
28847                 finally {
28848                     cancellationToken = undefined;
28849                 }
28850             },
28851             getLocalTypeParametersOfClassOrInterfaceOrTypeAlias: getLocalTypeParametersOfClassOrInterfaceOrTypeAlias,
28852             isDeclarationVisible: isDeclarationVisible,
28853         };
28854         function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode) {
28855             var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
28856             apparentArgumentCount = argumentCount;
28857             var res = node ? getResolvedSignature(node, candidatesOutArray, checkMode) : undefined;
28858             apparentArgumentCount = undefined;
28859             return res;
28860         }
28861         var tupleTypes = ts.createMap();
28862         var unionTypes = ts.createMap();
28863         var intersectionTypes = ts.createMap();
28864         var literalTypes = ts.createMap();
28865         var indexedAccessTypes = ts.createMap();
28866         var substitutionTypes = ts.createMap();
28867         var evolvingArrayTypes = [];
28868         var undefinedProperties = ts.createMap();
28869         var unknownSymbol = createSymbol(4, "unknown");
28870         var resolvingSymbol = createSymbol(0, "__resolving__");
28871         var anyType = createIntrinsicType(1, "any");
28872         var autoType = createIntrinsicType(1, "any");
28873         var wildcardType = createIntrinsicType(1, "any");
28874         var errorType = createIntrinsicType(1, "error");
28875         var nonInferrableAnyType = createIntrinsicType(1, "any", 524288);
28876         var unknownType = createIntrinsicType(2, "unknown");
28877         var undefinedType = createIntrinsicType(32768, "undefined");
28878         var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768, "undefined", 524288);
28879         var optionalType = createIntrinsicType(32768, "undefined");
28880         var nullType = createIntrinsicType(65536, "null");
28881         var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536, "null", 524288);
28882         var stringType = createIntrinsicType(4, "string");
28883         var numberType = createIntrinsicType(8, "number");
28884         var bigintType = createIntrinsicType(64, "bigint");
28885         var falseType = createIntrinsicType(512, "false");
28886         var regularFalseType = createIntrinsicType(512, "false");
28887         var trueType = createIntrinsicType(512, "true");
28888         var regularTrueType = createIntrinsicType(512, "true");
28889         trueType.regularType = regularTrueType;
28890         trueType.freshType = trueType;
28891         regularTrueType.regularType = regularTrueType;
28892         regularTrueType.freshType = trueType;
28893         falseType.regularType = regularFalseType;
28894         falseType.freshType = falseType;
28895         regularFalseType.regularType = regularFalseType;
28896         regularFalseType.freshType = falseType;
28897         var booleanType = createBooleanType([regularFalseType, regularTrueType]);
28898         createBooleanType([regularFalseType, trueType]);
28899         createBooleanType([falseType, regularTrueType]);
28900         createBooleanType([falseType, trueType]);
28901         var esSymbolType = createIntrinsicType(4096, "symbol");
28902         var voidType = createIntrinsicType(16384, "void");
28903         var neverType = createIntrinsicType(131072, "never");
28904         var silentNeverType = createIntrinsicType(131072, "never");
28905         var nonInferrableType = createIntrinsicType(131072, "never", 2097152);
28906         var implicitNeverType = createIntrinsicType(131072, "never");
28907         var unreachableNeverType = createIntrinsicType(131072, "never");
28908         var nonPrimitiveType = createIntrinsicType(67108864, "object");
28909         var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]);
28910         var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType;
28911         var numberOrBigIntType = getUnionType([numberType, bigintType]);
28912         var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? getRestrictiveTypeParameter(t) : t; });
28913         var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? wildcardType : t; });
28914         var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28915         var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28916         emptyJsxObjectType.objectFlags |= 4096;
28917         var emptyTypeLiteralSymbol = createSymbol(2048, "__type");
28918         emptyTypeLiteralSymbol.members = ts.createSymbolTable();
28919         var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28920         var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28921         emptyGenericType.instantiations = ts.createMap();
28922         var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28923         anyFunctionType.objectFlags |= 2097152;
28924         var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28925         var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28926         var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28927         var markerSuperType = createTypeParameter();
28928         var markerSubType = createTypeParameter();
28929         markerSubType.constraint = markerSuperType;
28930         var markerOtherType = createTypeParameter();
28931         var noTypePredicate = createTypePredicate(1, "<<unresolved>>", 0, anyType);
28932         var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, 0);
28933         var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, undefined, 0, 0);
28934         var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, 0);
28935         var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, undefined, 0, 0);
28936         var enumNumberIndexInfo = createIndexInfo(stringType, true);
28937         var iterationTypesCache = ts.createMap();
28938         var noIterationTypes = {
28939             get yieldType() { return ts.Debug.fail("Not supported"); },
28940             get returnType() { return ts.Debug.fail("Not supported"); },
28941             get nextType() { return ts.Debug.fail("Not supported"); },
28942         };
28943         var anyIterationTypes = createIterationTypes(anyType, anyType, anyType);
28944         var anyIterationTypesExceptNext = createIterationTypes(anyType, anyType, unknownType);
28945         var defaultIterationTypes = createIterationTypes(neverType, anyType, undefinedType);
28946         var asyncIterationTypesResolver = {
28947             iterableCacheKey: "iterationTypesOfAsyncIterable",
28948             iteratorCacheKey: "iterationTypesOfAsyncIterator",
28949             iteratorSymbolName: "asyncIterator",
28950             getGlobalIteratorType: getGlobalAsyncIteratorType,
28951             getGlobalIterableType: getGlobalAsyncIterableType,
28952             getGlobalIterableIteratorType: getGlobalAsyncIterableIteratorType,
28953             getGlobalGeneratorType: getGlobalAsyncGeneratorType,
28954             resolveIterationType: getAwaitedType,
28955             mustHaveANextMethodDiagnostic: ts.Diagnostics.An_async_iterator_must_have_a_next_method,
28956             mustBeAMethodDiagnostic: ts.Diagnostics.The_0_property_of_an_async_iterator_must_be_a_method,
28957             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,
28958         };
28959         var syncIterationTypesResolver = {
28960             iterableCacheKey: "iterationTypesOfIterable",
28961             iteratorCacheKey: "iterationTypesOfIterator",
28962             iteratorSymbolName: "iterator",
28963             getGlobalIteratorType: getGlobalIteratorType,
28964             getGlobalIterableType: getGlobalIterableType,
28965             getGlobalIterableIteratorType: getGlobalIterableIteratorType,
28966             getGlobalGeneratorType: getGlobalGeneratorType,
28967             resolveIterationType: function (type, _errorNode) { return type; },
28968             mustHaveANextMethodDiagnostic: ts.Diagnostics.An_iterator_must_have_a_next_method,
28969             mustBeAMethodDiagnostic: ts.Diagnostics.The_0_property_of_an_iterator_must_be_a_method,
28970             mustHaveAValueDiagnostic: ts.Diagnostics.The_type_returned_by_the_0_method_of_an_iterator_must_have_a_value_property,
28971         };
28972         var amalgamatedDuplicates;
28973         var reverseMappedCache = ts.createMap();
28974         var ambientModulesCache;
28975         var patternAmbientModules;
28976         var patternAmbientModuleAugmentations;
28977         var globalObjectType;
28978         var globalFunctionType;
28979         var globalCallableFunctionType;
28980         var globalNewableFunctionType;
28981         var globalArrayType;
28982         var globalReadonlyArrayType;
28983         var globalStringType;
28984         var globalNumberType;
28985         var globalBooleanType;
28986         var globalRegExpType;
28987         var globalThisType;
28988         var anyArrayType;
28989         var autoArrayType;
28990         var anyReadonlyArrayType;
28991         var deferredGlobalNonNullableTypeAlias;
28992         var deferredGlobalESSymbolConstructorSymbol;
28993         var deferredGlobalESSymbolType;
28994         var deferredGlobalTypedPropertyDescriptorType;
28995         var deferredGlobalPromiseType;
28996         var deferredGlobalPromiseLikeType;
28997         var deferredGlobalPromiseConstructorSymbol;
28998         var deferredGlobalPromiseConstructorLikeType;
28999         var deferredGlobalIterableType;
29000         var deferredGlobalIteratorType;
29001         var deferredGlobalIterableIteratorType;
29002         var deferredGlobalGeneratorType;
29003         var deferredGlobalIteratorYieldResultType;
29004         var deferredGlobalIteratorReturnResultType;
29005         var deferredGlobalAsyncIterableType;
29006         var deferredGlobalAsyncIteratorType;
29007         var deferredGlobalAsyncIterableIteratorType;
29008         var deferredGlobalAsyncGeneratorType;
29009         var deferredGlobalTemplateStringsArrayType;
29010         var deferredGlobalImportMetaType;
29011         var deferredGlobalExtractSymbol;
29012         var deferredGlobalOmitSymbol;
29013         var deferredGlobalBigIntType;
29014         var allPotentiallyUnusedIdentifiers = ts.createMap();
29015         var flowLoopStart = 0;
29016         var flowLoopCount = 0;
29017         var sharedFlowCount = 0;
29018         var flowAnalysisDisabled = false;
29019         var flowInvocationCount = 0;
29020         var lastFlowNode;
29021         var lastFlowNodeReachable;
29022         var flowTypeCache;
29023         var emptyStringType = getLiteralType("");
29024         var zeroType = getLiteralType(0);
29025         var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" });
29026         var resolutionTargets = [];
29027         var resolutionResults = [];
29028         var resolutionPropertyNames = [];
29029         var suggestionCount = 0;
29030         var maximumSuggestionCount = 10;
29031         var mergedSymbols = [];
29032         var symbolLinks = [];
29033         var nodeLinks = [];
29034         var flowLoopCaches = [];
29035         var flowLoopNodes = [];
29036         var flowLoopKeys = [];
29037         var flowLoopTypes = [];
29038         var sharedFlowNodes = [];
29039         var sharedFlowTypes = [];
29040         var flowNodeReachable = [];
29041         var potentialThisCollisions = [];
29042         var potentialNewTargetCollisions = [];
29043         var potentialWeakMapCollisions = [];
29044         var awaitedTypeStack = [];
29045         var diagnostics = ts.createDiagnosticCollection();
29046         var suggestionDiagnostics = ts.createDiagnosticCollection();
29047         var typeofTypesByName = ts.createMapFromTemplate({
29048             string: stringType,
29049             number: numberType,
29050             bigint: bigintType,
29051             boolean: booleanType,
29052             symbol: esSymbolType,
29053             undefined: undefinedType
29054         });
29055         var typeofType = createTypeofType();
29056         var _jsxNamespace;
29057         var _jsxFactoryEntity;
29058         var outofbandVarianceMarkerHandler;
29059         var subtypeRelation = ts.createMap();
29060         var strictSubtypeRelation = ts.createMap();
29061         var assignableRelation = ts.createMap();
29062         var comparableRelation = ts.createMap();
29063         var identityRelation = ts.createMap();
29064         var enumRelation = ts.createMap();
29065         var builtinGlobals = ts.createSymbolTable();
29066         builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol);
29067         initializeTypeChecker();
29068         return checker;
29069         function getJsxNamespace(location) {
29070             if (location) {
29071                 var file = ts.getSourceFileOfNode(location);
29072                 if (file) {
29073                     if (file.localJsxNamespace) {
29074                         return file.localJsxNamespace;
29075                     }
29076                     var jsxPragma = file.pragmas.get("jsx");
29077                     if (jsxPragma) {
29078                         var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma;
29079                         file.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion);
29080                         ts.visitNode(file.localJsxFactory, markAsSynthetic);
29081                         if (file.localJsxFactory) {
29082                             return file.localJsxNamespace = ts.getFirstIdentifier(file.localJsxFactory).escapedText;
29083                         }
29084                     }
29085                 }
29086             }
29087             if (!_jsxNamespace) {
29088                 _jsxNamespace = "React";
29089                 if (compilerOptions.jsxFactory) {
29090                     _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion);
29091                     ts.visitNode(_jsxFactoryEntity, markAsSynthetic);
29092                     if (_jsxFactoryEntity) {
29093                         _jsxNamespace = ts.getFirstIdentifier(_jsxFactoryEntity).escapedText;
29094                     }
29095                 }
29096                 else if (compilerOptions.reactNamespace) {
29097                     _jsxNamespace = ts.escapeLeadingUnderscores(compilerOptions.reactNamespace);
29098                 }
29099             }
29100             if (!_jsxFactoryEntity) {
29101                 _jsxFactoryEntity = ts.createQualifiedName(ts.createIdentifier(ts.unescapeLeadingUnderscores(_jsxNamespace)), "createElement");
29102             }
29103             return _jsxNamespace;
29104             function markAsSynthetic(node) {
29105                 node.pos = -1;
29106                 node.end = -1;
29107                 return ts.visitEachChild(node, markAsSynthetic, ts.nullTransformationContext);
29108             }
29109         }
29110         function getEmitResolver(sourceFile, cancellationToken) {
29111             getDiagnostics(sourceFile, cancellationToken);
29112             return emitResolver;
29113         }
29114         function lookupOrIssueError(location, message, arg0, arg1, arg2, arg3) {
29115             var diagnostic = location
29116                 ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3)
29117                 : ts.createCompilerDiagnostic(message, arg0, arg1, arg2, arg3);
29118             var existing = diagnostics.lookup(diagnostic);
29119             if (existing) {
29120                 return existing;
29121             }
29122             else {
29123                 diagnostics.add(diagnostic);
29124                 return diagnostic;
29125             }
29126         }
29127         function error(location, message, arg0, arg1, arg2, arg3) {
29128             var diagnostic = location
29129                 ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3)
29130                 : ts.createCompilerDiagnostic(message, arg0, arg1, arg2, arg3);
29131             diagnostics.add(diagnostic);
29132             return diagnostic;
29133         }
29134         function addErrorOrSuggestion(isError, diagnostic) {
29135             if (isError) {
29136                 diagnostics.add(diagnostic);
29137             }
29138             else {
29139                 suggestionDiagnostics.add(__assign(__assign({}, diagnostic), { category: ts.DiagnosticCategory.Suggestion }));
29140             }
29141         }
29142         function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) {
29143             addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message));
29144         }
29145         function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) {
29146             var diagnostic = error(location, message, arg0, arg1, arg2, arg3);
29147             if (maybeMissingAwait) {
29148                 var related = ts.createDiagnosticForNode(location, ts.Diagnostics.Did_you_forget_to_use_await);
29149                 ts.addRelatedInfo(diagnostic, related);
29150             }
29151             return diagnostic;
29152         }
29153         function createSymbol(flags, name, checkFlags) {
29154             symbolCount++;
29155             var symbol = (new Symbol(flags | 33554432, name));
29156             symbol.checkFlags = checkFlags || 0;
29157             return symbol;
29158         }
29159         function getExcludedSymbolFlags(flags) {
29160             var result = 0;
29161             if (flags & 2)
29162                 result |= 111551;
29163             if (flags & 1)
29164                 result |= 111550;
29165             if (flags & 4)
29166                 result |= 0;
29167             if (flags & 8)
29168                 result |= 900095;
29169             if (flags & 16)
29170                 result |= 110991;
29171             if (flags & 32)
29172                 result |= 899503;
29173             if (flags & 64)
29174                 result |= 788872;
29175             if (flags & 256)
29176                 result |= 899327;
29177             if (flags & 128)
29178                 result |= 899967;
29179             if (flags & 512)
29180                 result |= 110735;
29181             if (flags & 8192)
29182                 result |= 103359;
29183             if (flags & 32768)
29184                 result |= 46015;
29185             if (flags & 65536)
29186                 result |= 78783;
29187             if (flags & 262144)
29188                 result |= 526824;
29189             if (flags & 524288)
29190                 result |= 788968;
29191             if (flags & 2097152)
29192                 result |= 2097152;
29193             return result;
29194         }
29195         function recordMergedSymbol(target, source) {
29196             if (!source.mergeId) {
29197                 source.mergeId = nextMergeId;
29198                 nextMergeId++;
29199             }
29200             mergedSymbols[source.mergeId] = target;
29201         }
29202         function cloneSymbol(symbol) {
29203             var result = createSymbol(symbol.flags, symbol.escapedName);
29204             result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
29205             result.parent = symbol.parent;
29206             if (symbol.valueDeclaration)
29207                 result.valueDeclaration = symbol.valueDeclaration;
29208             if (symbol.constEnumOnlyModule)
29209                 result.constEnumOnlyModule = true;
29210             if (symbol.members)
29211                 result.members = ts.cloneMap(symbol.members);
29212             if (symbol.exports)
29213                 result.exports = ts.cloneMap(symbol.exports);
29214             recordMergedSymbol(result, symbol);
29215             return result;
29216         }
29217         function mergeSymbol(target, source, unidirectional) {
29218             if (unidirectional === void 0) { unidirectional = false; }
29219             if (!(target.flags & getExcludedSymbolFlags(source.flags)) ||
29220                 (source.flags | target.flags) & 67108864) {
29221                 if (source === target) {
29222                     return target;
29223                 }
29224                 if (!(target.flags & 33554432)) {
29225                     var resolvedTarget = resolveSymbol(target);
29226                     if (resolvedTarget === unknownSymbol) {
29227                         return source;
29228                     }
29229                     target = cloneSymbol(resolvedTarget);
29230                 }
29231                 if (source.flags & 512 && target.flags & 512 && target.constEnumOnlyModule && !source.constEnumOnlyModule) {
29232                     target.constEnumOnlyModule = false;
29233                 }
29234                 target.flags |= source.flags;
29235                 if (source.valueDeclaration) {
29236                     ts.setValueDeclaration(target, source.valueDeclaration);
29237                 }
29238                 ts.addRange(target.declarations, source.declarations);
29239                 if (source.members) {
29240                     if (!target.members)
29241                         target.members = ts.createSymbolTable();
29242                     mergeSymbolTable(target.members, source.members, unidirectional);
29243                 }
29244                 if (source.exports) {
29245                     if (!target.exports)
29246                         target.exports = ts.createSymbolTable();
29247                     mergeSymbolTable(target.exports, source.exports, unidirectional);
29248                 }
29249                 if (!unidirectional) {
29250                     recordMergedSymbol(target, source);
29251                 }
29252             }
29253             else if (target.flags & 1024) {
29254                 if (target !== globalThisSymbol) {
29255                     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));
29256                 }
29257             }
29258             else {
29259                 var isEitherEnum = !!(target.flags & 384 || source.flags & 384);
29260                 var isEitherBlockScoped_1 = !!(target.flags & 2 || source.flags & 2);
29261                 var message = isEitherEnum
29262                     ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations
29263                     : isEitherBlockScoped_1
29264                         ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
29265                         : ts.Diagnostics.Duplicate_identifier_0;
29266                 var sourceSymbolFile = source.declarations && ts.getSourceFileOfNode(source.declarations[0]);
29267                 var targetSymbolFile = target.declarations && ts.getSourceFileOfNode(target.declarations[0]);
29268                 var symbolName_1 = symbolToString(source);
29269                 if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) {
29270                     var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 ? sourceSymbolFile : targetSymbolFile;
29271                     var secondFile_1 = firstFile_1 === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile;
29272                     var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, firstFile_1.path + "|" + secondFile_1.path, function () {
29273                         return ({ firstFile: firstFile_1, secondFile: secondFile_1, conflictingSymbols: ts.createMap() });
29274                     });
29275                     var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () {
29276                         return ({ isBlockScoped: isEitherBlockScoped_1, firstFileLocations: [], secondFileLocations: [] });
29277                     });
29278                     addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
29279                     addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
29280                 }
29281                 else {
29282                     addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_1, target);
29283                     addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_1, source);
29284                 }
29285             }
29286             return target;
29287             function addDuplicateLocations(locs, symbol) {
29288                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
29289                     var decl = _a[_i];
29290                     ts.pushIfUnique(locs, decl);
29291                 }
29292             }
29293         }
29294         function addDuplicateDeclarationErrorsForSymbols(target, message, symbolName, source) {
29295             ts.forEach(target.declarations, function (node) {
29296                 addDuplicateDeclarationError(node, message, symbolName, source.declarations);
29297             });
29298         }
29299         function addDuplicateDeclarationError(node, message, symbolName, relatedNodes) {
29300             var errorNode = (ts.getExpandoInitializer(node, false) ? ts.getNameOfExpando(node) : ts.getNameOfDeclaration(node)) || node;
29301             var err = lookupOrIssueError(errorNode, message, symbolName);
29302             var _loop_6 = function (relatedNode) {
29303                 var adjustedNode = (ts.getExpandoInitializer(relatedNode, false) ? ts.getNameOfExpando(relatedNode) : ts.getNameOfDeclaration(relatedNode)) || relatedNode;
29304                 if (adjustedNode === errorNode)
29305                     return "continue";
29306                 err.relatedInformation = err.relatedInformation || [];
29307                 var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here, symbolName);
29308                 var followOnMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics.and_here);
29309                 if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 || ts.compareDiagnostics(r, leadingMessage) === 0; }))
29310                     return "continue";
29311                 ts.addRelatedInfo(err, !ts.length(err.relatedInformation) ? leadingMessage : followOnMessage);
29312             };
29313             for (var _i = 0, _a = relatedNodes || ts.emptyArray; _i < _a.length; _i++) {
29314                 var relatedNode = _a[_i];
29315                 _loop_6(relatedNode);
29316             }
29317         }
29318         function combineSymbolTables(first, second) {
29319             if (!ts.hasEntries(first))
29320                 return second;
29321             if (!ts.hasEntries(second))
29322                 return first;
29323             var combined = ts.createSymbolTable();
29324             mergeSymbolTable(combined, first);
29325             mergeSymbolTable(combined, second);
29326             return combined;
29327         }
29328         function mergeSymbolTable(target, source, unidirectional) {
29329             if (unidirectional === void 0) { unidirectional = false; }
29330             source.forEach(function (sourceSymbol, id) {
29331                 var targetSymbol = target.get(id);
29332                 target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : sourceSymbol);
29333             });
29334         }
29335         function mergeModuleAugmentation(moduleName) {
29336             var _a, _b;
29337             var moduleAugmentation = moduleName.parent;
29338             if (moduleAugmentation.symbol.declarations[0] !== moduleAugmentation) {
29339                 ts.Debug.assert(moduleAugmentation.symbol.declarations.length > 1);
29340                 return;
29341             }
29342             if (ts.isGlobalScopeAugmentation(moduleAugmentation)) {
29343                 mergeSymbolTable(globals, moduleAugmentation.symbol.exports);
29344             }
29345             else {
29346                 var moduleNotFoundError = !(moduleName.parent.parent.flags & 8388608)
29347                     ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found
29348                     : undefined;
29349                 var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, true);
29350                 if (!mainModule_1) {
29351                     return;
29352                 }
29353                 mainModule_1 = resolveExternalModuleSymbol(mainModule_1);
29354                 if (mainModule_1.flags & 1920) {
29355                     if (ts.some(patternAmbientModules, function (module) { return mainModule_1 === module.symbol; })) {
29356                         var merged = mergeSymbol(moduleAugmentation.symbol, mainModule_1, true);
29357                         if (!patternAmbientModuleAugmentations) {
29358                             patternAmbientModuleAugmentations = ts.createMap();
29359                         }
29360                         patternAmbientModuleAugmentations.set(moduleName.text, merged);
29361                     }
29362                     else {
29363                         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)) {
29364                             var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports");
29365                             for (var _i = 0, _c = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _c.length; _i++) {
29366                                 var _d = _c[_i], key = _d[0], value = _d[1];
29367                                 if (resolvedExports.has(key) && !mainModule_1.exports.has(key)) {
29368                                     mergeSymbol(resolvedExports.get(key), value);
29369                                 }
29370                             }
29371                         }
29372                         mergeSymbol(mainModule_1, moduleAugmentation.symbol);
29373                     }
29374                 }
29375                 else {
29376                     error(moduleName, ts.Diagnostics.Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity, moduleName.text);
29377                 }
29378             }
29379         }
29380         function addToSymbolTable(target, source, message) {
29381             source.forEach(function (sourceSymbol, id) {
29382                 var targetSymbol = target.get(id);
29383                 if (targetSymbol) {
29384                     ts.forEach(targetSymbol.declarations, addDeclarationDiagnostic(ts.unescapeLeadingUnderscores(id), message));
29385                 }
29386                 else {
29387                     target.set(id, sourceSymbol);
29388                 }
29389             });
29390             function addDeclarationDiagnostic(id, message) {
29391                 return function (declaration) { return diagnostics.add(ts.createDiagnosticForNode(declaration, message, id)); };
29392             }
29393         }
29394         function getSymbolLinks(symbol) {
29395             if (symbol.flags & 33554432)
29396                 return symbol;
29397             var id = getSymbolId(symbol);
29398             return symbolLinks[id] || (symbolLinks[id] = new SymbolLinks());
29399         }
29400         function getNodeLinks(node) {
29401             var nodeId = getNodeId(node);
29402             return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks());
29403         }
29404         function isGlobalSourceFile(node) {
29405             return node.kind === 290 && !ts.isExternalOrCommonJsModule(node);
29406         }
29407         function getSymbol(symbols, name, meaning) {
29408             if (meaning) {
29409                 var symbol = getMergedSymbol(symbols.get(name));
29410                 if (symbol) {
29411                     ts.Debug.assert((ts.getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here.");
29412                     if (symbol.flags & meaning) {
29413                         return symbol;
29414                     }
29415                     if (symbol.flags & 2097152) {
29416                         var target = resolveAlias(symbol);
29417                         if (target === unknownSymbol || target.flags & meaning) {
29418                             return symbol;
29419                         }
29420                     }
29421                 }
29422             }
29423         }
29424         function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) {
29425             var constructorDeclaration = parameter.parent;
29426             var classDeclaration = parameter.parent.parent;
29427             var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551);
29428             var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551);
29429             if (parameterSymbol && propertySymbol) {
29430                 return [parameterSymbol, propertySymbol];
29431             }
29432             return ts.Debug.fail("There should exist two symbols, one as property declaration and one as parameter declaration");
29433         }
29434         function isBlockScopedNameDeclaredBeforeUse(declaration, usage) {
29435             var declarationFile = ts.getSourceFileOfNode(declaration);
29436             var useFile = ts.getSourceFileOfNode(usage);
29437             var declContainer = ts.getEnclosingBlockScopeContainer(declaration);
29438             if (declarationFile !== useFile) {
29439                 if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) ||
29440                     (!compilerOptions.outFile && !compilerOptions.out) ||
29441                     isInTypeQuery(usage) ||
29442                     declaration.flags & 8388608) {
29443                     return true;
29444                 }
29445                 if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
29446                     return true;
29447                 }
29448                 var sourceFiles = host.getSourceFiles();
29449                 return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile);
29450             }
29451             if (declaration.pos <= usage.pos) {
29452                 if (declaration.kind === 191) {
29453                     var errorBindingElement = ts.getAncestor(usage, 191);
29454                     if (errorBindingElement) {
29455                         return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) ||
29456                             declaration.pos < errorBindingElement.pos;
29457                     }
29458                     return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 242), usage);
29459                 }
29460                 else if (declaration.kind === 242) {
29461                     return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage);
29462                 }
29463                 else if (ts.isClassDeclaration(declaration)) {
29464                     return !ts.findAncestor(usage, function (n) { return ts.isComputedPropertyName(n) && n.parent.parent === declaration; });
29465                 }
29466                 else if (ts.isPropertyDeclaration(declaration)) {
29467                     return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, false);
29468                 }
29469                 else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) {
29470                     return !(compilerOptions.target === 99 && !!compilerOptions.useDefineForClassFields
29471                         && ts.getContainingClass(declaration) === ts.getContainingClass(usage)
29472                         && isUsedInFunctionOrInstanceProperty(usage, declaration));
29473                 }
29474                 return true;
29475             }
29476             if (usage.parent.kind === 263 || (usage.parent.kind === 259 && usage.parent.isExportEquals)) {
29477                 return true;
29478             }
29479             if (usage.kind === 259 && usage.isExportEquals) {
29480                 return true;
29481             }
29482             if (!!(usage.flags & 4194304) || isInTypeQuery(usage) || usageInTypeDeclaration()) {
29483                 return true;
29484             }
29485             if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
29486                 if (compilerOptions.target === 99 && !!compilerOptions.useDefineForClassFields
29487                     && ts.getContainingClass(declaration)
29488                     && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) {
29489                     return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, true);
29490                 }
29491                 else {
29492                     return true;
29493                 }
29494             }
29495             return false;
29496             function usageInTypeDeclaration() {
29497                 return !!ts.findAncestor(usage, function (node) { return ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node); });
29498             }
29499             function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) {
29500                 switch (declaration.parent.parent.kind) {
29501                     case 225:
29502                     case 230:
29503                     case 232:
29504                         if (isSameScopeDescendentOf(usage, declaration, declContainer)) {
29505                             return true;
29506                         }
29507                         break;
29508                 }
29509                 var grandparent = declaration.parent.parent;
29510                 return ts.isForInOrOfStatement(grandparent) && isSameScopeDescendentOf(usage, grandparent.expression, declContainer);
29511             }
29512             function isUsedInFunctionOrInstanceProperty(usage, declaration) {
29513                 return !!ts.findAncestor(usage, function (current) {
29514                     if (current === declContainer) {
29515                         return "quit";
29516                     }
29517                     if (ts.isFunctionLike(current)) {
29518                         return true;
29519                     }
29520                     var initializerOfProperty = current.parent &&
29521                         current.parent.kind === 159 &&
29522                         current.parent.initializer === current;
29523                     if (initializerOfProperty) {
29524                         if (ts.hasModifier(current.parent, 32)) {
29525                             if (declaration.kind === 161) {
29526                                 return true;
29527                             }
29528                         }
29529                         else {
29530                             var isDeclarationInstanceProperty = declaration.kind === 159 && !ts.hasModifier(declaration, 32);
29531                             if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) {
29532                                 return true;
29533                             }
29534                         }
29535                     }
29536                     return false;
29537                 });
29538             }
29539             function isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, stopAtAnyPropertyDeclaration) {
29540                 if (usage.end > declaration.end) {
29541                     return false;
29542                 }
29543                 var ancestorChangingReferenceScope = ts.findAncestor(usage, function (node) {
29544                     if (node === declaration) {
29545                         return "quit";
29546                     }
29547                     switch (node.kind) {
29548                         case 202:
29549                             return true;
29550                         case 159:
29551                             return stopAtAnyPropertyDeclaration &&
29552                                 (ts.isPropertyDeclaration(declaration) && node.parent === declaration.parent
29553                                     || ts.isParameterPropertyDeclaration(declaration, declaration.parent) && node.parent === declaration.parent.parent)
29554                                 ? "quit" : true;
29555                         case 223:
29556                             switch (node.parent.kind) {
29557                                 case 163:
29558                                 case 161:
29559                                 case 164:
29560                                     return true;
29561                                 default:
29562                                     return false;
29563                             }
29564                         default:
29565                             return false;
29566                     }
29567                 });
29568                 return ancestorChangingReferenceScope === undefined;
29569             }
29570         }
29571         function useOuterVariableScopeInParameter(result, location, lastLocation) {
29572             var target = ts.getEmitScriptTarget(compilerOptions);
29573             var functionLocation = location;
29574             if (ts.isParameter(lastLocation) && functionLocation.body && result.valueDeclaration.pos >= functionLocation.body.pos && result.valueDeclaration.end <= functionLocation.body.end) {
29575                 if (target >= 2) {
29576                     var links = getNodeLinks(functionLocation);
29577                     if (links.declarationRequiresScopeChange === undefined) {
29578                         links.declarationRequiresScopeChange = ts.forEach(functionLocation.parameters, requiresScopeChange) || false;
29579                     }
29580                     return !links.declarationRequiresScopeChange;
29581                 }
29582             }
29583             return false;
29584             function requiresScopeChange(node) {
29585                 return requiresScopeChangeWorker(node.name)
29586                     || !!node.initializer && requiresScopeChangeWorker(node.initializer);
29587             }
29588             function requiresScopeChangeWorker(node) {
29589                 switch (node.kind) {
29590                     case 202:
29591                     case 201:
29592                     case 244:
29593                     case 162:
29594                         return false;
29595                     case 161:
29596                     case 163:
29597                     case 164:
29598                     case 281:
29599                         return requiresScopeChangeWorker(node.name);
29600                     case 159:
29601                         if (ts.hasStaticModifier(node)) {
29602                             return target < 99 || !compilerOptions.useDefineForClassFields;
29603                         }
29604                         return requiresScopeChangeWorker(node.name);
29605                     default:
29606                         if (ts.isNullishCoalesce(node) || ts.isOptionalChain(node)) {
29607                             return target < 7;
29608                         }
29609                         if (ts.isBindingElement(node) && node.dotDotDotToken && ts.isObjectBindingPattern(node.parent)) {
29610                             return target < 4;
29611                         }
29612                         if (ts.isTypeNode(node))
29613                             return false;
29614                         return ts.forEachChild(node, requiresScopeChangeWorker) || false;
29615                 }
29616             }
29617         }
29618         function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, suggestedNameNotFoundMessage) {
29619             if (excludeGlobals === void 0) { excludeGlobals = false; }
29620             return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol, suggestedNameNotFoundMessage);
29621         }
29622         function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup, suggestedNameNotFoundMessage) {
29623             var originalLocation = location;
29624             var result;
29625             var lastLocation;
29626             var lastSelfReferenceLocation;
29627             var propertyWithInvalidInitializer;
29628             var associatedDeclarationForContainingInitializerOrBindingName;
29629             var withinDeferredContext = false;
29630             var errorLocation = location;
29631             var grandparent;
29632             var isInExternalModule = false;
29633             loop: while (location) {
29634                 if (location.locals && !isGlobalSourceFile(location)) {
29635                     if (result = lookup(location.locals, name, meaning)) {
29636                         var useResult = true;
29637                         if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) {
29638                             if (meaning & result.flags & 788968 && lastLocation.kind !== 303) {
29639                                 useResult = result.flags & 262144
29640                                     ? lastLocation === location.type ||
29641                                         lastLocation.kind === 156 ||
29642                                         lastLocation.kind === 155
29643                                     : false;
29644                             }
29645                             if (meaning & result.flags & 3) {
29646                                 if (useOuterVariableScopeInParameter(result, location, lastLocation)) {
29647                                     useResult = false;
29648                                 }
29649                                 else if (result.flags & 1) {
29650                                     useResult =
29651                                         lastLocation.kind === 156 ||
29652                                             (lastLocation === location.type &&
29653                                                 !!ts.findAncestor(result.valueDeclaration, ts.isParameter));
29654                                 }
29655                             }
29656                         }
29657                         else if (location.kind === 180) {
29658                             useResult = lastLocation === location.trueType;
29659                         }
29660                         if (useResult) {
29661                             break loop;
29662                         }
29663                         else {
29664                             result = undefined;
29665                         }
29666                     }
29667                 }
29668                 withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation);
29669                 switch (location.kind) {
29670                     case 290:
29671                         if (!ts.isExternalOrCommonJsModule(location))
29672                             break;
29673                         isInExternalModule = true;
29674                     case 249:
29675                         var moduleExports = getSymbolOfNode(location).exports || emptySymbols;
29676                         if (location.kind === 290 || (ts.isModuleDeclaration(location) && location.flags & 8388608 && !ts.isGlobalScopeAugmentation(location))) {
29677                             if (result = moduleExports.get("default")) {
29678                                 var localSymbol = ts.getLocalSymbolForExportDefault(result);
29679                                 if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) {
29680                                     break loop;
29681                                 }
29682                                 result = undefined;
29683                             }
29684                             var moduleExport = moduleExports.get(name);
29685                             if (moduleExport &&
29686                                 moduleExport.flags === 2097152 &&
29687                                 (ts.getDeclarationOfKind(moduleExport, 263) || ts.getDeclarationOfKind(moduleExport, 262))) {
29688                                 break;
29689                             }
29690                         }
29691                         if (name !== "default" && (result = lookup(moduleExports, name, meaning & 2623475))) {
29692                             if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !result.declarations.some(ts.isJSDocTypeAlias)) {
29693                                 result = undefined;
29694                             }
29695                             else {
29696                                 break loop;
29697                             }
29698                         }
29699                         break;
29700                     case 248:
29701                         if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8)) {
29702                             break loop;
29703                         }
29704                         break;
29705                     case 159:
29706                         if (!ts.hasModifier(location, 32)) {
29707                             var ctor = findConstructorDeclaration(location.parent);
29708                             if (ctor && ctor.locals) {
29709                                 if (lookup(ctor.locals, name, meaning & 111551)) {
29710                                     propertyWithInvalidInitializer = location;
29711                                 }
29712                             }
29713                         }
29714                         break;
29715                     case 245:
29716                     case 214:
29717                     case 246:
29718                         if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968)) {
29719                             if (!isTypeParameterSymbolDeclaredInContainer(result, location)) {
29720                                 result = undefined;
29721                                 break;
29722                             }
29723                             if (lastLocation && ts.hasModifier(lastLocation, 32)) {
29724                                 error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters);
29725                                 return undefined;
29726                             }
29727                             break loop;
29728                         }
29729                         if (location.kind === 214 && meaning & 32) {
29730                             var className = location.name;
29731                             if (className && name === className.escapedText) {
29732                                 result = location.symbol;
29733                                 break loop;
29734                             }
29735                         }
29736                         break;
29737                     case 216:
29738                         if (lastLocation === location.expression && location.parent.token === 90) {
29739                             var container = location.parent.parent;
29740                             if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968))) {
29741                                 if (nameNotFoundMessage) {
29742                                     error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters);
29743                                 }
29744                                 return undefined;
29745                             }
29746                         }
29747                         break;
29748                     case 154:
29749                         grandparent = location.parent.parent;
29750                         if (ts.isClassLike(grandparent) || grandparent.kind === 246) {
29751                             if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968)) {
29752                                 error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type);
29753                                 return undefined;
29754                             }
29755                         }
29756                         break;
29757                     case 202:
29758                         if (compilerOptions.target >= 2) {
29759                             break;
29760                         }
29761                     case 161:
29762                     case 162:
29763                     case 163:
29764                     case 164:
29765                     case 244:
29766                         if (meaning & 3 && name === "arguments") {
29767                             result = argumentsSymbol;
29768                             break loop;
29769                         }
29770                         break;
29771                     case 201:
29772                         if (meaning & 3 && name === "arguments") {
29773                             result = argumentsSymbol;
29774                             break loop;
29775                         }
29776                         if (meaning & 16) {
29777                             var functionName = location.name;
29778                             if (functionName && name === functionName.escapedText) {
29779                                 result = location.symbol;
29780                                 break loop;
29781                             }
29782                         }
29783                         break;
29784                     case 157:
29785                         if (location.parent && location.parent.kind === 156) {
29786                             location = location.parent;
29787                         }
29788                         if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 245)) {
29789                             location = location.parent;
29790                         }
29791                         break;
29792                     case 322:
29793                     case 315:
29794                     case 316:
29795                         location = ts.getJSDocHost(location);
29796                         break;
29797                     case 156:
29798                         if (lastLocation && (lastLocation === location.initializer ||
29799                             lastLocation === location.name && ts.isBindingPattern(lastLocation))) {
29800                             if (!associatedDeclarationForContainingInitializerOrBindingName) {
29801                                 associatedDeclarationForContainingInitializerOrBindingName = location;
29802                             }
29803                         }
29804                         break;
29805                     case 191:
29806                         if (lastLocation && (lastLocation === location.initializer ||
29807                             lastLocation === location.name && ts.isBindingPattern(lastLocation))) {
29808                             var root = ts.getRootDeclaration(location);
29809                             if (root.kind === 156) {
29810                                 if (!associatedDeclarationForContainingInitializerOrBindingName) {
29811                                     associatedDeclarationForContainingInitializerOrBindingName = location;
29812                                 }
29813                             }
29814                         }
29815                         break;
29816                 }
29817                 if (isSelfReferenceLocation(location)) {
29818                     lastSelfReferenceLocation = location;
29819                 }
29820                 lastLocation = location;
29821                 location = location.parent;
29822             }
29823             if (isUse && result && (!lastSelfReferenceLocation || result !== lastSelfReferenceLocation.symbol)) {
29824                 result.isReferenced |= meaning;
29825             }
29826             if (!result) {
29827                 if (lastLocation) {
29828                     ts.Debug.assert(lastLocation.kind === 290);
29829                     if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) {
29830                         return lastLocation.symbol;
29831                     }
29832                 }
29833                 if (!excludeGlobals) {
29834                     result = lookup(globals, name, meaning);
29835                 }
29836             }
29837             if (!result) {
29838                 if (originalLocation && ts.isInJSFile(originalLocation) && originalLocation.parent) {
29839                     if (ts.isRequireCall(originalLocation.parent, false)) {
29840                         return requireSymbol;
29841                     }
29842                 }
29843             }
29844             if (!result) {
29845                 if (nameNotFoundMessage) {
29846                     if (!errorLocation ||
29847                         !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) &&
29848                             !checkAndReportErrorForExtendingInterface(errorLocation) &&
29849                             !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
29850                             !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
29851                             !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
29852                             !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
29853                             !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
29854                         var suggestion = void 0;
29855                         if (suggestedNameNotFoundMessage && suggestionCount < maximumSuggestionCount) {
29856                             suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
29857                             if (suggestion) {
29858                                 var suggestionName = symbolToString(suggestion);
29859                                 var diagnostic = error(errorLocation, suggestedNameNotFoundMessage, diagnosticName(nameArg), suggestionName);
29860                                 if (suggestion.valueDeclaration) {
29861                                     ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
29862                                 }
29863                             }
29864                         }
29865                         if (!suggestion) {
29866                             error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
29867                         }
29868                         suggestionCount++;
29869                     }
29870                 }
29871                 return undefined;
29872             }
29873             if (nameNotFoundMessage) {
29874                 if (propertyWithInvalidInitializer && !(compilerOptions.target === 99 && compilerOptions.useDefineForClassFields)) {
29875                     var propertyName = propertyWithInvalidInitializer.name;
29876                     error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
29877                     return undefined;
29878                 }
29879                 if (errorLocation &&
29880                     (meaning & 2 ||
29881                         ((meaning & 32 || meaning & 384) && (meaning & 111551) === 111551))) {
29882                     var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
29883                     if (exportOrLocalSymbol.flags & 2 || exportOrLocalSymbol.flags & 32 || exportOrLocalSymbol.flags & 384) {
29884                         checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
29885                     }
29886                 }
29887                 if (result && isInExternalModule && (meaning & 111551) === 111551 && !(originalLocation.flags & 4194304)) {
29888                     var merged = getMergedSymbol(result);
29889                     if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
29890                         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));
29891                     }
29892                 }
29893                 if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551) === 111551) {
29894                     var candidate = getMergedSymbol(getLateBoundSymbol(result));
29895                     var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName);
29896                     if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializerOrBindingName)) {
29897                         error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_itself, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name));
29898                     }
29899                     else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializerOrBindingName.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) {
29900                         error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
29901                     }
29902                 }
29903                 if (result && errorLocation && meaning & 111551 && result.flags & 2097152) {
29904                     checkSymbolUsageInExpressionContext(result, name, errorLocation);
29905                 }
29906             }
29907             return result;
29908         }
29909         function checkSymbolUsageInExpressionContext(symbol, name, useSite) {
29910             if (!ts.isValidTypeOnlyAliasUseSite(useSite)) {
29911                 var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
29912                 if (typeOnlyDeclaration) {
29913                     var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration);
29914                     var message = isExport
29915                         ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
29916                         : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
29917                     var relatedMessage = isExport
29918                         ? ts.Diagnostics._0_was_exported_here
29919                         : ts.Diagnostics._0_was_imported_here;
29920                     var unescapedName = ts.unescapeLeadingUnderscores(name);
29921                     ts.addRelatedInfo(error(useSite, message, unescapedName), ts.createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, unescapedName));
29922                 }
29923             }
29924         }
29925         function getIsDeferredContext(location, lastLocation) {
29926             if (location.kind !== 202 && location.kind !== 201) {
29927                 return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) ||
29928                     (location.kind === 159 && !ts.hasModifier(location, 32))) && (!lastLocation || lastLocation !== location.name));
29929             }
29930             if (lastLocation && lastLocation === location.name) {
29931                 return false;
29932             }
29933             if (location.asteriskToken || ts.hasModifier(location, 256)) {
29934                 return true;
29935             }
29936             return !ts.getImmediatelyInvokedFunctionExpression(location);
29937         }
29938         function isSelfReferenceLocation(node) {
29939             switch (node.kind) {
29940                 case 244:
29941                 case 245:
29942                 case 246:
29943                 case 248:
29944                 case 247:
29945                 case 249:
29946                     return true;
29947                 default:
29948                     return false;
29949             }
29950         }
29951         function diagnosticName(nameArg) {
29952             return ts.isString(nameArg) ? ts.unescapeLeadingUnderscores(nameArg) : ts.declarationNameToString(nameArg);
29953         }
29954         function isTypeParameterSymbolDeclaredInContainer(symbol, container) {
29955             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
29956                 var decl = _a[_i];
29957                 if (decl.kind === 155) {
29958                     var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent;
29959                     if (parent === container) {
29960                         return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias));
29961                     }
29962                 }
29963             }
29964             return false;
29965         }
29966         function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) {
29967             if (!ts.isIdentifier(errorLocation) || errorLocation.escapedText !== name || isTypeReferenceIdentifier(errorLocation) || isInTypeQuery(errorLocation)) {
29968                 return false;
29969             }
29970             var container = ts.getThisContainer(errorLocation, false);
29971             var location = container;
29972             while (location) {
29973                 if (ts.isClassLike(location.parent)) {
29974                     var classSymbol = getSymbolOfNode(location.parent);
29975                     if (!classSymbol) {
29976                         break;
29977                     }
29978                     var constructorType = getTypeOfSymbol(classSymbol);
29979                     if (getPropertyOfType(constructorType, name)) {
29980                         error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0, diagnosticName(nameArg), symbolToString(classSymbol));
29981                         return true;
29982                     }
29983                     if (location === container && !ts.hasModifier(location, 32)) {
29984                         var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType;
29985                         if (getPropertyOfType(instanceType, name)) {
29986                             error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, diagnosticName(nameArg));
29987                             return true;
29988                         }
29989                     }
29990                 }
29991                 location = location.parent;
29992             }
29993             return false;
29994         }
29995         function checkAndReportErrorForExtendingInterface(errorLocation) {
29996             var expression = getEntityNameForExtendingInterface(errorLocation);
29997             if (expression && resolveEntityName(expression, 64, true)) {
29998                 error(errorLocation, ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, ts.getTextOfNode(expression));
29999                 return true;
30000             }
30001             return false;
30002         }
30003         function getEntityNameForExtendingInterface(node) {
30004             switch (node.kind) {
30005                 case 75:
30006                 case 194:
30007                     return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined;
30008                 case 216:
30009                     if (ts.isEntityNameExpression(node.expression)) {
30010                         return node.expression;
30011                     }
30012                 default:
30013                     return undefined;
30014             }
30015         }
30016         function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) {
30017             var namespaceMeaning = 1920 | (ts.isInJSFile(errorLocation) ? 111551 : 0);
30018             if (meaning === namespaceMeaning) {
30019                 var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 & ~namespaceMeaning, undefined, undefined, false));
30020                 var parent = errorLocation.parent;
30021                 if (symbol) {
30022                     if (ts.isQualifiedName(parent)) {
30023                         ts.Debug.assert(parent.left === errorLocation, "Should only be resolving left side of qualified name as a namespace");
30024                         var propName = parent.right.escapedText;
30025                         var propType = getPropertyOfType(getDeclaredTypeOfSymbol(symbol), propName);
30026                         if (propType) {
30027                             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));
30028                             return true;
30029                         }
30030                     }
30031                     error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here, ts.unescapeLeadingUnderscores(name));
30032                     return true;
30033                 }
30034             }
30035             return false;
30036         }
30037         function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) {
30038             if (meaning & (788968 & ~1920)) {
30039                 var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 & 111551, undefined, undefined, false));
30040                 if (symbol && !(symbol.flags & 1920)) {
30041                     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));
30042                     return true;
30043                 }
30044             }
30045             return false;
30046         }
30047         function isPrimitiveTypeName(name) {
30048             return name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never" || name === "unknown";
30049         }
30050         function checkAndReportErrorForExportingPrimitiveType(errorLocation, name) {
30051             if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 263) {
30052                 error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name);
30053                 return true;
30054             }
30055             return false;
30056         }
30057         function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) {
30058             if (meaning & (111551 & ~1024)) {
30059                 if (isPrimitiveTypeName(name)) {
30060                     error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name));
30061                     return true;
30062                 }
30063                 var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 & ~111551, undefined, undefined, false));
30064                 if (symbol && !(symbol.flags & 1024)) {
30065                     var message = isES2015OrLaterConstructorName(name)
30066                         ? 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
30067                         : ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here;
30068                     error(errorLocation, message, ts.unescapeLeadingUnderscores(name));
30069                     return true;
30070                 }
30071             }
30072             return false;
30073         }
30074         function isES2015OrLaterConstructorName(n) {
30075             switch (n) {
30076                 case "Promise":
30077                 case "Symbol":
30078                 case "Map":
30079                 case "WeakMap":
30080                 case "Set":
30081                 case "WeakSet":
30082                     return true;
30083             }
30084             return false;
30085         }
30086         function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) {
30087             if (meaning & (111551 & ~1024 & ~788968)) {
30088                 var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~111551, undefined, undefined, false));
30089                 if (symbol) {
30090                     error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name));
30091                     return true;
30092                 }
30093             }
30094             else if (meaning & (788968 & ~1024 & ~111551)) {
30095                 var symbol = resolveSymbol(resolveName(errorLocation, name, (512 | 1024) & ~788968, undefined, undefined, false));
30096                 if (symbol) {
30097                     error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name));
30098                     return true;
30099                 }
30100             }
30101             return false;
30102         }
30103         function checkResolvedBlockScopedVariable(result, errorLocation) {
30104             ts.Debug.assert(!!(result.flags & 2 || result.flags & 32 || result.flags & 384));
30105             if (result.flags & (16 | 1 | 67108864) && result.flags & 32) {
30106                 return;
30107             }
30108             var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 248); });
30109             if (declaration === undefined)
30110                 return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration");
30111             if (!(declaration.flags & 8388608) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
30112                 var diagnosticMessage = void 0;
30113                 var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration));
30114                 if (result.flags & 2) {
30115                     diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName);
30116                 }
30117                 else if (result.flags & 32) {
30118                     diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
30119                 }
30120                 else if (result.flags & 256) {
30121                     diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName);
30122                 }
30123                 else {
30124                     ts.Debug.assert(!!(result.flags & 128));
30125                     if (compilerOptions.preserveConstEnums) {
30126                         diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
30127                     }
30128                 }
30129                 if (diagnosticMessage) {
30130                     ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_is_declared_here, declarationName));
30131                 }
30132             }
30133         }
30134         function isSameScopeDescendentOf(initial, parent, stopAt) {
30135             return !!parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; });
30136         }
30137         function getAnyImportSyntax(node) {
30138             switch (node.kind) {
30139                 case 253:
30140                     return node;
30141                 case 255:
30142                     return node.parent;
30143                 case 256:
30144                     return node.parent.parent;
30145                 case 258:
30146                     return node.parent.parent.parent;
30147                 default:
30148                     return undefined;
30149             }
30150         }
30151         function getDeclarationOfAliasSymbol(symbol) {
30152             return ts.find(symbol.declarations, isAliasSymbolDeclaration);
30153         }
30154         function isAliasSymbolDeclaration(node) {
30155             return node.kind === 253 ||
30156                 node.kind === 252 ||
30157                 node.kind === 255 && !!node.name ||
30158                 node.kind === 256 ||
30159                 node.kind === 262 ||
30160                 node.kind === 258 ||
30161                 node.kind === 263 ||
30162                 node.kind === 259 && ts.exportAssignmentIsAlias(node) ||
30163                 ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 && ts.exportAssignmentIsAlias(node) ||
30164                 ts.isPropertyAccessExpression(node)
30165                     && ts.isBinaryExpression(node.parent)
30166                     && node.parent.left === node
30167                     && node.parent.operatorToken.kind === 62
30168                     && isAliasableOrJsExpression(node.parent.right) ||
30169                 node.kind === 282 ||
30170                 node.kind === 281 && isAliasableOrJsExpression(node.initializer);
30171         }
30172         function isAliasableOrJsExpression(e) {
30173             return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
30174         }
30175         function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) {
30176             if (node.moduleReference.kind === 265) {
30177                 var immediate = resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node));
30178                 var resolved_4 = resolveExternalModuleSymbol(immediate);
30179                 markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, false);
30180                 return resolved_4;
30181             }
30182             var resolved = getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias);
30183             checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved);
30184             return resolved;
30185         }
30186         function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) {
30187             if (markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false)) {
30188                 var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node));
30189                 var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration);
30190                 var message = isExport
30191                     ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type
30192                     : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type;
30193                 var relatedMessage = isExport
30194                     ? ts.Diagnostics._0_was_exported_here
30195                     : ts.Diagnostics._0_was_imported_here;
30196                 var name = ts.unescapeLeadingUnderscores(typeOnlyDeclaration.name.escapedText);
30197                 ts.addRelatedInfo(error(node.moduleReference, message), ts.createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, name));
30198             }
30199         }
30200         function resolveExportByName(moduleSymbol, name, sourceNode, dontResolveAlias) {
30201             var exportValue = moduleSymbol.exports.get("export=");
30202             if (exportValue) {
30203                 return getPropertyOfType(getTypeOfSymbol(exportValue), name);
30204             }
30205             var exportSymbol = moduleSymbol.exports.get(name);
30206             var resolved = resolveSymbol(exportSymbol, dontResolveAlias);
30207             markSymbolOfAliasDeclarationIfTypeOnly(sourceNode, exportSymbol, resolved, false);
30208             return resolved;
30209         }
30210         function isSyntacticDefault(node) {
30211             return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasModifier(node, 512) || ts.isExportSpecifier(node));
30212         }
30213         function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias) {
30214             if (!allowSyntheticDefaultImports) {
30215                 return false;
30216             }
30217             if (!file || file.isDeclarationFile) {
30218                 var defaultExportSymbol = resolveExportByName(moduleSymbol, "default", undefined, true);
30219                 if (defaultExportSymbol && ts.some(defaultExportSymbol.declarations, isSyntacticDefault)) {
30220                     return false;
30221                 }
30222                 if (resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), undefined, dontResolveAlias)) {
30223                     return false;
30224                 }
30225                 return true;
30226             }
30227             if (!ts.isSourceFileJS(file)) {
30228                 return hasExportAssignmentSymbol(moduleSymbol);
30229             }
30230             return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), undefined, dontResolveAlias);
30231         }
30232         function getTargetOfImportClause(node, dontResolveAlias) {
30233             var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier);
30234             if (moduleSymbol) {
30235                 var exportDefaultSymbol = void 0;
30236                 if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) {
30237                     exportDefaultSymbol = moduleSymbol;
30238                 }
30239                 else {
30240                     exportDefaultSymbol = resolveExportByName(moduleSymbol, "default", node, dontResolveAlias);
30241                 }
30242                 var file = ts.find(moduleSymbol.declarations, ts.isSourceFile);
30243                 var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias);
30244                 if (!exportDefaultSymbol && !hasSyntheticDefault) {
30245                     if (hasExportAssignmentSymbol(moduleSymbol)) {
30246                         var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop";
30247                         var exportEqualsSymbol = moduleSymbol.exports.get("export=");
30248                         var exportAssignment = exportEqualsSymbol.valueDeclaration;
30249                         var err = error(node.name, ts.Diagnostics.Module_0_can_only_be_default_imported_using_the_1_flag, symbolToString(moduleSymbol), compilerOptionName);
30250                         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));
30251                     }
30252                     else {
30253                         reportNonDefaultExport(moduleSymbol, node);
30254                     }
30255                 }
30256                 else if (hasSyntheticDefault) {
30257                     var resolved = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
30258                     markSymbolOfAliasDeclarationIfTypeOnly(node, moduleSymbol, resolved, false);
30259                     return resolved;
30260                 }
30261                 markSymbolOfAliasDeclarationIfTypeOnly(node, exportDefaultSymbol, undefined, false);
30262                 return exportDefaultSymbol;
30263             }
30264         }
30265         function reportNonDefaultExport(moduleSymbol, node) {
30266             var _a, _b;
30267             if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has(node.symbol.escapedName)) {
30268                 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));
30269             }
30270             else {
30271                 var diagnostic = error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol));
30272                 var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export");
30273                 if (exportStar) {
30274                     var defaultExport = ts.find(exportStar.declarations, function (decl) {
30275                         var _a, _b;
30276                         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")));
30277                     });
30278                     if (defaultExport) {
30279                         ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(defaultExport, ts.Diagnostics.export_Asterisk_does_not_re_export_a_default));
30280                     }
30281                 }
30282             }
30283         }
30284         function getTargetOfNamespaceImport(node, dontResolveAlias) {
30285             var moduleSpecifier = node.parent.parent.moduleSpecifier;
30286             var immediate = resolveExternalModuleName(node, moduleSpecifier);
30287             var resolved = resolveESModuleSymbol(immediate, moduleSpecifier, dontResolveAlias, false);
30288             markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved, false);
30289             return resolved;
30290         }
30291         function getTargetOfNamespaceExport(node, dontResolveAlias) {
30292             var moduleSpecifier = node.parent.moduleSpecifier;
30293             var immediate = moduleSpecifier && resolveExternalModuleName(node, moduleSpecifier);
30294             var resolved = moduleSpecifier && resolveESModuleSymbol(immediate, moduleSpecifier, dontResolveAlias, false);
30295             markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved, false);
30296             return resolved;
30297         }
30298         function combineValueAndTypeSymbols(valueSymbol, typeSymbol) {
30299             if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) {
30300                 return unknownSymbol;
30301             }
30302             if (valueSymbol.flags & (788968 | 1920)) {
30303                 return valueSymbol;
30304             }
30305             var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName);
30306             result.declarations = ts.deduplicate(ts.concatenate(valueSymbol.declarations, typeSymbol.declarations), ts.equateValues);
30307             result.parent = valueSymbol.parent || typeSymbol.parent;
30308             if (valueSymbol.valueDeclaration)
30309                 result.valueDeclaration = valueSymbol.valueDeclaration;
30310             if (typeSymbol.members)
30311                 result.members = ts.cloneMap(typeSymbol.members);
30312             if (valueSymbol.exports)
30313                 result.exports = ts.cloneMap(valueSymbol.exports);
30314             return result;
30315         }
30316         function getExportOfModule(symbol, specifier, dontResolveAlias) {
30317             var _a;
30318             if (symbol.flags & 1536) {
30319                 var name = ((_a = specifier.propertyName) !== null && _a !== void 0 ? _a : specifier.name).escapedText;
30320                 var exportSymbol = getExportsOfSymbol(symbol).get(name);
30321                 var resolved = resolveSymbol(exportSymbol, dontResolveAlias);
30322                 markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, false);
30323                 return resolved;
30324             }
30325         }
30326         function getPropertyOfVariable(symbol, name) {
30327             if (symbol.flags & 3) {
30328                 var typeAnnotation = symbol.valueDeclaration.type;
30329                 if (typeAnnotation) {
30330                     return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name));
30331                 }
30332             }
30333         }
30334         function getExternalModuleMember(node, specifier, dontResolveAlias) {
30335             var _a;
30336             if (dontResolveAlias === void 0) { dontResolveAlias = false; }
30337             var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier);
30338             var name = specifier.propertyName || specifier.name;
30339             var suppressInteropError = name.escapedText === "default" && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop);
30340             var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias, suppressInteropError);
30341             if (targetSymbol) {
30342                 if (name.escapedText) {
30343                     if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) {
30344                         return moduleSymbol;
30345                     }
30346                     var symbolFromVariable = void 0;
30347                     if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=")) {
30348                         symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.escapedText);
30349                     }
30350                     else {
30351                         symbolFromVariable = getPropertyOfVariable(targetSymbol, name.escapedText);
30352                     }
30353                     symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias);
30354                     var symbolFromModule = getExportOfModule(targetSymbol, specifier, dontResolveAlias);
30355                     if (symbolFromModule === undefined && name.escapedText === "default") {
30356                         var file = ts.find(moduleSymbol.declarations, ts.isSourceFile);
30357                         if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias)) {
30358                             symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
30359                         }
30360                     }
30361                     var symbol = symbolFromModule && symbolFromVariable && symbolFromModule !== symbolFromVariable ?
30362                         combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) :
30363                         symbolFromModule || symbolFromVariable;
30364                     if (!symbol) {
30365                         var moduleName = getFullyQualifiedName(moduleSymbol, node);
30366                         var declarationName = ts.declarationNameToString(name);
30367                         var suggestion = getSuggestedSymbolForNonexistentModule(name, targetSymbol);
30368                         if (suggestion !== undefined) {
30369                             var suggestionName = symbolToString(suggestion);
30370                             var diagnostic = error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_2, moduleName, declarationName, suggestionName);
30371                             if (suggestion.valueDeclaration) {
30372                                 ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
30373                             }
30374                         }
30375                         else {
30376                             if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has("default")) {
30377                                 error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName);
30378                             }
30379                             else {
30380                                 reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName);
30381                             }
30382                         }
30383                     }
30384                     return symbol;
30385                 }
30386             }
30387         }
30388         function reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName) {
30389             var _a;
30390             var localSymbol = (_a = moduleSymbol.valueDeclaration.locals) === null || _a === void 0 ? void 0 : _a.get(name.escapedText);
30391             var exports = moduleSymbol.exports;
30392             if (localSymbol) {
30393                 var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=");
30394                 if (exportedEqualsSymbol) {
30395                     getSymbolIfSameReference(exportedEqualsSymbol, localSymbol) ? reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) :
30396                         error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName);
30397                 }
30398                 else {
30399                     var exportedSymbol = exports ? ts.find(symbolsToArray(exports), function (symbol) { return !!getSymbolIfSameReference(symbol, localSymbol); }) : undefined;
30400                     var diagnostic = exportedSymbol ? error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_exported_as_2, moduleName, declarationName, symbolToString(exportedSymbol)) :
30401                         error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported, moduleName, declarationName);
30402                     ts.addRelatedInfo.apply(void 0, __spreadArrays([diagnostic], ts.map(localSymbol.declarations, function (decl, index) {
30403                         return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName);
30404                     })));
30405                 }
30406             }
30407             else {
30408                 error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName);
30409             }
30410         }
30411         function reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) {
30412             if (moduleKind >= ts.ModuleKind.ES2015) {
30413                 var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_a_default_import :
30414                     ts.Diagnostics._0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
30415                 error(name, message, declarationName);
30416             }
30417             else {
30418                 if (ts.isInJSFile(node)) {
30419                     var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import :
30420                         ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
30421                     error(name, message, declarationName);
30422                 }
30423                 else {
30424                     var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import :
30425                         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;
30426                     error(name, message, declarationName, declarationName, moduleName);
30427                 }
30428             }
30429         }
30430         function getTargetOfImportSpecifier(node, dontResolveAlias) {
30431             var resolved = getExternalModuleMember(node.parent.parent.parent, node, dontResolveAlias);
30432             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
30433             return resolved;
30434         }
30435         function getTargetOfNamespaceExportDeclaration(node, dontResolveAlias) {
30436             var resolved = resolveExternalModuleSymbol(node.parent.symbol, dontResolveAlias);
30437             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
30438             return resolved;
30439         }
30440         function getTargetOfExportSpecifier(node, meaning, dontResolveAlias) {
30441             var resolved = node.parent.parent.moduleSpecifier ?
30442                 getExternalModuleMember(node.parent.parent, node, dontResolveAlias) :
30443                 resolveEntityName(node.propertyName || node.name, meaning, false, dontResolveAlias);
30444             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
30445             return resolved;
30446         }
30447         function getTargetOfExportAssignment(node, dontResolveAlias) {
30448             var expression = ts.isExportAssignment(node) ? node.expression : node.right;
30449             var resolved = getTargetOfAliasLikeExpression(expression, dontResolveAlias);
30450             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
30451             return resolved;
30452         }
30453         function getTargetOfAliasLikeExpression(expression, dontResolveAlias) {
30454             if (ts.isClassExpression(expression)) {
30455                 return checkExpressionCached(expression).symbol;
30456             }
30457             if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) {
30458                 return undefined;
30459             }
30460             var aliasLike = resolveEntityName(expression, 111551 | 788968 | 1920, true, dontResolveAlias);
30461             if (aliasLike) {
30462                 return aliasLike;
30463             }
30464             checkExpressionCached(expression);
30465             return getNodeLinks(expression).resolvedSymbol;
30466         }
30467         function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) {
30468             var expression = node.initializer;
30469             return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve);
30470         }
30471         function getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve) {
30472             if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62)) {
30473                 return undefined;
30474             }
30475             return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve);
30476         }
30477         function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) {
30478             if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; }
30479             switch (node.kind) {
30480                 case 253:
30481                     return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve);
30482                 case 255:
30483                     return getTargetOfImportClause(node, dontRecursivelyResolve);
30484                 case 256:
30485                     return getTargetOfNamespaceImport(node, dontRecursivelyResolve);
30486                 case 262:
30487                     return getTargetOfNamespaceExport(node, dontRecursivelyResolve);
30488                 case 258:
30489                     return getTargetOfImportSpecifier(node, dontRecursivelyResolve);
30490                 case 263:
30491                     return getTargetOfExportSpecifier(node, 111551 | 788968 | 1920, dontRecursivelyResolve);
30492                 case 259:
30493                 case 209:
30494                     return getTargetOfExportAssignment(node, dontRecursivelyResolve);
30495                 case 252:
30496                     return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve);
30497                 case 282:
30498                     return resolveEntityName(node.name, 111551 | 788968 | 1920, true, dontRecursivelyResolve);
30499                 case 281:
30500                     return getTargetOfPropertyAssignment(node, dontRecursivelyResolve);
30501                 case 194:
30502                     return getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve);
30503                 default:
30504                     return ts.Debug.fail();
30505             }
30506         }
30507         function isNonLocalAlias(symbol, excludes) {
30508             if (excludes === void 0) { excludes = 111551 | 788968 | 1920; }
30509             if (!symbol)
30510                 return false;
30511             return (symbol.flags & (2097152 | excludes)) === 2097152 || !!(symbol.flags & 2097152 && symbol.flags & 67108864);
30512         }
30513         function resolveSymbol(symbol, dontResolveAlias) {
30514             return !dontResolveAlias && isNonLocalAlias(symbol) ? resolveAlias(symbol) : symbol;
30515         }
30516         function resolveAlias(symbol) {
30517             ts.Debug.assert((symbol.flags & 2097152) !== 0, "Should only get Alias here.");
30518             var links = getSymbolLinks(symbol);
30519             if (!links.target) {
30520                 links.target = resolvingSymbol;
30521                 var node = getDeclarationOfAliasSymbol(symbol);
30522                 if (!node)
30523                     return ts.Debug.fail();
30524                 var target = getTargetOfAliasDeclaration(node);
30525                 if (links.target === resolvingSymbol) {
30526                     links.target = target || unknownSymbol;
30527                 }
30528                 else {
30529                     error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol));
30530                 }
30531             }
30532             else if (links.target === resolvingSymbol) {
30533                 links.target = unknownSymbol;
30534             }
30535             return links.target;
30536         }
30537         function tryResolveAlias(symbol) {
30538             var links = getSymbolLinks(symbol);
30539             if (links.target !== resolvingSymbol) {
30540                 return resolveAlias(symbol);
30541             }
30542             return undefined;
30543         }
30544         function markSymbolOfAliasDeclarationIfTypeOnly(aliasDeclaration, immediateTarget, finalTarget, overwriteEmpty) {
30545             if (!aliasDeclaration)
30546                 return false;
30547             var sourceSymbol = getSymbolOfNode(aliasDeclaration);
30548             if (ts.isTypeOnlyImportOrExportDeclaration(aliasDeclaration)) {
30549                 var links_1 = getSymbolLinks(sourceSymbol);
30550                 links_1.typeOnlyDeclaration = aliasDeclaration;
30551                 return true;
30552             }
30553             var links = getSymbolLinks(sourceSymbol);
30554             return markSymbolOfAliasDeclarationIfTypeOnlyWorker(links, immediateTarget, overwriteEmpty)
30555                 || markSymbolOfAliasDeclarationIfTypeOnlyWorker(links, finalTarget, overwriteEmpty);
30556         }
30557         function markSymbolOfAliasDeclarationIfTypeOnlyWorker(aliasDeclarationLinks, target, overwriteEmpty) {
30558             var _a, _b, _c;
30559             if (target && (aliasDeclarationLinks.typeOnlyDeclaration === undefined || overwriteEmpty && aliasDeclarationLinks.typeOnlyDeclaration === false)) {
30560                 var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=")) !== null && _b !== void 0 ? _b : target;
30561                 var typeOnly = exportSymbol.declarations && ts.find(exportSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
30562                 aliasDeclarationLinks.typeOnlyDeclaration = (_c = typeOnly !== null && typeOnly !== void 0 ? typeOnly : getSymbolLinks(exportSymbol).typeOnlyDeclaration) !== null && _c !== void 0 ? _c : false;
30563             }
30564             return !!aliasDeclarationLinks.typeOnlyDeclaration;
30565         }
30566         function getTypeOnlyAliasDeclaration(symbol) {
30567             if (!(symbol.flags & 2097152)) {
30568                 return undefined;
30569             }
30570             var links = getSymbolLinks(symbol);
30571             return links.typeOnlyDeclaration || undefined;
30572         }
30573         function markExportAsReferenced(node) {
30574             var symbol = getSymbolOfNode(node);
30575             var target = resolveAlias(symbol);
30576             if (target) {
30577                 var markAlias = target === unknownSymbol ||
30578                     ((target.flags & 111551) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol));
30579                 if (markAlias) {
30580                     markAliasSymbolAsReferenced(symbol);
30581                 }
30582             }
30583         }
30584         function markAliasSymbolAsReferenced(symbol) {
30585             var links = getSymbolLinks(symbol);
30586             if (!links.referenced) {
30587                 links.referenced = true;
30588                 var node = getDeclarationOfAliasSymbol(symbol);
30589                 if (!node)
30590                     return ts.Debug.fail();
30591                 if (ts.isInternalModuleImportEqualsDeclaration(node)) {
30592                     var target = resolveSymbol(symbol);
30593                     if (target === unknownSymbol || target.flags & 111551) {
30594                         checkExpressionCached(node.moduleReference);
30595                     }
30596                 }
30597             }
30598         }
30599         function markConstEnumAliasAsReferenced(symbol) {
30600             var links = getSymbolLinks(symbol);
30601             if (!links.constEnumReferenced) {
30602                 links.constEnumReferenced = true;
30603             }
30604         }
30605         function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) {
30606             if (entityName.kind === 75 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) {
30607                 entityName = entityName.parent;
30608             }
30609             if (entityName.kind === 75 || entityName.parent.kind === 153) {
30610                 return resolveEntityName(entityName, 1920, false, dontResolveAlias);
30611             }
30612             else {
30613                 ts.Debug.assert(entityName.parent.kind === 253);
30614                 return resolveEntityName(entityName, 111551 | 788968 | 1920, false, dontResolveAlias);
30615             }
30616         }
30617         function getFullyQualifiedName(symbol, containingLocation) {
30618             return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, undefined, 16 | 4);
30619         }
30620         function resolveEntityName(name, meaning, ignoreErrors, dontResolveAlias, location) {
30621             if (ts.nodeIsMissing(name)) {
30622                 return undefined;
30623             }
30624             var namespaceMeaning = 1920 | (ts.isInJSFile(name) ? meaning & 111551 : 0);
30625             var symbol;
30626             if (name.kind === 75) {
30627                 var message = meaning === namespaceMeaning || ts.nodeIsSynthesized(name) ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name));
30628                 var symbolFromJSPrototype = ts.isInJSFile(name) && !ts.nodeIsSynthesized(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined;
30629                 symbol = getMergedSymbol(resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, true));
30630                 if (!symbol) {
30631                     return getMergedSymbol(symbolFromJSPrototype);
30632                 }
30633             }
30634             else if (name.kind === 153 || name.kind === 194) {
30635                 var left = name.kind === 153 ? name.left : name.expression;
30636                 var right = name.kind === 153 ? name.right : name.name;
30637                 var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, false, location);
30638                 if (!namespace || ts.nodeIsMissing(right)) {
30639                     return undefined;
30640                 }
30641                 else if (namespace === unknownSymbol) {
30642                     return namespace;
30643                 }
30644                 if (ts.isInJSFile(name)) {
30645                     if (namespace.valueDeclaration &&
30646                         ts.isVariableDeclaration(namespace.valueDeclaration) &&
30647                         namespace.valueDeclaration.initializer &&
30648                         isCommonJsRequire(namespace.valueDeclaration.initializer)) {
30649                         var moduleName = namespace.valueDeclaration.initializer.arguments[0];
30650                         var moduleSym = resolveExternalModuleName(moduleName, moduleName);
30651                         if (moduleSym) {
30652                             var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym);
30653                             if (resolvedModuleSymbol) {
30654                                 namespace = resolvedModuleSymbol;
30655                             }
30656                         }
30657                     }
30658                 }
30659                 symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, meaning));
30660                 if (!symbol) {
30661                     if (!ignoreErrors) {
30662                         error(right, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(namespace), ts.declarationNameToString(right));
30663                     }
30664                     return undefined;
30665                 }
30666             }
30667             else {
30668                 throw ts.Debug.assertNever(name, "Unknown entity name kind.");
30669             }
30670             ts.Debug.assert((ts.getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here.");
30671             if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 || name.parent.kind === 259)) {
30672                 markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, undefined, true);
30673             }
30674             return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol);
30675         }
30676         function resolveEntityNameFromAssignmentDeclaration(name, meaning) {
30677             if (isJSDocTypeReference(name.parent)) {
30678                 var secondaryLocation = getAssignmentDeclarationLocation(name.parent);
30679                 if (secondaryLocation) {
30680                     return resolveName(secondaryLocation, name.escapedText, meaning, undefined, name, true);
30681                 }
30682             }
30683         }
30684         function getAssignmentDeclarationLocation(node) {
30685             var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 4194304) ? "quit" : ts.isJSDocTypeAlias(node); });
30686             if (typeAlias) {
30687                 return;
30688             }
30689             var host = ts.getJSDocHost(node);
30690             if (ts.isExpressionStatement(host) &&
30691                 ts.isBinaryExpression(host.expression) &&
30692                 ts.getAssignmentDeclarationKind(host.expression) === 3) {
30693                 var symbol = getSymbolOfNode(host.expression.left);
30694                 if (symbol) {
30695                     return getDeclarationOfJSPrototypeContainer(symbol);
30696                 }
30697             }
30698             if ((ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) &&
30699                 ts.isBinaryExpression(host.parent.parent) &&
30700                 ts.getAssignmentDeclarationKind(host.parent.parent) === 6) {
30701                 var symbol = getSymbolOfNode(host.parent.parent.left);
30702                 if (symbol) {
30703                     return getDeclarationOfJSPrototypeContainer(symbol);
30704                 }
30705             }
30706             var sig = ts.getEffectiveJSDocHost(node);
30707             if (sig && ts.isFunctionLike(sig)) {
30708                 var symbol = getSymbolOfNode(sig);
30709                 return symbol && symbol.valueDeclaration;
30710             }
30711         }
30712         function getDeclarationOfJSPrototypeContainer(symbol) {
30713             var decl = symbol.parent.valueDeclaration;
30714             if (!decl) {
30715                 return undefined;
30716             }
30717             var initializer = ts.isAssignmentDeclaration(decl) ? ts.getAssignedExpandoInitializer(decl) :
30718                 ts.hasOnlyExpressionInitializer(decl) ? ts.getDeclaredExpandoInitializer(decl) :
30719                     undefined;
30720             return initializer || decl;
30721         }
30722         function getExpandoSymbol(symbol) {
30723             var decl = symbol.valueDeclaration;
30724             if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 || ts.getExpandoInitializer(decl, false)) {
30725                 return undefined;
30726             }
30727             var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl);
30728             if (init) {
30729                 var initSymbol = getSymbolOfNode(init);
30730                 if (initSymbol) {
30731                     return mergeJSSymbols(initSymbol, symbol);
30732                 }
30733             }
30734         }
30735         function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) {
30736             return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations);
30737         }
30738         function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError, isForAugmentation) {
30739             if (isForAugmentation === void 0) { isForAugmentation = false; }
30740             return ts.isStringLiteralLike(moduleReferenceExpression)
30741                 ? resolveExternalModule(location, moduleReferenceExpression.text, moduleNotFoundError, moduleReferenceExpression, isForAugmentation)
30742                 : undefined;
30743         }
30744         function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) {
30745             if (isForAugmentation === void 0) { isForAugmentation = false; }
30746             if (ts.startsWith(moduleReference, "@types/")) {
30747                 var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
30748                 var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/");
30749                 error(errorNode, diag, withoutAtTypePrefix, moduleReference);
30750             }
30751             var ambientModule = tryFindAmbientModule(moduleReference, true);
30752             if (ambientModule) {
30753                 return ambientModule;
30754             }
30755             var currentSourceFile = ts.getSourceFileOfNode(location);
30756             var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference);
30757             var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule);
30758             var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
30759             if (sourceFile) {
30760                 if (sourceFile.symbol) {
30761                     if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
30762                         errorOnImplicitAnyModule(false, errorNode, resolvedModule, moduleReference);
30763                     }
30764                     return getMergedSymbol(sourceFile.symbol);
30765                 }
30766                 if (moduleNotFoundError) {
30767                     error(errorNode, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName);
30768                 }
30769                 return undefined;
30770             }
30771             if (patternAmbientModules) {
30772                 var pattern = ts.findBestPatternMatch(patternAmbientModules, function (_) { return _.pattern; }, moduleReference);
30773                 if (pattern) {
30774                     var augmentation = patternAmbientModuleAugmentations && patternAmbientModuleAugmentations.get(moduleReference);
30775                     if (augmentation) {
30776                         return getMergedSymbol(augmentation);
30777                     }
30778                     return getMergedSymbol(pattern.symbol);
30779                 }
30780             }
30781             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) {
30782                 if (isForAugmentation) {
30783                     var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented;
30784                     error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName);
30785                 }
30786                 else {
30787                     errorOnImplicitAnyModule(noImplicitAny && !!moduleNotFoundError, errorNode, resolvedModule, moduleReference);
30788                 }
30789                 return undefined;
30790             }
30791             if (moduleNotFoundError) {
30792                 if (resolvedModule) {
30793                     var redirect = host.getProjectReferenceRedirect(resolvedModule.resolvedFileName);
30794                     if (redirect) {
30795                         error(errorNode, ts.Diagnostics.Output_file_0_has_not_been_built_from_source_file_1, redirect, resolvedModule.resolvedFileName);
30796                         return undefined;
30797                     }
30798                 }
30799                 if (resolutionDiagnostic) {
30800                     error(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName);
30801                 }
30802                 else {
30803                     var tsExtension = ts.tryExtractTSExtension(moduleReference);
30804                     if (tsExtension) {
30805                         var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead;
30806                         error(errorNode, diag, tsExtension, ts.removeExtension(moduleReference, tsExtension));
30807                     }
30808                     else if (!compilerOptions.resolveJsonModule &&
30809                         ts.fileExtensionIs(moduleReference, ".json") &&
30810                         ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs &&
30811                         ts.hasJsonModuleEmitEnabled(compilerOptions)) {
30812                         error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
30813                     }
30814                     else {
30815                         error(errorNode, moduleNotFoundError, moduleReference);
30816                     }
30817                 }
30818             }
30819             return undefined;
30820         }
30821         function errorOnImplicitAnyModule(isError, errorNode, _a, moduleReference) {
30822             var packageId = _a.packageId, resolvedFileName = _a.resolvedFileName;
30823             var errorInfo = !ts.isExternalModuleNameRelative(moduleReference) && packageId
30824                 ? typesPackageExists(packageId.name)
30825                     ? 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))
30826                     : 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))
30827                 : undefined;
30828             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));
30829         }
30830         function typesPackageExists(packageName) {
30831             return getPackagesSet().has(ts.getTypesPackageName(packageName));
30832         }
30833         function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) {
30834             if (moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.exports) {
30835                 var exportEquals = resolveSymbol(moduleSymbol.exports.get("export="), dontResolveAlias);
30836                 var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol));
30837                 return getMergedSymbol(exported) || moduleSymbol;
30838             }
30839             return undefined;
30840         }
30841         function getCommonJsExportEquals(exported, moduleSymbol) {
30842             if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152) {
30843                 return exported;
30844             }
30845             var links = getSymbolLinks(exported);
30846             if (links.cjsExportMerged) {
30847                 return links.cjsExportMerged;
30848             }
30849             var merged = exported.flags & 33554432 ? exported : cloneSymbol(exported);
30850             merged.flags = merged.flags | 512;
30851             if (merged.exports === undefined) {
30852                 merged.exports = ts.createSymbolTable();
30853             }
30854             moduleSymbol.exports.forEach(function (s, name) {
30855                 if (name === "export=")
30856                     return;
30857                 merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s);
30858             });
30859             getSymbolLinks(merged).cjsExportMerged = merged;
30860             return links.cjsExportMerged = merged;
30861         }
30862         function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) {
30863             var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias);
30864             if (!dontResolveAlias && symbol) {
30865                 if (!suppressInteropError && !(symbol.flags & (1536 | 3)) && !ts.getDeclarationOfKind(symbol, 290)) {
30866                     var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015
30867                         ? "allowSyntheticDefaultImports"
30868                         : "esModuleInterop";
30869                     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);
30870                     return symbol;
30871                 }
30872                 if (compilerOptions.esModuleInterop) {
30873                     var referenceParent = referencingLocation.parent;
30874                     if ((ts.isImportDeclaration(referenceParent) && ts.getNamespaceDeclarationNode(referenceParent)) ||
30875                         ts.isImportCall(referenceParent)) {
30876                         var type = getTypeOfSymbol(symbol);
30877                         var sigs = getSignaturesOfStructuredType(type, 0);
30878                         if (!sigs || !sigs.length) {
30879                             sigs = getSignaturesOfStructuredType(type, 1);
30880                         }
30881                         if (sigs && sigs.length) {
30882                             var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol);
30883                             var result = createSymbol(symbol.flags, symbol.escapedName);
30884                             result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
30885                             result.parent = symbol.parent;
30886                             result.target = symbol;
30887                             result.originatingImport = referenceParent;
30888                             if (symbol.valueDeclaration)
30889                                 result.valueDeclaration = symbol.valueDeclaration;
30890                             if (symbol.constEnumOnlyModule)
30891                                 result.constEnumOnlyModule = true;
30892                             if (symbol.members)
30893                                 result.members = ts.cloneMap(symbol.members);
30894                             if (symbol.exports)
30895                                 result.exports = ts.cloneMap(symbol.exports);
30896                             var resolvedModuleType = resolveStructuredTypeMembers(moduleType);
30897                             result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.stringIndexInfo, resolvedModuleType.numberIndexInfo);
30898                             return result;
30899                         }
30900                     }
30901                 }
30902             }
30903             return symbol;
30904         }
30905         function hasExportAssignmentSymbol(moduleSymbol) {
30906             return moduleSymbol.exports.get("export=") !== undefined;
30907         }
30908         function getExportsOfModuleAsArray(moduleSymbol) {
30909             return symbolsToArray(getExportsOfModule(moduleSymbol));
30910         }
30911         function getExportsAndPropertiesOfModule(moduleSymbol) {
30912             var exports = getExportsOfModuleAsArray(moduleSymbol);
30913             var exportEquals = resolveExternalModuleSymbol(moduleSymbol);
30914             if (exportEquals !== moduleSymbol) {
30915                 ts.addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals)));
30916             }
30917             return exports;
30918         }
30919         function tryGetMemberInModuleExports(memberName, moduleSymbol) {
30920             var symbolTable = getExportsOfModule(moduleSymbol);
30921             if (symbolTable) {
30922                 return symbolTable.get(memberName);
30923             }
30924         }
30925         function tryGetMemberInModuleExportsAndProperties(memberName, moduleSymbol) {
30926             var symbol = tryGetMemberInModuleExports(memberName, moduleSymbol);
30927             if (symbol) {
30928                 return symbol;
30929             }
30930             var exportEquals = resolveExternalModuleSymbol(moduleSymbol);
30931             if (exportEquals === moduleSymbol) {
30932                 return undefined;
30933             }
30934             var type = getTypeOfSymbol(exportEquals);
30935             return type.flags & 131068 ||
30936                 ts.getObjectFlags(type) & 1 ||
30937                 isArrayOrTupleLikeType(type)
30938                 ? undefined
30939                 : getPropertyOfType(type, memberName);
30940         }
30941         function getExportsOfSymbol(symbol) {
30942             return symbol.flags & 6256 ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports") :
30943                 symbol.flags & 1536 ? getExportsOfModule(symbol) :
30944                     symbol.exports || emptySymbols;
30945         }
30946         function getExportsOfModule(moduleSymbol) {
30947             var links = getSymbolLinks(moduleSymbol);
30948             return links.resolvedExports || (links.resolvedExports = getExportsOfModuleWorker(moduleSymbol));
30949         }
30950         function extendExportSymbols(target, source, lookupTable, exportNode) {
30951             if (!source)
30952                 return;
30953             source.forEach(function (sourceSymbol, id) {
30954                 if (id === "default")
30955                     return;
30956                 var targetSymbol = target.get(id);
30957                 if (!targetSymbol) {
30958                     target.set(id, sourceSymbol);
30959                     if (lookupTable && exportNode) {
30960                         lookupTable.set(id, {
30961                             specifierText: ts.getTextOfNode(exportNode.moduleSpecifier)
30962                         });
30963                     }
30964                 }
30965                 else if (lookupTable && exportNode && targetSymbol && resolveSymbol(targetSymbol) !== resolveSymbol(sourceSymbol)) {
30966                     var collisionTracker = lookupTable.get(id);
30967                     if (!collisionTracker.exportsWithDuplicate) {
30968                         collisionTracker.exportsWithDuplicate = [exportNode];
30969                     }
30970                     else {
30971                         collisionTracker.exportsWithDuplicate.push(exportNode);
30972                     }
30973                 }
30974             });
30975         }
30976         function getExportsOfModuleWorker(moduleSymbol) {
30977             var visitedSymbols = [];
30978             moduleSymbol = resolveExternalModuleSymbol(moduleSymbol);
30979             return visit(moduleSymbol) || emptySymbols;
30980             function visit(symbol) {
30981                 if (!(symbol && symbol.exports && ts.pushIfUnique(visitedSymbols, symbol))) {
30982                     return;
30983                 }
30984                 var symbols = ts.cloneMap(symbol.exports);
30985                 var exportStars = symbol.exports.get("__export");
30986                 if (exportStars) {
30987                     var nestedSymbols = ts.createSymbolTable();
30988                     var lookupTable_1 = ts.createMap();
30989                     for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) {
30990                         var node = _a[_i];
30991                         var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
30992                         var exportedSymbols = visit(resolvedModule);
30993                         extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node);
30994                     }
30995                     lookupTable_1.forEach(function (_a, id) {
30996                         var exportsWithDuplicate = _a.exportsWithDuplicate;
30997                         if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols.has(id)) {
30998                             return;
30999                         }
31000                         for (var _i = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _i < exportsWithDuplicate_1.length; _i++) {
31001                             var node = exportsWithDuplicate_1[_i];
31002                             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)));
31003                         }
31004                     });
31005                     extendExportSymbols(symbols, nestedSymbols);
31006                 }
31007                 return symbols;
31008             }
31009         }
31010         function getMergedSymbol(symbol) {
31011             var merged;
31012             return symbol && symbol.mergeId && (merged = mergedSymbols[symbol.mergeId]) ? merged : symbol;
31013         }
31014         function getSymbolOfNode(node) {
31015             return getMergedSymbol(node.symbol && getLateBoundSymbol(node.symbol));
31016         }
31017         function getParentOfSymbol(symbol) {
31018             return getMergedSymbol(symbol.parent && getLateBoundSymbol(symbol.parent));
31019         }
31020         function getAlternativeContainingModules(symbol, enclosingDeclaration) {
31021             var containingFile = ts.getSourceFileOfNode(enclosingDeclaration);
31022             var id = "" + getNodeId(containingFile);
31023             var links = getSymbolLinks(symbol);
31024             var results;
31025             if (links.extendedContainersByFile && (results = links.extendedContainersByFile.get(id))) {
31026                 return results;
31027             }
31028             if (containingFile && containingFile.imports) {
31029                 for (var _i = 0, _a = containingFile.imports; _i < _a.length; _i++) {
31030                     var importRef = _a[_i];
31031                     if (ts.nodeIsSynthesized(importRef))
31032                         continue;
31033                     var resolvedModule = resolveExternalModuleName(enclosingDeclaration, importRef, true);
31034                     if (!resolvedModule)
31035                         continue;
31036                     var ref = getAliasForSymbolInContainer(resolvedModule, symbol);
31037                     if (!ref)
31038                         continue;
31039                     results = ts.append(results, resolvedModule);
31040                 }
31041                 if (ts.length(results)) {
31042                     (links.extendedContainersByFile || (links.extendedContainersByFile = ts.createMap())).set(id, results);
31043                     return results;
31044                 }
31045             }
31046             if (links.extendedContainers) {
31047                 return links.extendedContainers;
31048             }
31049             var otherFiles = host.getSourceFiles();
31050             for (var _b = 0, otherFiles_1 = otherFiles; _b < otherFiles_1.length; _b++) {
31051                 var file = otherFiles_1[_b];
31052                 if (!ts.isExternalModule(file))
31053                     continue;
31054                 var sym = getSymbolOfNode(file);
31055                 var ref = getAliasForSymbolInContainer(sym, symbol);
31056                 if (!ref)
31057                     continue;
31058                 results = ts.append(results, sym);
31059             }
31060             return links.extendedContainers = results || ts.emptyArray;
31061         }
31062         function getContainersOfSymbol(symbol, enclosingDeclaration) {
31063             var container = getParentOfSymbol(symbol);
31064             if (container && !(symbol.flags & 262144)) {
31065                 var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer);
31066                 var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
31067                 if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920, false)) {
31068                     return ts.concatenate(ts.concatenate([container], additionalContainers), reexportContainers);
31069                 }
31070                 var res = ts.append(additionalContainers, container);
31071                 return ts.concatenate(res, reexportContainers);
31072             }
31073             var candidates = ts.mapDefined(symbol.declarations, function (d) {
31074                 if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) {
31075                     return getSymbolOfNode(d.parent);
31076                 }
31077                 if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) {
31078                     if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) {
31079                         return getSymbolOfNode(ts.getSourceFileOfNode(d));
31080                     }
31081                     checkExpressionCached(d.parent.left.expression);
31082                     return getNodeLinks(d.parent.left.expression).resolvedSymbol;
31083                 }
31084             });
31085             if (!ts.length(candidates)) {
31086                 return undefined;
31087             }
31088             return ts.mapDefined(candidates, function (candidate) { return getAliasForSymbolInContainer(candidate, symbol) ? candidate : undefined; });
31089             function fileSymbolIfFileSymbolExportEqualsContainer(d) {
31090                 return container && getFileSymbolIfFileSymbolExportEqualsContainer(d, container);
31091             }
31092         }
31093         function getFileSymbolIfFileSymbolExportEqualsContainer(d, container) {
31094             var fileSymbol = getExternalModuleContainer(d);
31095             var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=");
31096             return exported && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined;
31097         }
31098         function getAliasForSymbolInContainer(container, symbol) {
31099             if (container === getParentOfSymbol(symbol)) {
31100                 return symbol;
31101             }
31102             var exportEquals = container.exports && container.exports.get("export=");
31103             if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) {
31104                 return container;
31105             }
31106             var exports = getExportsOfSymbol(container);
31107             var quick = exports.get(symbol.escapedName);
31108             if (quick && getSymbolIfSameReference(quick, symbol)) {
31109                 return quick;
31110             }
31111             return ts.forEachEntry(exports, function (exported) {
31112                 if (getSymbolIfSameReference(exported, symbol)) {
31113                     return exported;
31114                 }
31115             });
31116         }
31117         function getSymbolIfSameReference(s1, s2) {
31118             if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) {
31119                 return s1;
31120             }
31121         }
31122         function getExportSymbolOfValueSymbolIfExported(symbol) {
31123             return getMergedSymbol(symbol && (symbol.flags & 1048576) !== 0 ? symbol.exportSymbol : symbol);
31124         }
31125         function symbolIsValue(symbol) {
31126             return !!(symbol.flags & 111551 || symbol.flags & 2097152 && resolveAlias(symbol).flags & 111551 && !getTypeOnlyAliasDeclaration(symbol));
31127         }
31128         function findConstructorDeclaration(node) {
31129             var members = node.members;
31130             for (var _i = 0, members_3 = members; _i < members_3.length; _i++) {
31131                 var member = members_3[_i];
31132                 if (member.kind === 162 && ts.nodeIsPresent(member.body)) {
31133                     return member;
31134                 }
31135             }
31136         }
31137         function createType(flags) {
31138             var result = new Type(checker, flags);
31139             typeCount++;
31140             result.id = typeCount;
31141             return result;
31142         }
31143         function createIntrinsicType(kind, intrinsicName, objectFlags) {
31144             if (objectFlags === void 0) { objectFlags = 0; }
31145             var type = createType(kind);
31146             type.intrinsicName = intrinsicName;
31147             type.objectFlags = objectFlags;
31148             return type;
31149         }
31150         function createBooleanType(trueFalseTypes) {
31151             var type = getUnionType(trueFalseTypes);
31152             type.flags |= 16;
31153             type.intrinsicName = "boolean";
31154             return type;
31155         }
31156         function createObjectType(objectFlags, symbol) {
31157             var type = createType(524288);
31158             type.objectFlags = objectFlags;
31159             type.symbol = symbol;
31160             type.members = undefined;
31161             type.properties = undefined;
31162             type.callSignatures = undefined;
31163             type.constructSignatures = undefined;
31164             type.stringIndexInfo = undefined;
31165             type.numberIndexInfo = undefined;
31166             return type;
31167         }
31168         function createTypeofType() {
31169             return getUnionType(ts.arrayFrom(typeofEQFacts.keys(), getLiteralType));
31170         }
31171         function createTypeParameter(symbol) {
31172             var type = createType(262144);
31173             if (symbol)
31174                 type.symbol = symbol;
31175             return type;
31176         }
31177         function isReservedMemberName(name) {
31178             return name.charCodeAt(0) === 95 &&
31179                 name.charCodeAt(1) === 95 &&
31180                 name.charCodeAt(2) !== 95 &&
31181                 name.charCodeAt(2) !== 64 &&
31182                 name.charCodeAt(2) !== 35;
31183         }
31184         function getNamedMembers(members) {
31185             var result;
31186             members.forEach(function (symbol, id) {
31187                 if (!isReservedMemberName(id) && symbolIsValue(symbol)) {
31188                     (result || (result = [])).push(symbol);
31189                 }
31190             });
31191             return result || ts.emptyArray;
31192         }
31193         function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) {
31194             type.members = members;
31195             type.properties = members === emptySymbols ? ts.emptyArray : getNamedMembers(members);
31196             type.callSignatures = callSignatures;
31197             type.constructSignatures = constructSignatures;
31198             type.stringIndexInfo = stringIndexInfo;
31199             type.numberIndexInfo = numberIndexInfo;
31200             return type;
31201         }
31202         function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) {
31203             return setStructuredTypeMembers(createObjectType(16, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
31204         }
31205         function forEachSymbolTableInScope(enclosingDeclaration, callback) {
31206             var result;
31207             var _loop_7 = function (location) {
31208                 if (location.locals && !isGlobalSourceFile(location)) {
31209                     if (result = callback(location.locals)) {
31210                         return { value: result };
31211                     }
31212                 }
31213                 switch (location.kind) {
31214                     case 290:
31215                         if (!ts.isExternalOrCommonJsModule(location)) {
31216                             break;
31217                         }
31218                     case 249:
31219                         var sym = getSymbolOfNode(location);
31220                         if (result = callback((sym === null || sym === void 0 ? void 0 : sym.exports) || emptySymbols)) {
31221                             return { value: result };
31222                         }
31223                         break;
31224                     case 245:
31225                     case 214:
31226                     case 246:
31227                         var table_1;
31228                         (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) {
31229                             if (memberSymbol.flags & (788968 & ~67108864)) {
31230                                 (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol);
31231                             }
31232                         });
31233                         if (table_1 && (result = callback(table_1))) {
31234                             return { value: result };
31235                         }
31236                         break;
31237                 }
31238             };
31239             for (var location = enclosingDeclaration; location; location = location.parent) {
31240                 var state_2 = _loop_7(location);
31241                 if (typeof state_2 === "object")
31242                     return state_2.value;
31243             }
31244             return callback(globals);
31245         }
31246         function getQualifiedLeftMeaning(rightMeaning) {
31247             return rightMeaning === 111551 ? 111551 : 1920;
31248         }
31249         function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) {
31250             if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = ts.createMap(); }
31251             if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) {
31252                 return undefined;
31253             }
31254             var id = "" + getSymbolId(symbol);
31255             var visitedSymbolTables = visitedSymbolTablesMap.get(id);
31256             if (!visitedSymbolTables) {
31257                 visitedSymbolTablesMap.set(id, visitedSymbolTables = []);
31258             }
31259             return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable);
31260             function getAccessibleSymbolChainFromSymbolTable(symbols, ignoreQualification) {
31261                 if (!ts.pushIfUnique(visitedSymbolTables, symbols)) {
31262                     return undefined;
31263                 }
31264                 var result = trySymbolTable(symbols, ignoreQualification);
31265                 visitedSymbolTables.pop();
31266                 return result;
31267             }
31268             function canQualifySymbol(symbolFromSymbolTable, meaning) {
31269                 return !needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning) ||
31270                     !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing, visitedSymbolTablesMap);
31271             }
31272             function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol, ignoreQualification) {
31273                 return (symbol === (resolvedAliasSymbol || symbolFromSymbolTable) || getMergedSymbol(symbol) === getMergedSymbol(resolvedAliasSymbol || symbolFromSymbolTable)) &&
31274                     !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) &&
31275                     (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning));
31276             }
31277             function trySymbolTable(symbols, ignoreQualification) {
31278                 if (isAccessible(symbols.get(symbol.escapedName), undefined, ignoreQualification)) {
31279                     return [symbol];
31280                 }
31281                 var result = ts.forEachEntry(symbols, function (symbolFromSymbolTable) {
31282                     if (symbolFromSymbolTable.flags & 2097152
31283                         && symbolFromSymbolTable.escapedName !== "export="
31284                         && symbolFromSymbolTable.escapedName !== "default"
31285                         && !(ts.isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration)))
31286                         && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration))
31287                         && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 263))) {
31288                         var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable);
31289                         var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification);
31290                         if (candidate) {
31291                             return candidate;
31292                         }
31293                     }
31294                     if (symbolFromSymbolTable.escapedName === symbol.escapedName && symbolFromSymbolTable.exportSymbol) {
31295                         if (isAccessible(getMergedSymbol(symbolFromSymbolTable.exportSymbol), undefined, ignoreQualification)) {
31296                             return [symbol];
31297                         }
31298                     }
31299                 });
31300                 return result || (symbols === globals ? getCandidateListForSymbol(globalThisSymbol, globalThisSymbol, ignoreQualification) : undefined);
31301             }
31302             function getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification) {
31303                 if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) {
31304                     return [symbolFromSymbolTable];
31305                 }
31306                 var candidateTable = getExportsOfSymbol(resolvedImportedSymbol);
31307                 var accessibleSymbolsFromExports = candidateTable && getAccessibleSymbolChainFromSymbolTable(candidateTable, true);
31308                 if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) {
31309                     return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports);
31310                 }
31311             }
31312         }
31313         function needsQualification(symbol, enclosingDeclaration, meaning) {
31314             var qualify = false;
31315             forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) {
31316                 var symbolFromSymbolTable = getMergedSymbol(symbolTable.get(symbol.escapedName));
31317                 if (!symbolFromSymbolTable) {
31318                     return false;
31319                 }
31320                 if (symbolFromSymbolTable === symbol) {
31321                     return true;
31322                 }
31323                 symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 263)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
31324                 if (symbolFromSymbolTable.flags & meaning) {
31325                     qualify = true;
31326                     return true;
31327                 }
31328                 return false;
31329             });
31330             return qualify;
31331         }
31332         function isPropertyOrMethodDeclarationSymbol(symbol) {
31333             if (symbol.declarations && symbol.declarations.length) {
31334                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
31335                     var declaration = _a[_i];
31336                     switch (declaration.kind) {
31337                         case 159:
31338                         case 161:
31339                         case 163:
31340                         case 164:
31341                             continue;
31342                         default:
31343                             return false;
31344                     }
31345                 }
31346                 return true;
31347             }
31348             return false;
31349         }
31350         function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) {
31351             var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 788968, false);
31352             return access.accessibility === 0;
31353         }
31354         function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) {
31355             var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 111551, false);
31356             return access.accessibility === 0;
31357         }
31358         function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible) {
31359             if (!ts.length(symbols))
31360                 return;
31361             var hadAccessibleChain;
31362             var earlyModuleBail = false;
31363             for (var _i = 0, _a = symbols; _i < _a.length; _i++) {
31364                 var symbol = _a[_i];
31365                 var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, false);
31366                 if (accessibleSymbolChain) {
31367                     hadAccessibleChain = symbol;
31368                     var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0], shouldComputeAliasesToMakeVisible);
31369                     if (hasAccessibleDeclarations) {
31370                         return hasAccessibleDeclarations;
31371                     }
31372                 }
31373                 else {
31374                     if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
31375                         if (shouldComputeAliasesToMakeVisible) {
31376                             earlyModuleBail = true;
31377                             continue;
31378                         }
31379                         return {
31380                             accessibility: 0
31381                         };
31382                     }
31383                 }
31384                 var containers = getContainersOfSymbol(symbol, enclosingDeclaration);
31385                 var firstDecl = !!ts.length(symbol.declarations) && ts.first(symbol.declarations);
31386                 if (!ts.length(containers) && meaning & 111551 && firstDecl && ts.isObjectLiteralExpression(firstDecl)) {
31387                     if (firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent) && firstDecl === firstDecl.parent.initializer) {
31388                         containers = [getSymbolOfNode(firstDecl.parent)];
31389                     }
31390                 }
31391                 var parentResult = isAnySymbolAccessible(containers, enclosingDeclaration, initialSymbol, initialSymbol === symbol ? getQualifiedLeftMeaning(meaning) : meaning, shouldComputeAliasesToMakeVisible);
31392                 if (parentResult) {
31393                     return parentResult;
31394                 }
31395             }
31396             if (earlyModuleBail) {
31397                 return {
31398                     accessibility: 0
31399                 };
31400             }
31401             if (hadAccessibleChain) {
31402                 return {
31403                     accessibility: 1,
31404                     errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
31405                     errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920) : undefined,
31406                 };
31407             }
31408         }
31409         function isSymbolAccessible(symbol, enclosingDeclaration, meaning, shouldComputeAliasesToMakeVisible) {
31410             if (symbol && enclosingDeclaration) {
31411                 var result = isAnySymbolAccessible([symbol], enclosingDeclaration, symbol, meaning, shouldComputeAliasesToMakeVisible);
31412                 if (result) {
31413                     return result;
31414                 }
31415                 var symbolExternalModule = ts.forEach(symbol.declarations, getExternalModuleContainer);
31416                 if (symbolExternalModule) {
31417                     var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration);
31418                     if (symbolExternalModule !== enclosingExternalModule) {
31419                         return {
31420                             accessibility: 2,
31421                             errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning),
31422                             errorModuleName: symbolToString(symbolExternalModule)
31423                         };
31424                     }
31425                 }
31426                 return {
31427                     accessibility: 1,
31428                     errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning),
31429                 };
31430             }
31431             return { accessibility: 0 };
31432         }
31433         function getExternalModuleContainer(declaration) {
31434             var node = ts.findAncestor(declaration, hasExternalModuleSymbol);
31435             return node && getSymbolOfNode(node);
31436         }
31437         function hasExternalModuleSymbol(declaration) {
31438             return ts.isAmbientModule(declaration) || (declaration.kind === 290 && ts.isExternalOrCommonJsModule(declaration));
31439         }
31440         function hasNonGlobalAugmentationExternalModuleSymbol(declaration) {
31441             return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 290 && ts.isExternalOrCommonJsModule(declaration));
31442         }
31443         function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) {
31444             var aliasesToMakeVisible;
31445             if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 75; }), getIsDeclarationVisible)) {
31446                 return undefined;
31447             }
31448             return { accessibility: 0, aliasesToMakeVisible: aliasesToMakeVisible };
31449             function getIsDeclarationVisible(declaration) {
31450                 if (!isDeclarationVisible(declaration)) {
31451                     var anyImportSyntax = getAnyImportSyntax(declaration);
31452                     if (anyImportSyntax &&
31453                         !ts.hasModifier(anyImportSyntax, 1) &&
31454                         isDeclarationVisible(anyImportSyntax.parent)) {
31455                         return addVisibleAlias(declaration, anyImportSyntax);
31456                     }
31457                     else if (ts.isVariableDeclaration(declaration) && ts.isVariableStatement(declaration.parent.parent) &&
31458                         !ts.hasModifier(declaration.parent.parent, 1) &&
31459                         isDeclarationVisible(declaration.parent.parent.parent)) {
31460                         return addVisibleAlias(declaration, declaration.parent.parent);
31461                     }
31462                     else if (ts.isLateVisibilityPaintedStatement(declaration)
31463                         && !ts.hasModifier(declaration, 1)
31464                         && isDeclarationVisible(declaration.parent)) {
31465                         return addVisibleAlias(declaration, declaration);
31466                     }
31467                     return false;
31468                 }
31469                 return true;
31470             }
31471             function addVisibleAlias(declaration, aliasingStatement) {
31472                 if (shouldComputeAliasToMakeVisible) {
31473                     getNodeLinks(declaration).isVisible = true;
31474                     aliasesToMakeVisible = ts.appendIfUnique(aliasesToMakeVisible, aliasingStatement);
31475                 }
31476                 return true;
31477             }
31478         }
31479         function isEntityNameVisible(entityName, enclosingDeclaration) {
31480             var meaning;
31481             if (entityName.parent.kind === 172 ||
31482                 ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) ||
31483                 entityName.parent.kind === 154) {
31484                 meaning = 111551 | 1048576;
31485             }
31486             else if (entityName.kind === 153 || entityName.kind === 194 ||
31487                 entityName.parent.kind === 253) {
31488                 meaning = 1920;
31489             }
31490             else {
31491                 meaning = 788968;
31492             }
31493             var firstIdentifier = ts.getFirstIdentifier(entityName);
31494             var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, undefined, undefined, false);
31495             return (symbol && hasVisibleDeclarations(symbol, true)) || {
31496                 accessibility: 1,
31497                 errorSymbolName: ts.getTextOfNode(firstIdentifier),
31498                 errorNode: firstIdentifier
31499             };
31500         }
31501         function symbolToString(symbol, enclosingDeclaration, meaning, flags, writer) {
31502             if (flags === void 0) { flags = 4; }
31503             var nodeFlags = 70221824;
31504             if (flags & 2) {
31505                 nodeFlags |= 128;
31506             }
31507             if (flags & 1) {
31508                 nodeFlags |= 512;
31509             }
31510             if (flags & 8) {
31511                 nodeFlags |= 16384;
31512             }
31513             if (flags & 16) {
31514                 nodeFlags |= 134217728;
31515             }
31516             var builder = flags & 4 ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName;
31517             return writer ? symbolToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(symbolToStringWorker);
31518             function symbolToStringWorker(writer) {
31519                 var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags);
31520                 var printer = ts.createPrinter({ removeComments: true });
31521                 var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
31522                 printer.writeNode(4, entity, sourceFile, writer);
31523                 return writer;
31524             }
31525         }
31526         function signatureToString(signature, enclosingDeclaration, flags, kind, writer) {
31527             if (flags === void 0) { flags = 0; }
31528             return writer ? signatureToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(signatureToStringWorker);
31529             function signatureToStringWorker(writer) {
31530                 var sigOutput;
31531                 if (flags & 262144) {
31532                     sigOutput = kind === 1 ? 171 : 170;
31533                 }
31534                 else {
31535                     sigOutput = kind === 1 ? 166 : 165;
31536                 }
31537                 var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | 512);
31538                 var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
31539                 var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
31540                 printer.writeNode(4, sig, sourceFile, ts.getTrailingSemicolonDeferringWriter(writer));
31541                 return writer;
31542             }
31543         }
31544         function typeToString(type, enclosingDeclaration, flags, writer) {
31545             if (flags === void 0) { flags = 1048576 | 16384; }
31546             if (writer === void 0) { writer = ts.createTextWriter(""); }
31547             var noTruncation = compilerOptions.noErrorTruncation || flags & 1;
31548             var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | (noTruncation ? 1 : 0), writer);
31549             if (typeNode === undefined)
31550                 return ts.Debug.fail("should always get typenode");
31551             var options = { removeComments: true };
31552             var printer = ts.createPrinter(options);
31553             var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
31554             printer.writeNode(4, typeNode, sourceFile, writer);
31555             var result = writer.getText();
31556             var maxLength = noTruncation ? ts.noTruncationMaximumTruncationLength * 2 : ts.defaultMaximumTruncationLength * 2;
31557             if (maxLength && result && result.length >= maxLength) {
31558                 return result.substr(0, maxLength - "...".length) + "...";
31559             }
31560             return result;
31561         }
31562         function getTypeNamesForErrorDisplay(left, right) {
31563             var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left);
31564             var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right);
31565             if (leftStr === rightStr) {
31566                 leftStr = typeToString(left, undefined, 64);
31567                 rightStr = typeToString(right, undefined, 64);
31568             }
31569             return [leftStr, rightStr];
31570         }
31571         function symbolValueDeclarationIsContextSensitive(symbol) {
31572             return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration);
31573         }
31574         function toNodeBuilderFlags(flags) {
31575             if (flags === void 0) { flags = 0; }
31576             return flags & 814775659;
31577         }
31578         function createNodeBuilder() {
31579             return {
31580                 typeToTypeNode: function (type, enclosingDeclaration, flags, tracker) {
31581                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeToTypeNodeHelper(type, context); });
31582                 },
31583                 indexInfoToIndexSignatureDeclaration: function (indexInfo, kind, enclosingDeclaration, flags, tracker) {
31584                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); });
31585                 },
31586                 signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags, tracker) {
31587                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return signatureToSignatureDeclarationHelper(signature, kind, context); });
31588                 },
31589                 symbolToEntityName: function (symbol, meaning, enclosingDeclaration, flags, tracker) {
31590                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToName(symbol, context, meaning, false); });
31591                 },
31592                 symbolToExpression: function (symbol, meaning, enclosingDeclaration, flags, tracker) {
31593                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToExpression(symbol, context, meaning); });
31594                 },
31595                 symbolToTypeParameterDeclarations: function (symbol, enclosingDeclaration, flags, tracker) {
31596                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParametersToTypeParameterDeclarations(symbol, context); });
31597                 },
31598                 symbolToParameterDeclaration: function (symbol, enclosingDeclaration, flags, tracker) {
31599                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToParameterDeclaration(symbol, context); });
31600                 },
31601                 typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) {
31602                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); });
31603                 },
31604                 symbolTableToDeclarationStatements: function (symbolTable, enclosingDeclaration, flags, tracker, bundled) {
31605                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolTableToDeclarationStatements(symbolTable, context, bundled); });
31606                 },
31607             };
31608             function withContext(enclosingDeclaration, flags, tracker, cb) {
31609                 ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0);
31610                 var context = {
31611                     enclosingDeclaration: enclosingDeclaration,
31612                     flags: flags || 0,
31613                     tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 ? {
31614                             getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; },
31615                             getSourceFiles: function () { return host.getSourceFiles(); },
31616                             getCurrentDirectory: function () { return host.getCurrentDirectory(); },
31617                             getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks),
31618                             useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames),
31619                             redirectTargetsMap: host.redirectTargetsMap,
31620                             getProjectReferenceRedirect: function (fileName) { return host.getProjectReferenceRedirect(fileName); },
31621                             isSourceOfProjectReferenceRedirect: function (fileName) { return host.isSourceOfProjectReferenceRedirect(fileName); },
31622                             fileExists: function (fileName) { return host.fileExists(fileName); },
31623                         } : undefined },
31624                     encounteredError: false,
31625                     visitedTypes: undefined,
31626                     symbolDepth: undefined,
31627                     inferTypeParameters: undefined,
31628                     approximateLength: 0
31629                 };
31630                 var resultingNode = cb(context);
31631                 return context.encounteredError ? undefined : resultingNode;
31632             }
31633             function checkTruncationLength(context) {
31634                 if (context.truncating)
31635                     return context.truncating;
31636                 return context.truncating = context.approximateLength > ((context.flags & 1) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength);
31637             }
31638             function typeToTypeNodeHelper(type, context) {
31639                 if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
31640                     cancellationToken.throwIfCancellationRequested();
31641                 }
31642                 var inTypeAlias = context.flags & 8388608;
31643                 context.flags &= ~8388608;
31644                 if (!type) {
31645                     if (!(context.flags & 262144)) {
31646                         context.encounteredError = true;
31647                         return undefined;
31648                     }
31649                     context.approximateLength += 3;
31650                     return ts.createKeywordTypeNode(125);
31651                 }
31652                 if (!(context.flags & 536870912)) {
31653                     type = getReducedType(type);
31654                 }
31655                 if (type.flags & 1) {
31656                     context.approximateLength += 3;
31657                     return ts.createKeywordTypeNode(125);
31658                 }
31659                 if (type.flags & 2) {
31660                     return ts.createKeywordTypeNode(148);
31661                 }
31662                 if (type.flags & 4) {
31663                     context.approximateLength += 6;
31664                     return ts.createKeywordTypeNode(143);
31665                 }
31666                 if (type.flags & 8) {
31667                     context.approximateLength += 6;
31668                     return ts.createKeywordTypeNode(140);
31669                 }
31670                 if (type.flags & 64) {
31671                     context.approximateLength += 6;
31672                     return ts.createKeywordTypeNode(151);
31673                 }
31674                 if (type.flags & 16) {
31675                     context.approximateLength += 7;
31676                     return ts.createKeywordTypeNode(128);
31677                 }
31678                 if (type.flags & 1024 && !(type.flags & 1048576)) {
31679                     var parentSymbol = getParentOfSymbol(type.symbol);
31680                     var parentName = symbolToTypeNode(parentSymbol, context, 788968);
31681                     var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type
31682                         ? parentName
31683                         : appendReferenceToType(parentName, ts.createTypeReferenceNode(ts.symbolName(type.symbol), undefined));
31684                     return enumLiteralName;
31685                 }
31686                 if (type.flags & 1056) {
31687                     return symbolToTypeNode(type.symbol, context, 788968);
31688                 }
31689                 if (type.flags & 128) {
31690                     context.approximateLength += (type.value.length + 2);
31691                     return ts.createLiteralTypeNode(ts.setEmitFlags(ts.createLiteral(type.value, !!(context.flags & 268435456)), 16777216));
31692                 }
31693                 if (type.flags & 256) {
31694                     var value = type.value;
31695                     context.approximateLength += ("" + value).length;
31696                     return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(40, ts.createLiteral(-value)) : ts.createLiteral(value));
31697                 }
31698                 if (type.flags & 2048) {
31699                     context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1;
31700                     return ts.createLiteralTypeNode((ts.createLiteral(type.value)));
31701                 }
31702                 if (type.flags & 512) {
31703                     context.approximateLength += type.intrinsicName.length;
31704                     return type.intrinsicName === "true" ? ts.createTrue() : ts.createFalse();
31705                 }
31706                 if (type.flags & 8192) {
31707                     if (!(context.flags & 1048576)) {
31708                         if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
31709                             context.approximateLength += 6;
31710                             return symbolToTypeNode(type.symbol, context, 111551);
31711                         }
31712                         if (context.tracker.reportInaccessibleUniqueSymbolError) {
31713                             context.tracker.reportInaccessibleUniqueSymbolError();
31714                         }
31715                     }
31716                     context.approximateLength += 13;
31717                     return ts.createTypeOperatorNode(147, ts.createKeywordTypeNode(144));
31718                 }
31719                 if (type.flags & 16384) {
31720                     context.approximateLength += 4;
31721                     return ts.createKeywordTypeNode(110);
31722                 }
31723                 if (type.flags & 32768) {
31724                     context.approximateLength += 9;
31725                     return ts.createKeywordTypeNode(146);
31726                 }
31727                 if (type.flags & 65536) {
31728                     context.approximateLength += 4;
31729                     return ts.createKeywordTypeNode(100);
31730                 }
31731                 if (type.flags & 131072) {
31732                     context.approximateLength += 5;
31733                     return ts.createKeywordTypeNode(137);
31734                 }
31735                 if (type.flags & 4096) {
31736                     context.approximateLength += 6;
31737                     return ts.createKeywordTypeNode(144);
31738                 }
31739                 if (type.flags & 67108864) {
31740                     context.approximateLength += 6;
31741                     return ts.createKeywordTypeNode(141);
31742                 }
31743                 if (isThisTypeParameter(type)) {
31744                     if (context.flags & 4194304) {
31745                         if (!context.encounteredError && !(context.flags & 32768)) {
31746                             context.encounteredError = true;
31747                         }
31748                         if (context.tracker.reportInaccessibleThisError) {
31749                             context.tracker.reportInaccessibleThisError();
31750                         }
31751                     }
31752                     context.approximateLength += 4;
31753                     return ts.createThis();
31754                 }
31755                 if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
31756                     var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
31757                     if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32))
31758                         return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes);
31759                     return symbolToTypeNode(type.aliasSymbol, context, 788968, typeArgumentNodes);
31760                 }
31761                 var objectFlags = ts.getObjectFlags(type);
31762                 if (objectFlags & 4) {
31763                     ts.Debug.assert(!!(type.flags & 524288));
31764                     return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type);
31765                 }
31766                 if (type.flags & 262144 || objectFlags & 3) {
31767                     if (type.flags & 262144 && ts.contains(context.inferTypeParameters, type)) {
31768                         context.approximateLength += (ts.symbolName(type.symbol).length + 6);
31769                         return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, undefined));
31770                     }
31771                     if (context.flags & 4 &&
31772                         type.flags & 262144 &&
31773                         !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
31774                         var name = typeParameterToName(type, context);
31775                         context.approximateLength += ts.idText(name).length;
31776                         return ts.createTypeReferenceNode(ts.createIdentifier(ts.idText(name)), undefined);
31777                     }
31778                     return type.symbol
31779                         ? symbolToTypeNode(type.symbol, context, 788968)
31780                         : ts.createTypeReferenceNode(ts.createIdentifier("?"), undefined);
31781                 }
31782                 if (type.flags & (1048576 | 2097152)) {
31783                     var types = type.flags & 1048576 ? formatUnionTypes(type.types) : type.types;
31784                     if (ts.length(types) === 1) {
31785                         return typeToTypeNodeHelper(types[0], context);
31786                     }
31787                     var typeNodes = mapToTypeNodes(types, context, true);
31788                     if (typeNodes && typeNodes.length > 0) {
31789                         var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 ? 178 : 179, typeNodes);
31790                         return unionOrIntersectionTypeNode;
31791                     }
31792                     else {
31793                         if (!context.encounteredError && !(context.flags & 262144)) {
31794                             context.encounteredError = true;
31795                         }
31796                         return undefined;
31797                     }
31798                 }
31799                 if (objectFlags & (16 | 32)) {
31800                     ts.Debug.assert(!!(type.flags & 524288));
31801                     return createAnonymousTypeNode(type);
31802                 }
31803                 if (type.flags & 4194304) {
31804                     var indexedType = type.type;
31805                     context.approximateLength += 6;
31806                     var indexTypeNode = typeToTypeNodeHelper(indexedType, context);
31807                     return ts.createTypeOperatorNode(indexTypeNode);
31808                 }
31809                 if (type.flags & 8388608) {
31810                     var objectTypeNode = typeToTypeNodeHelper(type.objectType, context);
31811                     var indexTypeNode = typeToTypeNodeHelper(type.indexType, context);
31812                     context.approximateLength += 2;
31813                     return ts.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode);
31814                 }
31815                 if (type.flags & 16777216) {
31816                     var checkTypeNode = typeToTypeNodeHelper(type.checkType, context);
31817                     var saveInferTypeParameters = context.inferTypeParameters;
31818                     context.inferTypeParameters = type.root.inferTypeParameters;
31819                     var extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context);
31820                     context.inferTypeParameters = saveInferTypeParameters;
31821                     var trueTypeNode = typeToTypeNodeHelper(getTrueTypeFromConditionalType(type), context);
31822                     var falseTypeNode = typeToTypeNodeHelper(getFalseTypeFromConditionalType(type), context);
31823                     context.approximateLength += 15;
31824                     return ts.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode);
31825                 }
31826                 if (type.flags & 33554432) {
31827                     return typeToTypeNodeHelper(type.baseType, context);
31828                 }
31829                 return ts.Debug.fail("Should be unreachable.");
31830                 function createMappedTypeNodeFromType(type) {
31831                     ts.Debug.assert(!!(type.flags & 524288));
31832                     var readonlyToken = type.declaration.readonlyToken ? ts.createToken(type.declaration.readonlyToken.kind) : undefined;
31833                     var questionToken = type.declaration.questionToken ? ts.createToken(type.declaration.questionToken.kind) : undefined;
31834                     var appropriateConstraintTypeNode;
31835                     if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
31836                         appropriateConstraintTypeNode = ts.createTypeOperatorNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context));
31837                     }
31838                     else {
31839                         appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context);
31840                     }
31841                     var typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode);
31842                     var templateTypeNode = typeToTypeNodeHelper(getTemplateTypeFromMappedType(type), context);
31843                     var mappedTypeNode = ts.createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode);
31844                     context.approximateLength += 10;
31845                     return ts.setEmitFlags(mappedTypeNode, 1);
31846                 }
31847                 function createAnonymousTypeNode(type) {
31848                     var typeId = "" + type.id;
31849                     var symbol = type.symbol;
31850                     if (symbol) {
31851                         if (isJSConstructor(symbol.valueDeclaration)) {
31852                             var isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? 788968 : 111551;
31853                             return symbolToTypeNode(symbol, context, isInstanceType);
31854                         }
31855                         else if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 214 && context.flags & 2048) ||
31856                             symbol.flags & (384 | 512) ||
31857                             shouldWriteTypeOfFunctionSymbol()) {
31858                             return symbolToTypeNode(symbol, context, 111551);
31859                         }
31860                         else if (context.visitedTypes && context.visitedTypes.has(typeId)) {
31861                             var typeAlias = getTypeAliasForTypeLiteral(type);
31862                             if (typeAlias) {
31863                                 return symbolToTypeNode(typeAlias, context, 788968);
31864                             }
31865                             else {
31866                                 return createElidedInformationPlaceholder(context);
31867                             }
31868                         }
31869                         else {
31870                             return visitAndTransformType(type, createTypeNodeFromObjectType);
31871                         }
31872                     }
31873                     else {
31874                         return createTypeNodeFromObjectType(type);
31875                     }
31876                     function shouldWriteTypeOfFunctionSymbol() {
31877                         var isStaticMethodSymbol = !!(symbol.flags & 8192) &&
31878                             ts.some(symbol.declarations, function (declaration) { return ts.hasModifier(declaration, 32); });
31879                         var isNonLocalFunctionSymbol = !!(symbol.flags & 16) &&
31880                             (symbol.parent ||
31881                                 ts.forEach(symbol.declarations, function (declaration) {
31882                                     return declaration.parent.kind === 290 || declaration.parent.kind === 250;
31883                                 }));
31884                         if (isStaticMethodSymbol || isNonLocalFunctionSymbol) {
31885                             return (!!(context.flags & 4096) || (context.visitedTypes && context.visitedTypes.has(typeId))) &&
31886                                 (!(context.flags & 8) || isValueSymbolAccessible(symbol, context.enclosingDeclaration));
31887                         }
31888                     }
31889                 }
31890                 function visitAndTransformType(type, transform) {
31891                     var typeId = "" + type.id;
31892                     var isConstructorObject = ts.getObjectFlags(type) & 16 && type.symbol && type.symbol.flags & 32;
31893                     var id = ts.getObjectFlags(type) & 4 && type.node ? "N" + getNodeId(type.node) :
31894                         type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) :
31895                             undefined;
31896                     if (!context.visitedTypes) {
31897                         context.visitedTypes = ts.createMap();
31898                     }
31899                     if (id && !context.symbolDepth) {
31900                         context.symbolDepth = ts.createMap();
31901                     }
31902                     var depth;
31903                     if (id) {
31904                         depth = context.symbolDepth.get(id) || 0;
31905                         if (depth > 10) {
31906                             return createElidedInformationPlaceholder(context);
31907                         }
31908                         context.symbolDepth.set(id, depth + 1);
31909                     }
31910                     context.visitedTypes.set(typeId, true);
31911                     var result = transform(type);
31912                     context.visitedTypes.delete(typeId);
31913                     if (id) {
31914                         context.symbolDepth.set(id, depth);
31915                     }
31916                     return result;
31917                 }
31918                 function createTypeNodeFromObjectType(type) {
31919                     if (isGenericMappedType(type)) {
31920                         return createMappedTypeNodeFromType(type);
31921                     }
31922                     var resolved = resolveStructuredTypeMembers(type);
31923                     if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) {
31924                         if (!resolved.callSignatures.length && !resolved.constructSignatures.length) {
31925                             context.approximateLength += 2;
31926                             return ts.setEmitFlags(ts.createTypeLiteralNode(undefined), 1);
31927                         }
31928                         if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) {
31929                             var signature = resolved.callSignatures[0];
31930                             var signatureNode = signatureToSignatureDeclarationHelper(signature, 170, context);
31931                             return signatureNode;
31932                         }
31933                         if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) {
31934                             var signature = resolved.constructSignatures[0];
31935                             var signatureNode = signatureToSignatureDeclarationHelper(signature, 171, context);
31936                             return signatureNode;
31937                         }
31938                     }
31939                     var savedFlags = context.flags;
31940                     context.flags |= 4194304;
31941                     var members = createTypeNodesFromResolvedType(resolved);
31942                     context.flags = savedFlags;
31943                     var typeLiteralNode = ts.createTypeLiteralNode(members);
31944                     context.approximateLength += 2;
31945                     return ts.setEmitFlags(typeLiteralNode, (context.flags & 1024) ? 0 : 1);
31946                 }
31947                 function typeReferenceToTypeNode(type) {
31948                     var typeArguments = getTypeArguments(type);
31949                     if (type.target === globalArrayType || type.target === globalReadonlyArrayType) {
31950                         if (context.flags & 2) {
31951                             var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context);
31952                             return ts.createTypeReferenceNode(type.target === globalArrayType ? "Array" : "ReadonlyArray", [typeArgumentNode]);
31953                         }
31954                         var elementType = typeToTypeNodeHelper(typeArguments[0], context);
31955                         var arrayType = ts.createArrayTypeNode(elementType);
31956                         return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(138, arrayType);
31957                     }
31958                     else if (type.target.objectFlags & 8) {
31959                         if (typeArguments.length > 0) {
31960                             var arity = getTypeReferenceArity(type);
31961                             var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context);
31962                             var hasRestElement = type.target.hasRestElement;
31963                             if (tupleConstituentNodes) {
31964                                 for (var i = type.target.minLength; i < Math.min(arity, tupleConstituentNodes.length); i++) {
31965                                     tupleConstituentNodes[i] = hasRestElement && i === arity - 1 ?
31966                                         ts.createRestTypeNode(ts.createArrayTypeNode(tupleConstituentNodes[i])) :
31967                                         ts.createOptionalTypeNode(tupleConstituentNodes[i]);
31968                                 }
31969                                 var tupleTypeNode = ts.createTupleTypeNode(tupleConstituentNodes);
31970                                 return type.target.readonly ? ts.createTypeOperatorNode(138, tupleTypeNode) : tupleTypeNode;
31971                             }
31972                         }
31973                         if (context.encounteredError || (context.flags & 524288)) {
31974                             var tupleTypeNode = ts.createTupleTypeNode([]);
31975                             return type.target.readonly ? ts.createTypeOperatorNode(138, tupleTypeNode) : tupleTypeNode;
31976                         }
31977                         context.encounteredError = true;
31978                         return undefined;
31979                     }
31980                     else if (context.flags & 2048 &&
31981                         type.symbol.valueDeclaration &&
31982                         ts.isClassLike(type.symbol.valueDeclaration) &&
31983                         !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
31984                         return createAnonymousTypeNode(type);
31985                     }
31986                     else {
31987                         var outerTypeParameters = type.target.outerTypeParameters;
31988                         var i = 0;
31989                         var resultType = void 0;
31990                         if (outerTypeParameters) {
31991                             var length_2 = outerTypeParameters.length;
31992                             while (i < length_2) {
31993                                 var start = i;
31994                                 var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]);
31995                                 do {
31996                                     i++;
31997                                 } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent);
31998                                 if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) {
31999                                     var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context);
32000                                     var flags_2 = context.flags;
32001                                     context.flags |= 16;
32002                                     var ref = symbolToTypeNode(parent, context, 788968, typeArgumentSlice);
32003                                     context.flags = flags_2;
32004                                     resultType = !resultType ? ref : appendReferenceToType(resultType, ref);
32005                                 }
32006                             }
32007                         }
32008                         var typeArgumentNodes = void 0;
32009                         if (typeArguments.length > 0) {
32010                             var typeParameterCount = (type.target.typeParameters || ts.emptyArray).length;
32011                             typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context);
32012                         }
32013                         var flags = context.flags;
32014                         context.flags |= 16;
32015                         var finalRef = symbolToTypeNode(type.symbol, context, 788968, typeArgumentNodes);
32016                         context.flags = flags;
32017                         return !resultType ? finalRef : appendReferenceToType(resultType, finalRef);
32018                     }
32019                 }
32020                 function appendReferenceToType(root, ref) {
32021                     if (ts.isImportTypeNode(root)) {
32022                         var innerParams = root.typeArguments;
32023                         if (root.qualifier) {
32024                             (ts.isIdentifier(root.qualifier) ? root.qualifier : root.qualifier.right).typeArguments = innerParams;
32025                         }
32026                         root.typeArguments = ref.typeArguments;
32027                         var ids = getAccessStack(ref);
32028                         for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
32029                             var id = ids_1[_i];
32030                             root.qualifier = root.qualifier ? ts.createQualifiedName(root.qualifier, id) : id;
32031                         }
32032                         return root;
32033                     }
32034                     else {
32035                         var innerParams = root.typeArguments;
32036                         (ts.isIdentifier(root.typeName) ? root.typeName : root.typeName.right).typeArguments = innerParams;
32037                         root.typeArguments = ref.typeArguments;
32038                         var ids = getAccessStack(ref);
32039                         for (var _a = 0, ids_2 = ids; _a < ids_2.length; _a++) {
32040                             var id = ids_2[_a];
32041                             root.typeName = ts.createQualifiedName(root.typeName, id);
32042                         }
32043                         return root;
32044                     }
32045                 }
32046                 function getAccessStack(ref) {
32047                     var state = ref.typeName;
32048                     var ids = [];
32049                     while (!ts.isIdentifier(state)) {
32050                         ids.unshift(state.right);
32051                         state = state.left;
32052                     }
32053                     ids.unshift(state);
32054                     return ids;
32055                 }
32056                 function createTypeNodesFromResolvedType(resolvedType) {
32057                     if (checkTruncationLength(context)) {
32058                         return [ts.createPropertySignature(undefined, "...", undefined, undefined, undefined)];
32059                     }
32060                     var typeElements = [];
32061                     for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) {
32062                         var signature = _a[_i];
32063                         typeElements.push(signatureToSignatureDeclarationHelper(signature, 165, context));
32064                     }
32065                     for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) {
32066                         var signature = _c[_b];
32067                         typeElements.push(signatureToSignatureDeclarationHelper(signature, 166, context));
32068                     }
32069                     if (resolvedType.stringIndexInfo) {
32070                         var indexSignature = void 0;
32071                         if (resolvedType.objectFlags & 2048) {
32072                             indexSignature = indexInfoToIndexSignatureDeclarationHelper(createIndexInfo(anyType, resolvedType.stringIndexInfo.isReadonly, resolvedType.stringIndexInfo.declaration), 0, context);
32073                             indexSignature.type = createElidedInformationPlaceholder(context);
32074                         }
32075                         else {
32076                             indexSignature = indexInfoToIndexSignatureDeclarationHelper(resolvedType.stringIndexInfo, 0, context);
32077                         }
32078                         typeElements.push(indexSignature);
32079                     }
32080                     if (resolvedType.numberIndexInfo) {
32081                         typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.numberIndexInfo, 1, context));
32082                     }
32083                     var properties = resolvedType.properties;
32084                     if (!properties) {
32085                         return typeElements;
32086                     }
32087                     var i = 0;
32088                     for (var _d = 0, properties_1 = properties; _d < properties_1.length; _d++) {
32089                         var propertySymbol = properties_1[_d];
32090                         i++;
32091                         if (context.flags & 2048) {
32092                             if (propertySymbol.flags & 4194304) {
32093                                 continue;
32094                             }
32095                             if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 | 16) && context.tracker.reportPrivateInBaseOfClassExpression) {
32096                                 context.tracker.reportPrivateInBaseOfClassExpression(ts.unescapeLeadingUnderscores(propertySymbol.escapedName));
32097                             }
32098                         }
32099                         if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) {
32100                             typeElements.push(ts.createPropertySignature(undefined, "... " + (properties.length - i) + " more ...", undefined, undefined, undefined));
32101                             addPropertyToElementList(properties[properties.length - 1], context, typeElements);
32102                             break;
32103                         }
32104                         addPropertyToElementList(propertySymbol, context, typeElements);
32105                     }
32106                     return typeElements.length ? typeElements : undefined;
32107                 }
32108             }
32109             function createElidedInformationPlaceholder(context) {
32110                 context.approximateLength += 3;
32111                 if (!(context.flags & 1)) {
32112                     return ts.createTypeReferenceNode(ts.createIdentifier("..."), undefined);
32113                 }
32114                 return ts.createKeywordTypeNode(125);
32115             }
32116             function addPropertyToElementList(propertySymbol, context, typeElements) {
32117                 var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192);
32118                 var propertyType = propertyIsReverseMapped && context.flags & 33554432 ?
32119                     anyType : getTypeOfSymbol(propertySymbol);
32120                 var saveEnclosingDeclaration = context.enclosingDeclaration;
32121                 context.enclosingDeclaration = undefined;
32122                 if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096) {
32123                     var decl = ts.first(propertySymbol.declarations);
32124                     if (hasLateBindableName(decl)) {
32125                         if (ts.isBinaryExpression(decl)) {
32126                             var name = ts.getNameOfDeclaration(decl);
32127                             if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) {
32128                                 trackComputedName(name.argumentExpression, saveEnclosingDeclaration, context);
32129                             }
32130                         }
32131                         else {
32132                             trackComputedName(decl.name.expression, saveEnclosingDeclaration, context);
32133                         }
32134                     }
32135                 }
32136                 context.enclosingDeclaration = saveEnclosingDeclaration;
32137                 var propertyName = getPropertyNameNodeForSymbol(propertySymbol, context);
32138                 context.approximateLength += (ts.symbolName(propertySymbol).length + 1);
32139                 var optionalToken = propertySymbol.flags & 16777216 ? ts.createToken(57) : undefined;
32140                 if (propertySymbol.flags & (16 | 8192) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) {
32141                     var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768); }), 0);
32142                     for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) {
32143                         var signature = signatures_1[_i];
32144                         var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 160, context);
32145                         methodDeclaration.name = propertyName;
32146                         methodDeclaration.questionToken = optionalToken;
32147                         typeElements.push(preserveCommentsOn(methodDeclaration));
32148                     }
32149                 }
32150                 else {
32151                     var savedFlags = context.flags;
32152                     context.flags |= propertyIsReverseMapped ? 33554432 : 0;
32153                     var propertyTypeNode = void 0;
32154                     if (propertyIsReverseMapped && !!(savedFlags & 33554432)) {
32155                         propertyTypeNode = createElidedInformationPlaceholder(context);
32156                     }
32157                     else {
32158                         propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.createKeywordTypeNode(125);
32159                     }
32160                     context.flags = savedFlags;
32161                     var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(138)] : undefined;
32162                     if (modifiers) {
32163                         context.approximateLength += 9;
32164                     }
32165                     var propertySignature = ts.createPropertySignature(modifiers, propertyName, optionalToken, propertyTypeNode, undefined);
32166                     typeElements.push(preserveCommentsOn(propertySignature));
32167                 }
32168                 function preserveCommentsOn(node) {
32169                     if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 323; })) {
32170                         var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 323; });
32171                         var commentText = d.comment;
32172                         if (commentText) {
32173                             ts.setSyntheticLeadingComments(node, [{ kind: 3, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]);
32174                         }
32175                     }
32176                     else if (propertySymbol.valueDeclaration) {
32177                         ts.setCommentRange(node, propertySymbol.valueDeclaration);
32178                     }
32179                     return node;
32180                 }
32181             }
32182             function mapToTypeNodes(types, context, isBareList) {
32183                 if (ts.some(types)) {
32184                     if (checkTruncationLength(context)) {
32185                         if (!isBareList) {
32186                             return [ts.createTypeReferenceNode("...", undefined)];
32187                         }
32188                         else if (types.length > 2) {
32189                             return [
32190                                 typeToTypeNodeHelper(types[0], context),
32191                                 ts.createTypeReferenceNode("... " + (types.length - 2) + " more ...", undefined),
32192                                 typeToTypeNodeHelper(types[types.length - 1], context)
32193                             ];
32194                         }
32195                     }
32196                     var mayHaveNameCollisions = !(context.flags & 64);
32197                     var seenNames = mayHaveNameCollisions ? ts.createUnderscoreEscapedMultiMap() : undefined;
32198                     var result_3 = [];
32199                     var i = 0;
32200                     for (var _i = 0, types_1 = types; _i < types_1.length; _i++) {
32201                         var type = types_1[_i];
32202                         i++;
32203                         if (checkTruncationLength(context) && (i + 2 < types.length - 1)) {
32204                             result_3.push(ts.createTypeReferenceNode("... " + (types.length - i) + " more ...", undefined));
32205                             var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context);
32206                             if (typeNode_1) {
32207                                 result_3.push(typeNode_1);
32208                             }
32209                             break;
32210                         }
32211                         context.approximateLength += 2;
32212                         var typeNode = typeToTypeNodeHelper(type, context);
32213                         if (typeNode) {
32214                             result_3.push(typeNode);
32215                             if (seenNames && ts.isIdentifierTypeReference(typeNode)) {
32216                                 seenNames.add(typeNode.typeName.escapedText, [type, result_3.length - 1]);
32217                             }
32218                         }
32219                     }
32220                     if (seenNames) {
32221                         var saveContextFlags = context.flags;
32222                         context.flags |= 64;
32223                         seenNames.forEach(function (types) {
32224                             if (!ts.arrayIsHomogeneous(types, function (_a, _b) {
32225                                 var a = _a[0];
32226                                 var b = _b[0];
32227                                 return typesAreSameReference(a, b);
32228                             })) {
32229                                 for (var _i = 0, types_2 = types; _i < types_2.length; _i++) {
32230                                     var _a = types_2[_i], type = _a[0], resultIndex = _a[1];
32231                                     result_3[resultIndex] = typeToTypeNodeHelper(type, context);
32232                                 }
32233                             }
32234                         });
32235                         context.flags = saveContextFlags;
32236                     }
32237                     return result_3;
32238                 }
32239             }
32240             function typesAreSameReference(a, b) {
32241                 return a === b
32242                     || !!a.symbol && a.symbol === b.symbol
32243                     || !!a.aliasSymbol && a.aliasSymbol === b.aliasSymbol;
32244             }
32245             function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context) {
32246                 var name = ts.getNameFromIndexInfo(indexInfo) || "x";
32247                 var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 ? 143 : 140);
32248                 var indexingParameter = ts.createParameter(undefined, undefined, undefined, name, undefined, indexerTypeNode, undefined);
32249                 var typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context);
32250                 if (!indexInfo.type && !(context.flags & 2097152)) {
32251                     context.encounteredError = true;
32252                 }
32253                 context.approximateLength += (name.length + 4);
32254                 return ts.createIndexSignature(undefined, indexInfo.isReadonly ? [ts.createToken(138)] : undefined, [indexingParameter], typeNode);
32255             }
32256             function signatureToSignatureDeclarationHelper(signature, kind, context, privateSymbolVisitor, bundledImports) {
32257                 var suppressAny = context.flags & 256;
32258                 if (suppressAny)
32259                     context.flags &= ~256;
32260                 var typeParameters;
32261                 var typeArguments;
32262                 if (context.flags & 32 && signature.target && signature.mapper && signature.target.typeParameters) {
32263                     typeArguments = signature.target.typeParameters.map(function (parameter) { return typeToTypeNodeHelper(instantiateType(parameter, signature.mapper), context); });
32264                 }
32265                 else {
32266                     typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); });
32267                 }
32268                 var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 162, privateSymbolVisitor, bundledImports); });
32269                 if (signature.thisParameter) {
32270                     var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context);
32271                     parameters.unshift(thisParameter);
32272                 }
32273                 var returnTypeNode;
32274                 var typePredicate = getTypePredicateOfSignature(signature);
32275                 if (typePredicate) {
32276                     var assertsModifier = typePredicate.kind === 2 || typePredicate.kind === 3 ?
32277                         ts.createToken(124) :
32278                         undefined;
32279                     var parameterName = typePredicate.kind === 1 || typePredicate.kind === 3 ?
32280                         ts.setEmitFlags(ts.createIdentifier(typePredicate.parameterName), 16777216) :
32281                         ts.createThisTypeNode();
32282                     var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context);
32283                     returnTypeNode = ts.createTypePredicateNodeWithModifier(assertsModifier, parameterName, typeNode);
32284                 }
32285                 else {
32286                     var returnType = getReturnTypeOfSignature(signature);
32287                     if (returnType && !(suppressAny && isTypeAny(returnType))) {
32288                         returnTypeNode = serializeReturnTypeForSignature(context, returnType, signature, privateSymbolVisitor, bundledImports);
32289                     }
32290                     else if (!suppressAny) {
32291                         returnTypeNode = ts.createKeywordTypeNode(125);
32292                     }
32293                 }
32294                 context.approximateLength += 3;
32295                 return ts.createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNode, typeArguments);
32296             }
32297             function typeParameterToDeclarationWithConstraint(type, context, constraintNode) {
32298                 var savedContextFlags = context.flags;
32299                 context.flags &= ~512;
32300                 var name = typeParameterToName(type, context);
32301                 var defaultParameter = getDefaultFromTypeParameter(type);
32302                 var defaultParameterNode = defaultParameter && typeToTypeNodeHelper(defaultParameter, context);
32303                 context.flags = savedContextFlags;
32304                 return ts.createTypeParameterDeclaration(name, constraintNode, defaultParameterNode);
32305             }
32306             function typeParameterToDeclaration(type, context, constraint) {
32307                 if (constraint === void 0) { constraint = getConstraintOfTypeParameter(type); }
32308                 var constraintNode = constraint && typeToTypeNodeHelper(constraint, context);
32309                 return typeParameterToDeclarationWithConstraint(type, context, constraintNode);
32310             }
32311             function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) {
32312                 var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 156);
32313                 if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) {
32314                     parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 317);
32315                 }
32316                 var parameterType = getTypeOfSymbol(parameterSymbol);
32317                 if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
32318                     parameterType = getOptionalType(parameterType);
32319                 }
32320                 var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports);
32321                 var modifiers = !(context.flags & 8192) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined;
32322                 var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768;
32323                 var dotDotDotToken = isRest ? ts.createToken(25) : undefined;
32324                 var name = parameterDeclaration ? parameterDeclaration.name ?
32325                     parameterDeclaration.name.kind === 75 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216) :
32326                         parameterDeclaration.name.kind === 153 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216) :
32327                             cloneBindingName(parameterDeclaration.name) :
32328                     ts.symbolName(parameterSymbol) :
32329                     ts.symbolName(parameterSymbol);
32330                 var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384;
32331                 var questionToken = isOptional ? ts.createToken(57) : undefined;
32332                 var parameterNode = ts.createParameter(undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, undefined);
32333                 context.approximateLength += ts.symbolName(parameterSymbol).length + 3;
32334                 return parameterNode;
32335                 function cloneBindingName(node) {
32336                     return elideInitializerAndSetEmitFlags(node);
32337                     function elideInitializerAndSetEmitFlags(node) {
32338                         if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) {
32339                             trackComputedName(node.expression, context.enclosingDeclaration, context);
32340                         }
32341                         var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, undefined, elideInitializerAndSetEmitFlags);
32342                         var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited);
32343                         if (clone.kind === 191) {
32344                             clone.initializer = undefined;
32345                         }
32346                         return ts.setEmitFlags(clone, 1 | 16777216);
32347                     }
32348                 }
32349             }
32350             function trackComputedName(accessExpression, enclosingDeclaration, context) {
32351                 if (!context.tracker.trackSymbol)
32352                     return;
32353                 var firstIdentifier = ts.getFirstIdentifier(accessExpression);
32354                 var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 | 1048576, undefined, undefined, true);
32355                 if (name) {
32356                     context.tracker.trackSymbol(name, enclosingDeclaration, 111551);
32357                 }
32358             }
32359             function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) {
32360                 context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning);
32361                 return lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol);
32362             }
32363             function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) {
32364                 var chain;
32365                 var isTypeParameter = symbol.flags & 262144;
32366                 if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64) && !(context.flags & 134217728)) {
32367                     chain = ts.Debug.checkDefined(getSymbolChain(symbol, meaning, true));
32368                     ts.Debug.assert(chain && chain.length > 0);
32369                 }
32370                 else {
32371                     chain = [symbol];
32372                 }
32373                 return chain;
32374                 function getSymbolChain(symbol, meaning, endOfChain) {
32375                     var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128));
32376                     var parentSpecifiers;
32377                     if (!accessibleSymbolChain ||
32378                         needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) {
32379                         var parents_1 = getContainersOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol, context.enclosingDeclaration);
32380                         if (ts.length(parents_1)) {
32381                             parentSpecifiers = parents_1.map(function (symbol) {
32382                                 return ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)
32383                                     ? getSpecifierForModuleSymbol(symbol, context)
32384                                     : undefined;
32385                             });
32386                             var indices = parents_1.map(function (_, i) { return i; });
32387                             indices.sort(sortByBestName);
32388                             var sortedParents = indices.map(function (i) { return parents_1[i]; });
32389                             for (var _i = 0, sortedParents_1 = sortedParents; _i < sortedParents_1.length; _i++) {
32390                                 var parent = sortedParents_1[_i];
32391                                 var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), false);
32392                                 if (parentChain) {
32393                                     if (parent.exports && parent.exports.get("export=") &&
32394                                         getSymbolIfSameReference(parent.exports.get("export="), symbol)) {
32395                                         accessibleSymbolChain = parentChain;
32396                                         break;
32397                                     }
32398                                     accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]);
32399                                     break;
32400                                 }
32401                             }
32402                         }
32403                     }
32404                     if (accessibleSymbolChain) {
32405                         return accessibleSymbolChain;
32406                     }
32407                     if (endOfChain ||
32408                         !(symbol.flags & (2048 | 4096))) {
32409                         if (!endOfChain && !yieldModuleSymbol && !!ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
32410                             return;
32411                         }
32412                         return [symbol];
32413                     }
32414                     function sortByBestName(a, b) {
32415                         var specifierA = parentSpecifiers[a];
32416                         var specifierB = parentSpecifiers[b];
32417                         if (specifierA && specifierB) {
32418                             var isBRelative = ts.pathIsRelative(specifierB);
32419                             if (ts.pathIsRelative(specifierA) === isBRelative) {
32420                                 return ts.moduleSpecifiers.countPathComponents(specifierA) - ts.moduleSpecifiers.countPathComponents(specifierB);
32421                             }
32422                             if (isBRelative) {
32423                                 return -1;
32424                             }
32425                             return 1;
32426                         }
32427                         return 0;
32428                     }
32429                 }
32430             }
32431             function typeParametersToTypeParameterDeclarations(symbol, context) {
32432                 var typeParameterNodes;
32433                 var targetSymbol = getTargetSymbol(symbol);
32434                 if (targetSymbol.flags & (32 | 64 | 524288)) {
32435                     typeParameterNodes = ts.createNodeArray(ts.map(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), function (tp) { return typeParameterToDeclaration(tp, context); }));
32436                 }
32437                 return typeParameterNodes;
32438             }
32439             function lookupTypeParameterNodes(chain, index, context) {
32440                 ts.Debug.assert(chain && 0 <= index && index < chain.length);
32441                 var symbol = chain[index];
32442                 var symbolId = "" + getSymbolId(symbol);
32443                 if (context.typeParameterSymbolList && context.typeParameterSymbolList.get(symbolId)) {
32444                     return undefined;
32445                 }
32446                 (context.typeParameterSymbolList || (context.typeParameterSymbolList = ts.createMap())).set(symbolId, true);
32447                 var typeParameterNodes;
32448                 if (context.flags & 512 && index < (chain.length - 1)) {
32449                     var parentSymbol = symbol;
32450                     var nextSymbol_1 = chain[index + 1];
32451                     if (ts.getCheckFlags(nextSymbol_1) & 1) {
32452                         var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 ? resolveAlias(parentSymbol) : parentSymbol);
32453                         typeParameterNodes = mapToTypeNodes(ts.map(params, function (t) { return getMappedType(t, nextSymbol_1.mapper); }), context);
32454                     }
32455                     else {
32456                         typeParameterNodes = typeParametersToTypeParameterDeclarations(symbol, context);
32457                     }
32458                 }
32459                 return typeParameterNodes;
32460             }
32461             function getTopmostIndexedAccessType(top) {
32462                 if (ts.isIndexedAccessTypeNode(top.objectType)) {
32463                     return getTopmostIndexedAccessType(top.objectType);
32464                 }
32465                 return top;
32466             }
32467             function getSpecifierForModuleSymbol(symbol, context) {
32468                 var file = ts.getDeclarationOfKind(symbol, 290);
32469                 if (!file) {
32470                     var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); });
32471                     if (equivalentFileSymbol) {
32472                         file = ts.getDeclarationOfKind(equivalentFileSymbol, 290);
32473                     }
32474                 }
32475                 if (file && file.moduleName !== undefined) {
32476                     return file.moduleName;
32477                 }
32478                 if (!file) {
32479                     if (context.tracker.trackReferencedAmbientModule) {
32480                         var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule);
32481                         if (ts.length(ambientDecls)) {
32482                             for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) {
32483                                 var decl = ambientDecls_1[_i];
32484                                 context.tracker.trackReferencedAmbientModule(decl, symbol);
32485                             }
32486                         }
32487                     }
32488                     if (ambientModuleSymbolRegex.test(symbol.escapedName)) {
32489                         return symbol.escapedName.substring(1, symbol.escapedName.length - 1);
32490                     }
32491                 }
32492                 if (!context.enclosingDeclaration || !context.tracker.moduleResolverHost) {
32493                     if (ambientModuleSymbolRegex.test(symbol.escapedName)) {
32494                         return symbol.escapedName.substring(1, symbol.escapedName.length - 1);
32495                     }
32496                     return ts.getSourceFileOfNode(ts.getNonAugmentationDeclaration(symbol)).fileName;
32497                 }
32498                 var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration));
32499                 var links = getSymbolLinks(symbol);
32500                 var specifier = links.specifierCache && links.specifierCache.get(contextFile.path);
32501                 if (!specifier) {
32502                     var isBundle_1 = (compilerOptions.out || compilerOptions.outFile);
32503                     var moduleResolverHost = context.tracker.moduleResolverHost;
32504                     var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions;
32505                     specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative" }));
32506                     links.specifierCache = links.specifierCache || ts.createMap();
32507                     links.specifierCache.set(contextFile.path, specifier);
32508                 }
32509                 return specifier;
32510             }
32511             function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
32512                 var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384));
32513                 var isTypeOf = meaning === 111551;
32514                 if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
32515                     var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined;
32516                     var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context);
32517                     var specifier = getSpecifierForModuleSymbol(chain[0], context);
32518                     if (!(context.flags & 67108864) && ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs && specifier.indexOf("/node_modules/") >= 0) {
32519                         context.encounteredError = true;
32520                         if (context.tracker.reportLikelyUnsafeImportRequiredError) {
32521                             context.tracker.reportLikelyUnsafeImportRequiredError(specifier);
32522                         }
32523                     }
32524                     var lit = ts.createLiteralTypeNode(ts.createLiteral(specifier));
32525                     if (context.tracker.trackExternalModuleSymbolOfImportTypeNode)
32526                         context.tracker.trackExternalModuleSymbolOfImportTypeNode(chain[0]);
32527                     context.approximateLength += specifier.length + 10;
32528                     if (!nonRootParts || ts.isEntityName(nonRootParts)) {
32529                         if (nonRootParts) {
32530                             var lastId = ts.isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right;
32531                             lastId.typeArguments = undefined;
32532                         }
32533                         return ts.createImportTypeNode(lit, nonRootParts, typeParameterNodes, isTypeOf);
32534                     }
32535                     else {
32536                         var splitNode = getTopmostIndexedAccessType(nonRootParts);
32537                         var qualifier = splitNode.objectType.typeName;
32538                         return ts.createIndexedAccessTypeNode(ts.createImportTypeNode(lit, qualifier, typeParameterNodes, isTypeOf), splitNode.indexType);
32539                     }
32540                 }
32541                 var entityName = createAccessFromSymbolChain(chain, chain.length - 1, 0);
32542                 if (ts.isIndexedAccessTypeNode(entityName)) {
32543                     return entityName;
32544                 }
32545                 if (isTypeOf) {
32546                     return ts.createTypeQueryNode(entityName);
32547                 }
32548                 else {
32549                     var lastId = ts.isIdentifier(entityName) ? entityName : entityName.right;
32550                     var lastTypeArgs = lastId.typeArguments;
32551                     lastId.typeArguments = undefined;
32552                     return ts.createTypeReferenceNode(entityName, lastTypeArgs);
32553                 }
32554                 function createAccessFromSymbolChain(chain, index, stopper) {
32555                     var typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context);
32556                     var symbol = chain[index];
32557                     var parent = chain[index - 1];
32558                     var symbolName;
32559                     if (index === 0) {
32560                         context.flags |= 16777216;
32561                         symbolName = getNameOfSymbolAsWritten(symbol, context);
32562                         context.approximateLength += (symbolName ? symbolName.length : 0) + 1;
32563                         context.flags ^= 16777216;
32564                     }
32565                     else {
32566                         if (parent && getExportsOfSymbol(parent)) {
32567                             var exports_1 = getExportsOfSymbol(parent);
32568                             ts.forEachEntry(exports_1, function (ex, name) {
32569                                 if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=") {
32570                                     symbolName = ts.unescapeLeadingUnderscores(name);
32571                                     return true;
32572                                 }
32573                             });
32574                         }
32575                     }
32576                     if (!symbolName) {
32577                         symbolName = getNameOfSymbolAsWritten(symbol, context);
32578                     }
32579                     context.approximateLength += symbolName.length + 1;
32580                     if (!(context.flags & 16) && parent &&
32581                         getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) &&
32582                         getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) {
32583                         var LHS = createAccessFromSymbolChain(chain, index - 1, stopper);
32584                         if (ts.isIndexedAccessTypeNode(LHS)) {
32585                             return ts.createIndexedAccessTypeNode(LHS, ts.createLiteralTypeNode(ts.createLiteral(symbolName)));
32586                         }
32587                         else {
32588                             return ts.createIndexedAccessTypeNode(ts.createTypeReferenceNode(LHS, typeParameterNodes), ts.createLiteralTypeNode(ts.createLiteral(symbolName)));
32589                         }
32590                     }
32591                     var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216);
32592                     identifier.symbol = symbol;
32593                     if (index > stopper) {
32594                         var LHS = createAccessFromSymbolChain(chain, index - 1, stopper);
32595                         if (!ts.isEntityName(LHS)) {
32596                             return ts.Debug.fail("Impossible construct - an export of an indexed access cannot be reachable");
32597                         }
32598                         return ts.createQualifiedName(LHS, identifier);
32599                     }
32600                     return identifier;
32601                 }
32602             }
32603             function typeParameterShadowsNameInScope(escapedName, context, type) {
32604                 var result = resolveName(context.enclosingDeclaration, escapedName, 788968, undefined, escapedName, false);
32605                 if (result) {
32606                     if (result.flags & 262144 && result === type.symbol) {
32607                         return false;
32608                     }
32609                     return true;
32610                 }
32611                 return false;
32612             }
32613             function typeParameterToName(type, context) {
32614                 if (context.flags & 4 && context.typeParameterNames) {
32615                     var cached = context.typeParameterNames.get("" + getTypeId(type));
32616                     if (cached) {
32617                         return cached;
32618                     }
32619                 }
32620                 var result = symbolToName(type.symbol, context, 788968, true);
32621                 if (!(result.kind & 75)) {
32622                     return ts.createIdentifier("(Missing type parameter)");
32623                 }
32624                 if (context.flags & 4) {
32625                     var rawtext = result.escapedText;
32626                     var i = 0;
32627                     var text = rawtext;
32628                     while ((context.typeParameterNamesByText && context.typeParameterNamesByText.get(text)) || typeParameterShadowsNameInScope(text, context, type)) {
32629                         i++;
32630                         text = rawtext + "_" + i;
32631                     }
32632                     if (text !== rawtext) {
32633                         result = ts.createIdentifier(text, result.typeArguments);
32634                     }
32635                     (context.typeParameterNames || (context.typeParameterNames = ts.createMap())).set("" + getTypeId(type), result);
32636                     (context.typeParameterNamesByText || (context.typeParameterNamesByText = ts.createMap())).set(result.escapedText, true);
32637                 }
32638                 return result;
32639             }
32640             function symbolToName(symbol, context, meaning, expectsIdentifier) {
32641                 var chain = lookupSymbolChain(symbol, context, meaning);
32642                 if (expectsIdentifier && chain.length !== 1
32643                     && !context.encounteredError
32644                     && !(context.flags & 65536)) {
32645                     context.encounteredError = true;
32646                 }
32647                 return createEntityNameFromSymbolChain(chain, chain.length - 1);
32648                 function createEntityNameFromSymbolChain(chain, index) {
32649                     var typeParameterNodes = lookupTypeParameterNodes(chain, index, context);
32650                     var symbol = chain[index];
32651                     if (index === 0) {
32652                         context.flags |= 16777216;
32653                     }
32654                     var symbolName = getNameOfSymbolAsWritten(symbol, context);
32655                     if (index === 0) {
32656                         context.flags ^= 16777216;
32657                     }
32658                     var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216);
32659                     identifier.symbol = symbol;
32660                     return index > 0 ? ts.createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier;
32661                 }
32662             }
32663             function symbolToExpression(symbol, context, meaning) {
32664                 var chain = lookupSymbolChain(symbol, context, meaning);
32665                 return createExpressionFromSymbolChain(chain, chain.length - 1);
32666                 function createExpressionFromSymbolChain(chain, index) {
32667                     var typeParameterNodes = lookupTypeParameterNodes(chain, index, context);
32668                     var symbol = chain[index];
32669                     if (index === 0) {
32670                         context.flags |= 16777216;
32671                     }
32672                     var symbolName = getNameOfSymbolAsWritten(symbol, context);
32673                     if (index === 0) {
32674                         context.flags ^= 16777216;
32675                     }
32676                     var firstChar = symbolName.charCodeAt(0);
32677                     if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
32678                         return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context));
32679                     }
32680                     var canUsePropertyAccess = firstChar === 35 ?
32681                         symbolName.length > 1 && ts.isIdentifierStart(symbolName.charCodeAt(1), languageVersion) :
32682                         ts.isIdentifierStart(firstChar, languageVersion);
32683                     if (index === 0 || canUsePropertyAccess) {
32684                         var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216);
32685                         identifier.symbol = symbol;
32686                         return index > 0 ? ts.createPropertyAccess(createExpressionFromSymbolChain(chain, index - 1), identifier) : identifier;
32687                     }
32688                     else {
32689                         if (firstChar === 91) {
32690                             symbolName = symbolName.substring(1, symbolName.length - 1);
32691                             firstChar = symbolName.charCodeAt(0);
32692                         }
32693                         var expression = void 0;
32694                         if (ts.isSingleOrDoubleQuote(firstChar)) {
32695                             expression = ts.createLiteral(symbolName.substring(1, symbolName.length - 1).replace(/\\./g, function (s) { return s.substring(1); }));
32696                             expression.singleQuote = firstChar === 39;
32697                         }
32698                         else if (("" + +symbolName) === symbolName) {
32699                             expression = ts.createLiteral(+symbolName);
32700                         }
32701                         if (!expression) {
32702                             expression = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216);
32703                             expression.symbol = symbol;
32704                         }
32705                         return ts.createElementAccess(createExpressionFromSymbolChain(chain, index - 1), expression);
32706                     }
32707                 }
32708             }
32709             function isSingleQuotedStringNamed(d) {
32710                 var name = ts.getNameOfDeclaration(d);
32711                 if (name && ts.isStringLiteral(name) && (name.singleQuote ||
32712                     (!ts.nodeIsSynthesized(name) && ts.startsWith(ts.getTextOfNode(name, false), "'")))) {
32713                     return true;
32714                 }
32715                 return false;
32716             }
32717             function getPropertyNameNodeForSymbol(symbol, context) {
32718                 var singleQuote = !!ts.length(symbol.declarations) && ts.every(symbol.declarations, isSingleQuotedStringNamed);
32719                 var fromNameType = getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote);
32720                 if (fromNameType) {
32721                     return fromNameType;
32722                 }
32723                 if (ts.isKnownSymbol(symbol)) {
32724                     return ts.createComputedPropertyName(ts.createPropertyAccess(ts.createIdentifier("Symbol"), symbol.escapedName.substr(3)));
32725                 }
32726                 var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName);
32727                 return createPropertyNameNodeForIdentifierOrLiteral(rawName, singleQuote);
32728             }
32729             function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote) {
32730                 var nameType = getSymbolLinks(symbol).nameType;
32731                 if (nameType) {
32732                     if (nameType.flags & 384) {
32733                         var name = "" + nameType.value;
32734                         if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) {
32735                             return ts.createLiteral(name, !!singleQuote);
32736                         }
32737                         if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
32738                             return ts.createComputedPropertyName(ts.createLiteral(+name));
32739                         }
32740                         return createPropertyNameNodeForIdentifierOrLiteral(name);
32741                     }
32742                     if (nameType.flags & 8192) {
32743                         return ts.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551));
32744                     }
32745                 }
32746             }
32747             function createPropertyNameNodeForIdentifierOrLiteral(name, singleQuote) {
32748                 return ts.isIdentifierText(name, compilerOptions.target) ? ts.createIdentifier(name) : ts.createLiteral(isNumericLiteralName(name) && +name >= 0 ? +name : name, !!singleQuote);
32749             }
32750             function cloneNodeBuilderContext(context) {
32751                 var initial = __assign({}, context);
32752                 if (initial.typeParameterNames) {
32753                     initial.typeParameterNames = ts.cloneMap(initial.typeParameterNames);
32754                 }
32755                 if (initial.typeParameterNamesByText) {
32756                     initial.typeParameterNamesByText = ts.cloneMap(initial.typeParameterNamesByText);
32757                 }
32758                 if (initial.typeParameterSymbolList) {
32759                     initial.typeParameterSymbolList = ts.cloneMap(initial.typeParameterSymbolList);
32760                 }
32761                 return initial;
32762             }
32763             function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) {
32764                 return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); });
32765             }
32766             function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) {
32767                 return !(ts.getObjectFlags(type) & 4) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
32768             }
32769             function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) {
32770                 if (type !== errorType && enclosingDeclaration) {
32771                     var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration);
32772                     if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) {
32773                         var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation);
32774                         if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
32775                             var result_4 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled);
32776                             if (result_4) {
32777                                 return result_4;
32778                             }
32779                         }
32780                     }
32781                 }
32782                 var oldFlags = context.flags;
32783                 if (type.flags & 8192 &&
32784                     type.symbol === symbol) {
32785                     context.flags |= 1048576;
32786                 }
32787                 var result = typeToTypeNodeHelper(type, context);
32788                 context.flags = oldFlags;
32789                 return result;
32790             }
32791             function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
32792                 if (type !== errorType && context.enclosingDeclaration) {
32793                     var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
32794                     if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) {
32795                         var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled);
32796                         if (result) {
32797                             return result;
32798                         }
32799                     }
32800                 }
32801                 return typeToTypeNodeHelper(type, context);
32802             }
32803             function serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled) {
32804                 if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
32805                     cancellationToken.throwIfCancellationRequested();
32806                 }
32807                 var hadError = false;
32808                 var transformed = ts.visitNode(existing, visitExistingNodeTreeSymbols);
32809                 if (hadError) {
32810                     return undefined;
32811                 }
32812                 return transformed === existing ? ts.getMutableClone(existing) : transformed;
32813                 function visitExistingNodeTreeSymbols(node) {
32814                     var _a, _b;
32815                     if (ts.isJSDocAllType(node) || node.kind === 302) {
32816                         return ts.createKeywordTypeNode(125);
32817                     }
32818                     if (ts.isJSDocUnknownType(node)) {
32819                         return ts.createKeywordTypeNode(148);
32820                     }
32821                     if (ts.isJSDocNullableType(node)) {
32822                         return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(100)]);
32823                     }
32824                     if (ts.isJSDocOptionalType(node)) {
32825                         return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(146)]);
32826                     }
32827                     if (ts.isJSDocNonNullableType(node)) {
32828                         return ts.visitNode(node.type, visitExistingNodeTreeSymbols);
32829                     }
32830                     if (ts.isJSDocVariadicType(node)) {
32831                         return ts.createArrayTypeNode(ts.visitNode(node.type, visitExistingNodeTreeSymbols));
32832                     }
32833                     if (ts.isJSDocTypeLiteral(node)) {
32834                         return ts.createTypeLiteralNode(ts.map(node.jsDocPropertyTags, function (t) {
32835                             var name = ts.isIdentifier(t.name) ? t.name : t.name.right;
32836                             var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText);
32837                             var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined;
32838                             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);
32839                         }));
32840                     }
32841                     if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") {
32842                         return ts.setOriginalNode(ts.createKeywordTypeNode(125), node);
32843                     }
32844                     if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) {
32845                         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))]);
32846                     }
32847                     if (ts.isJSDocFunctionType(node)) {
32848                         if (ts.isJSDocConstructSignature(node)) {
32849                             var newTypeNode_1;
32850                             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));
32851                         }
32852                         else {
32853                             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));
32854                         }
32855                     }
32856                     if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968, true))) {
32857                         return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
32858                     }
32859                     if (ts.isLiteralImportTypeNode(node)) {
32860                         return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf);
32861                     }
32862                     if (ts.isEntityName(node) || ts.isEntityNameExpression(node)) {
32863                         var leftmost = ts.getFirstIdentifier(node);
32864                         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)))) {
32865                             hadError = true;
32866                             return node;
32867                         }
32868                         var sym = resolveEntityName(leftmost, 67108863, true, true);
32869                         if (sym) {
32870                             if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863, false).accessibility !== 0) {
32871                                 hadError = true;
32872                             }
32873                             else {
32874                                 (_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);
32875                                 includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym);
32876                             }
32877                             if (ts.isIdentifier(node)) {
32878                                 var name = sym.flags & 262144 ? typeParameterToName(getDeclaredTypeOfSymbol(sym), context) : ts.getMutableClone(node);
32879                                 name.symbol = sym;
32880                                 return ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216);
32881                             }
32882                         }
32883                     }
32884                     return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext);
32885                     function getEffectiveDotDotDotForParameter(p) {
32886                         return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.createToken(25) : undefined);
32887                     }
32888                     function rewriteModuleSpecifier(parent, lit) {
32889                         if (bundled) {
32890                             if (context.tracker && context.tracker.moduleResolverHost) {
32891                                 var targetFile = getExternalModuleFileFromDeclaration(parent);
32892                                 if (targetFile) {
32893                                     var getCanonicalFileName = ts.createGetCanonicalFileName(!!host.useCaseSensitiveFileNames);
32894                                     var resolverHost = {
32895                                         getCanonicalFileName: getCanonicalFileName,
32896                                         getCurrentDirectory: function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); },
32897                                         getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); }
32898                                     };
32899                                     var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile);
32900                                     return ts.createLiteral(newName);
32901                                 }
32902                             }
32903                         }
32904                         else {
32905                             if (context.tracker && context.tracker.trackExternalModuleSymbolOfImportTypeNode) {
32906                                 var moduleSym = resolveExternalModuleNameWorker(lit, lit, undefined);
32907                                 if (moduleSym) {
32908                                     context.tracker.trackExternalModuleSymbolOfImportTypeNode(moduleSym);
32909                                 }
32910                             }
32911                         }
32912                         return lit;
32913                     }
32914                 }
32915             }
32916             function symbolTableToDeclarationStatements(symbolTable, context, bundled) {
32917                 var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.createProperty, 161, true);
32918                 var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type, initializer) { return ts.createPropertySignature(mods, name, question, type, initializer); }, 160, false);
32919                 var enclosingDeclaration = context.enclosingDeclaration;
32920                 var results = [];
32921                 var visitedSymbols = ts.createMap();
32922                 var deferredPrivates;
32923                 var oldcontext = context;
32924                 context = __assign(__assign({}, oldcontext), { usedSymbolNames: ts.createMap(), remappedSymbolNames: ts.createMap(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) {
32925                             var accessibleResult = isSymbolAccessible(sym, decl, meaning, false);
32926                             if (accessibleResult.accessibility === 0) {
32927                                 var chain = lookupSymbolChainWorker(sym, context, meaning);
32928                                 if (!(sym.flags & 4)) {
32929                                     includePrivateSymbol(chain[0]);
32930                                 }
32931                             }
32932                             else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) {
32933                                 oldcontext.tracker.trackSymbol(sym, decl, meaning);
32934                             }
32935                         } }) });
32936                 if (oldcontext.usedSymbolNames) {
32937                     oldcontext.usedSymbolNames.forEach(function (_, name) {
32938                         context.usedSymbolNames.set(name, true);
32939                     });
32940                 }
32941                 ts.forEachEntry(symbolTable, function (symbol, name) {
32942                     var baseName = ts.unescapeLeadingUnderscores(name);
32943                     void getInternalSymbolName(symbol, baseName);
32944                 });
32945                 var addingDeclare = !bundled;
32946                 var exportEquals = symbolTable.get("export=");
32947                 if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152) {
32948                     symbolTable = ts.createSymbolTable();
32949                     symbolTable.set("export=", exportEquals);
32950                 }
32951                 visitSymbolTable(symbolTable);
32952                 return mergeRedundantStatements(results);
32953                 function isIdentifierAndNotUndefined(node) {
32954                     return !!node && node.kind === 75;
32955                 }
32956                 function getNamesOfDeclaration(statement) {
32957                     if (ts.isVariableStatement(statement)) {
32958                         return ts.filter(ts.map(statement.declarationList.declarations, ts.getNameOfDeclaration), isIdentifierAndNotUndefined);
32959                     }
32960                     return ts.filter([ts.getNameOfDeclaration(statement)], isIdentifierAndNotUndefined);
32961                 }
32962                 function flattenExportAssignedNamespace(statements) {
32963                     var exportAssignment = ts.find(statements, ts.isExportAssignment);
32964                     var ns = ts.find(statements, ts.isModuleDeclaration);
32965                     if (ns && exportAssignment && exportAssignment.isExportEquals &&
32966                         ts.isIdentifier(exportAssignment.expression) && ts.isIdentifier(ns.name) && ts.idText(ns.name) === ts.idText(exportAssignment.expression) &&
32967                         ns.body && ts.isModuleBlock(ns.body)) {
32968                         var excessExports = ts.filter(statements, function (s) { return !!(ts.getModifierFlags(s) & 1); });
32969                         if (ts.length(excessExports)) {
32970                             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)]));
32971                         }
32972                         if (!ts.find(statements, function (s) { return s !== ns && ts.nodeHasName(s, ns.name); })) {
32973                             results = [];
32974                             ts.forEach(ns.body.statements, function (s) {
32975                                 addResult(s, 0);
32976                             });
32977                             statements = __spreadArrays(ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), results);
32978                         }
32979                     }
32980                     return statements;
32981                 }
32982                 function mergeExportDeclarations(statements) {
32983                     var exports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause && ts.isNamedExports(d.exportClause); });
32984                     if (ts.length(exports) > 1) {
32985                         var nonExports = ts.filter(statements, function (d) { return !ts.isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause; });
32986                         statements = __spreadArrays(nonExports, [ts.createExportDeclaration(undefined, undefined, ts.createNamedExports(ts.flatMap(exports, function (e) { return ts.cast(e.exportClause, ts.isNamedExports).elements; })), undefined)]);
32987                     }
32988                     var reexports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !!d.moduleSpecifier && !!d.exportClause && ts.isNamedExports(d.exportClause); });
32989                     if (ts.length(reexports) > 1) {
32990                         var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; });
32991                         if (groups.length !== reexports.length) {
32992                             var _loop_8 = function (group_1) {
32993                                 if (group_1.length > 1) {
32994                                     statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [
32995                                         ts.createExportDeclaration(undefined, undefined, ts.createNamedExports(ts.flatMap(group_1, function (e) { return ts.cast(e.exportClause, ts.isNamedExports).elements; })), group_1[0].moduleSpecifier)
32996                                     ]);
32997                                 }
32998                             };
32999                             for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) {
33000                                 var group_1 = groups_1[_i];
33001                                 _loop_8(group_1);
33002                             }
33003                         }
33004                     }
33005                     return statements;
33006                 }
33007                 function inlineExportModifiers(statements) {
33008                     var exportDecl = ts.find(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; });
33009                     if (exportDecl && exportDecl.exportClause && ts.isNamedExports(exportDecl.exportClause)) {
33010                         var replacements = ts.mapDefined(exportDecl.exportClause.elements, function (e) {
33011                             if (!e.propertyName) {
33012                                 var associated = ts.filter(statements, function (s) { return ts.nodeHasName(s, e.name); });
33013                                 if (ts.length(associated) && ts.every(associated, canHaveExportModifier)) {
33014                                     ts.forEach(associated, addExportModifier);
33015                                     return undefined;
33016                                 }
33017                             }
33018                             return e;
33019                         });
33020                         if (!ts.length(replacements)) {
33021                             statements = ts.filter(statements, function (s) { return s !== exportDecl; });
33022                         }
33023                         else {
33024                             exportDecl.exportClause.elements = ts.createNodeArray(replacements);
33025                         }
33026                     }
33027                     return statements;
33028                 }
33029                 function mergeRedundantStatements(statements) {
33030                     statements = flattenExportAssignedNamespace(statements);
33031                     statements = mergeExportDeclarations(statements);
33032                     statements = inlineExportModifiers(statements);
33033                     if (enclosingDeclaration &&
33034                         ((ts.isSourceFile(enclosingDeclaration) && ts.isExternalOrCommonJsModule(enclosingDeclaration)) || ts.isModuleDeclaration(enclosingDeclaration)) &&
33035                         (!ts.some(statements, ts.isExternalModuleIndicator) || (!ts.hasScopeMarker(statements) && ts.some(statements, ts.needsScopeMarker)))) {
33036                         statements.push(ts.createEmptyExports());
33037                     }
33038                     return statements;
33039                 }
33040                 function canHaveExportModifier(node) {
33041                     return ts.isEnumDeclaration(node) ||
33042                         ts.isVariableStatement(node) ||
33043                         ts.isFunctionDeclaration(node) ||
33044                         ts.isClassDeclaration(node) ||
33045                         (ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) ||
33046                         ts.isInterfaceDeclaration(node) ||
33047                         isTypeDeclaration(node);
33048                 }
33049                 function addExportModifier(statement) {
33050                     var flags = (ts.getModifierFlags(statement) | 1) & ~2;
33051                     statement.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(flags));
33052                     statement.modifierFlagsCache = 0;
33053                 }
33054                 function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) {
33055                     var oldDeferredPrivates = deferredPrivates;
33056                     if (!suppressNewPrivateContext) {
33057                         deferredPrivates = ts.createMap();
33058                     }
33059                     symbolTable.forEach(function (symbol) {
33060                         serializeSymbol(symbol, false, !!propertyAsAlias);
33061                     });
33062                     if (!suppressNewPrivateContext) {
33063                         deferredPrivates.forEach(function (symbol) {
33064                             serializeSymbol(symbol, true, !!propertyAsAlias);
33065                         });
33066                     }
33067                     deferredPrivates = oldDeferredPrivates;
33068                 }
33069                 function serializeSymbol(symbol, isPrivate, propertyAsAlias) {
33070                     var visitedSym = getMergedSymbol(symbol);
33071                     if (visitedSymbols.has("" + getSymbolId(visitedSym))) {
33072                         return;
33073                     }
33074                     visitedSymbols.set("" + getSymbolId(visitedSym), true);
33075                     var skipMembershipCheck = !isPrivate;
33076                     if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) {
33077                         var oldContext = context;
33078                         context = cloneNodeBuilderContext(context);
33079                         var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias);
33080                         context = oldContext;
33081                         return result;
33082                     }
33083                 }
33084                 function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) {
33085                     var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName);
33086                     var isDefault = symbol.escapedName === "default";
33087                     if (!(context.flags & 131072) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) {
33088                         context.encounteredError = true;
33089                         return;
33090                     }
33091                     var needsPostExportDefault = isDefault && !!(symbol.flags & -113
33092                         || (symbol.flags & 16 && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152);
33093                     if (needsPostExportDefault) {
33094                         isPrivate = true;
33095                     }
33096                     var modifierFlags = (!isPrivate ? 1 : 0) | (isDefault && !needsPostExportDefault ? 512 : 0);
33097                     var isConstMergedWithNS = symbol.flags & 1536 &&
33098                         symbol.flags & (2 | 1 | 4) &&
33099                         symbol.escapedName !== "export=";
33100                     var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol);
33101                     if (symbol.flags & (16 | 8192) || isConstMergedWithNSPrintableAsSignatureMerge) {
33102                         serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
33103                     }
33104                     if (symbol.flags & 524288) {
33105                         serializeTypeAlias(symbol, symbolName, modifierFlags);
33106                     }
33107                     if (symbol.flags & (2 | 1 | 4)
33108                         && symbol.escapedName !== "export="
33109                         && !(symbol.flags & 4194304)
33110                         && !(symbol.flags & 32)
33111                         && !isConstMergedWithNSPrintableAsSignatureMerge) {
33112                         serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags);
33113                     }
33114                     if (symbol.flags & 384) {
33115                         serializeEnum(symbol, symbolName, modifierFlags);
33116                     }
33117                     if (symbol.flags & 32) {
33118                         if (symbol.flags & 4 && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) {
33119                             serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
33120                         }
33121                         else {
33122                             serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
33123                         }
33124                     }
33125                     if ((symbol.flags & (512 | 1024) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) {
33126                         serializeModule(symbol, symbolName, modifierFlags);
33127                     }
33128                     if (symbol.flags & 64) {
33129                         serializeInterface(symbol, symbolName, modifierFlags);
33130                     }
33131                     if (symbol.flags & 2097152) {
33132                         serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
33133                     }
33134                     if (symbol.flags & 4 && symbol.escapedName === "export=") {
33135                         serializeMaybeAliasAssignment(symbol);
33136                     }
33137                     if (symbol.flags & 8388608) {
33138                         for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
33139                             var node = _a[_i];
33140                             var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
33141                             if (!resolvedModule)
33142                                 continue;
33143                             addResult(ts.createExportDeclaration(undefined, undefined, undefined, ts.createLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0);
33144                         }
33145                     }
33146                     if (needsPostExportDefault) {
33147                         addResult(ts.createExportAssignment(undefined, undefined, false, ts.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0);
33148                     }
33149                 }
33150                 function includePrivateSymbol(symbol) {
33151                     if (ts.some(symbol.declarations, ts.isParameterDeclaration))
33152                         return;
33153                     ts.Debug.assertIsDefined(deferredPrivates);
33154                     getUnusedName(ts.unescapeLeadingUnderscores(symbol.escapedName), symbol);
33155                     deferredPrivates.set("" + getSymbolId(symbol), symbol);
33156                 }
33157                 function isExportingScope(enclosingDeclaration) {
33158                     return ((ts.isSourceFile(enclosingDeclaration) && (ts.isExternalOrCommonJsModule(enclosingDeclaration) || ts.isJsonSourceFile(enclosingDeclaration))) ||
33159                         (ts.isAmbientModule(enclosingDeclaration) && !ts.isGlobalScopeAugmentation(enclosingDeclaration)));
33160                 }
33161                 function addResult(node, additionalModifierFlags) {
33162                     var newModifierFlags = 0;
33163                     if (additionalModifierFlags & 1 &&
33164                         enclosingDeclaration &&
33165                         isExportingScope(enclosingDeclaration) &&
33166                         canHaveExportModifier(node)) {
33167                         newModifierFlags |= 1;
33168                     }
33169                     if (addingDeclare && !(newModifierFlags & 1) &&
33170                         (!enclosingDeclaration || !(enclosingDeclaration.flags & 8388608)) &&
33171                         (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) {
33172                         newModifierFlags |= 2;
33173                     }
33174                     if ((additionalModifierFlags & 512) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) {
33175                         newModifierFlags |= 512;
33176                     }
33177                     if (newModifierFlags) {
33178                         node.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(newModifierFlags | ts.getModifierFlags(node)));
33179                         node.modifierFlagsCache = 0;
33180                     }
33181                     results.push(node);
33182                 }
33183                 function serializeTypeAlias(symbol, symbolName, modifierFlags) {
33184                     var aliasType = getDeclaredTypeOfTypeAlias(symbol);
33185                     var typeParams = getSymbolLinks(symbol).typeParameters;
33186                     var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); });
33187                     var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias);
33188                     var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined;
33189                     var oldFlags = context.flags;
33190                     context.flags |= 8388608;
33191                     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);
33192                     context.flags = oldFlags;
33193                 }
33194                 function serializeInterface(symbol, symbolName, modifierFlags) {
33195                     var interfaceType = getDeclaredTypeOfClassOrInterface(symbol);
33196                     var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
33197                     var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); });
33198                     var baseTypes = getBaseTypes(interfaceType);
33199                     var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined;
33200                     var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); });
33201                     var callSignatures = serializeSignatures(0, interfaceType, baseType, 165);
33202                     var constructSignatures = serializeSignatures(1, interfaceType, baseType, 166);
33203                     var indexSignatures = serializeIndexSignatures(interfaceType, baseType);
33204                     var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(90, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b); }))];
33205                     addResult(ts.createInterfaceDeclaration(undefined, undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, constructSignatures, callSignatures, members)), modifierFlags);
33206                 }
33207                 function getNamespaceMembersForSerialization(symbol) {
33208                     return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember);
33209                 }
33210                 function isTypeOnlyNamespace(symbol) {
33211                     return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551); });
33212                 }
33213                 function serializeModule(symbol, symbolName, modifierFlags) {
33214                     var members = getNamespaceMembersForSerialization(symbol);
33215                     var locationMap = ts.arrayToMultiMap(members, function (m) { return m.parent && m.parent === symbol ? "real" : "merged"; });
33216                     var realMembers = locationMap.get("real") || ts.emptyArray;
33217                     var mergedMembers = locationMap.get("merged") || ts.emptyArray;
33218                     if (ts.length(realMembers)) {
33219                         var localName = getInternalSymbolName(symbol, symbolName);
33220                         serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 | 67108864)));
33221                     }
33222                     if (ts.length(mergedMembers)) {
33223                         var containingFile_1 = ts.getSourceFileOfNode(context.enclosingDeclaration);
33224                         var localName = getInternalSymbolName(symbol, symbolName);
33225                         var nsBody = ts.createModuleBlock([ts.createExportDeclaration(undefined, undefined, ts.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export="; }), function (s) {
33226                                 var _a, _b;
33227                                 var name = ts.unescapeLeadingUnderscores(s.escapedName);
33228                                 var localName = getInternalSymbolName(s, name);
33229                                 var aliasDecl = s.declarations && getDeclarationOfAliasSymbol(s);
33230                                 if (containingFile_1 && (aliasDecl ? containingFile_1 !== ts.getSourceFileOfNode(aliasDecl) : !ts.some(s.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile_1; }))) {
33231                                     (_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);
33232                                     return undefined;
33233                                 }
33234                                 var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, true);
33235                                 includePrivateSymbol(target || s);
33236                                 var targetName = target ? getInternalSymbolName(target, ts.unescapeLeadingUnderscores(target.escapedName)) : localName;
33237                                 return ts.createExportSpecifier(name === targetName ? undefined : targetName, name);
33238                             })))]);
33239                         addResult(ts.createModuleDeclaration(undefined, undefined, ts.createIdentifier(localName), nsBody, 16), 0);
33240                     }
33241                 }
33242                 function serializeEnum(symbol, symbolName, modifierFlags) {
33243                     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) {
33244                         var initializedValue = p.declarations && p.declarations[0] && ts.isEnumMember(p.declarations[0]) && getConstantValue(p.declarations[0]);
33245                         return ts.createEnumMember(ts.unescapeLeadingUnderscores(p.escapedName), initializedValue === undefined ? undefined : ts.createLiteral(initializedValue));
33246                     })), modifierFlags);
33247                 }
33248                 function serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags) {
33249                     if (propertyAsAlias) {
33250                         serializeMaybeAliasAssignment(symbol);
33251                     }
33252                     else {
33253                         var type = getTypeOfSymbol(symbol);
33254                         var localName = getInternalSymbolName(symbol, symbolName);
33255                         if (!(symbol.flags & 16) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) {
33256                             serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags);
33257                         }
33258                         else {
33259                             var flags = !(symbol.flags & 2) ? undefined
33260                                 : isConstVariable(symbol) ? 2
33261                                     : 1;
33262                             var name = (needsPostExportDefault || !(symbol.flags & 4)) ? localName : getUnusedName(localName, symbol);
33263                             var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); });
33264                             if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) {
33265                                 textRange = textRange.parent.parent;
33266                             }
33267                             var statement = ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
33268                                 ts.createVariableDeclaration(name, serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled))
33269                             ], flags)), textRange);
33270                             addResult(statement, name !== localName ? modifierFlags & ~1 : modifierFlags);
33271                             if (name !== localName && !isPrivate) {
33272                                 addResult(ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([ts.createExportSpecifier(name, localName)])), 0);
33273                             }
33274                         }
33275                     }
33276                 }
33277                 function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) {
33278                     var signatures = getSignaturesOfType(type, 0);
33279                     for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) {
33280                         var sig = signatures_2[_i];
33281                         var decl = signatureToSignatureDeclarationHelper(sig, 244, context, includePrivateSymbol, bundled);
33282                         decl.name = ts.createIdentifier(localName);
33283                         addResult(ts.setTextRange(decl, sig.declaration && ts.isVariableDeclaration(sig.declaration.parent) && sig.declaration.parent.parent || sig.declaration), modifierFlags);
33284                     }
33285                     if (!(symbol.flags & (512 | 1024) && !!symbol.exports && !!symbol.exports.size)) {
33286                         var props = ts.filter(getPropertiesOfType(type), isNamespaceMember);
33287                         serializeAsNamespaceDeclaration(props, localName, modifierFlags, true);
33288                     }
33289                 }
33290                 function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) {
33291                     if (ts.length(props)) {
33292                         var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) {
33293                             return !ts.length(p.declarations) || ts.some(p.declarations, function (d) {
33294                                 return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration);
33295                             }) ? "local" : "remote";
33296                         });
33297                         var localProps = localVsRemoteMap.get("local") || ts.emptyArray;
33298                         var fakespace = ts.createModuleDeclaration(undefined, undefined, ts.createIdentifier(localName), ts.createModuleBlock([]), 16);
33299                         fakespace.flags ^= 8;
33300                         fakespace.parent = enclosingDeclaration;
33301                         fakespace.locals = ts.createSymbolTable(props);
33302                         fakespace.symbol = props[0].parent;
33303                         var oldResults = results;
33304                         results = [];
33305                         var oldAddingDeclare = addingDeclare;
33306                         addingDeclare = false;
33307                         var subcontext = __assign(__assign({}, context), { enclosingDeclaration: fakespace });
33308                         var oldContext = context;
33309                         context = subcontext;
33310                         visitSymbolTable(ts.createSymbolTable(localProps), suppressNewPrivateContext, true);
33311                         context = oldContext;
33312                         addingDeclare = oldAddingDeclare;
33313                         var declarations = results;
33314                         results = oldResults;
33315                         fakespace.flags ^= 8;
33316                         fakespace.parent = undefined;
33317                         fakespace.locals = undefined;
33318                         fakespace.symbol = undefined;
33319                         fakespace.body = ts.createModuleBlock(declarations);
33320                         addResult(fakespace, modifierFlags);
33321                     }
33322                 }
33323                 function isNamespaceMember(p) {
33324                     return !(p.flags & 4194304 || p.escapedName === "prototype" || p.valueDeclaration && ts.isClassLike(p.valueDeclaration.parent));
33325                 }
33326                 function serializeAsClass(symbol, localName, modifierFlags) {
33327                     var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
33328                     var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); });
33329                     var classType = getDeclaredTypeOfClassOrInterface(symbol);
33330                     var baseTypes = getBaseTypes(classType);
33331                     var implementsTypes = getImplementsTypes(classType);
33332                     var staticType = getTypeOfSymbol(symbol);
33333                     var staticBaseType = getBaseConstructorTypeOfClass(staticType);
33334                     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); }))]);
33335                     var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType));
33336                     var publicSymbolProps = ts.filter(symbolProps, function (s) {
33337                         var valueDecl = s.valueDeclaration;
33338                         return valueDecl && !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name));
33339                     });
33340                     var hasPrivateIdentifier = ts.some(symbolProps, function (s) {
33341                         var valueDecl = s.valueDeclaration;
33342                         return valueDecl && ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name);
33343                     });
33344                     var privateProperties = hasPrivateIdentifier ?
33345                         [ts.createProperty(undefined, undefined, ts.createPrivateIdentifier("#private"), undefined, undefined, undefined)] :
33346                         ts.emptyArray;
33347                     var publicProperties = ts.flatMap(publicSymbolProps, function (p) { return serializePropertySymbolForClass(p, false, baseTypes[0]); });
33348                     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); });
33349                     var constructors = serializeSignatures(1, staticType, baseTypes[0], 162);
33350                     for (var _i = 0, constructors_1 = constructors; _i < constructors_1.length; _i++) {
33351                         var c = constructors_1[_i];
33352                         c.type = undefined;
33353                         c.typeParameters = undefined;
33354                     }
33355                     var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]);
33356                     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);
33357                 }
33358                 function serializeAsAlias(symbol, localName, modifierFlags) {
33359                     var node = getDeclarationOfAliasSymbol(symbol);
33360                     if (!node)
33361                         return ts.Debug.fail();
33362                     var target = getMergedSymbol(getTargetOfAliasDeclaration(node, true));
33363                     if (!target) {
33364                         return;
33365                     }
33366                     var verbatimTargetName = ts.unescapeLeadingUnderscores(target.escapedName);
33367                     if (verbatimTargetName === "export=" && (compilerOptions.esModuleInterop || compilerOptions.allowSyntheticDefaultImports)) {
33368                         verbatimTargetName = "default";
33369                     }
33370                     var targetName = getInternalSymbolName(target, verbatimTargetName);
33371                     includePrivateSymbol(target);
33372                     switch (node.kind) {
33373                         case 253:
33374                             var isLocalImport = !(target.flags & 512);
33375                             addResult(ts.createImportEqualsDeclaration(undefined, undefined, ts.createIdentifier(localName), isLocalImport
33376                                 ? symbolToName(target, context, 67108863, false)
33377                                 : ts.createExternalModuleReference(ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)))), isLocalImport ? modifierFlags : 0);
33378                             break;
33379                         case 252:
33380                             addResult(ts.createNamespaceExportDeclaration(ts.idText(node.name)), 0);
33381                             break;
33382                         case 255:
33383                             addResult(ts.createImportDeclaration(undefined, undefined, ts.createImportClause(ts.createIdentifier(localName), undefined), ts.createLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0);
33384                             break;
33385                         case 256:
33386                             addResult(ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(ts.createIdentifier(localName))), ts.createLiteral(getSpecifierForModuleSymbol(target, context))), 0);
33387                             break;
33388                         case 262:
33389                             addResult(ts.createExportDeclaration(undefined, undefined, ts.createNamespaceExport(ts.createIdentifier(localName)), ts.createLiteral(getSpecifierForModuleSymbol(target, context))), 0);
33390                             break;
33391                         case 258:
33392                             addResult(ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamedImports([
33393                                 ts.createImportSpecifier(localName !== verbatimTargetName ? ts.createIdentifier(verbatimTargetName) : undefined, ts.createIdentifier(localName))
33394                             ])), ts.createLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0);
33395                             break;
33396                         case 263:
33397                             var specifier = node.parent.parent.moduleSpecifier;
33398                             serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.createLiteral(specifier.text) : undefined);
33399                             break;
33400                         case 259:
33401                             serializeMaybeAliasAssignment(symbol);
33402                             break;
33403                         case 209:
33404                         case 194:
33405                             if (symbol.escapedName === "default" || symbol.escapedName === "export=") {
33406                                 serializeMaybeAliasAssignment(symbol);
33407                             }
33408                             else {
33409                                 serializeExportSpecifier(localName, targetName);
33410                             }
33411                             break;
33412                         default:
33413                             return ts.Debug.failBadSyntaxKind(node, "Unhandled alias declaration kind in symbol serializer!");
33414                     }
33415                 }
33416                 function serializeExportSpecifier(localName, targetName, specifier) {
33417                     addResult(ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([ts.createExportSpecifier(localName !== targetName ? targetName : undefined, localName)]), specifier), 0);
33418                 }
33419                 function serializeMaybeAliasAssignment(symbol) {
33420                     if (symbol.flags & 4194304) {
33421                         return;
33422                     }
33423                     var name = ts.unescapeLeadingUnderscores(symbol.escapedName);
33424                     var isExportEquals = name === "export=";
33425                     var isDefault = name === "default";
33426                     var isExportAssignment = isExportEquals || isDefault;
33427                     var aliasDecl = symbol.declarations && getDeclarationOfAliasSymbol(symbol);
33428                     var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, true);
33429                     if (target && ts.length(target.declarations) && ts.some(target.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(enclosingDeclaration); })) {
33430                         var expr = isExportAssignment ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl);
33431                         var first_1 = ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined;
33432                         var referenced = first_1 && resolveEntityName(first_1, 67108863, true, true, enclosingDeclaration);
33433                         if (referenced || target) {
33434                             includePrivateSymbol(referenced || target);
33435                         }
33436                         var oldTrack = context.tracker.trackSymbol;
33437                         context.tracker.trackSymbol = ts.noop;
33438                         if (isExportAssignment) {
33439                             results.push(ts.createExportAssignment(undefined, undefined, isExportEquals, symbolToExpression(target, context, 67108863)));
33440                         }
33441                         else {
33442                             if (first_1 === expr) {
33443                                 serializeExportSpecifier(name, ts.idText(first_1));
33444                             }
33445                             else if (ts.isClassExpression(expr)) {
33446                                 serializeExportSpecifier(name, getInternalSymbolName(target, ts.symbolName(target)));
33447                             }
33448                             else {
33449                                 var varName = getUnusedName(name, symbol);
33450                                 addResult(ts.createImportEqualsDeclaration(undefined, undefined, ts.createIdentifier(varName), symbolToName(target, context, 67108863, false)), 0);
33451                                 serializeExportSpecifier(name, varName);
33452                             }
33453                         }
33454                         context.tracker.trackSymbol = oldTrack;
33455                     }
33456                     else {
33457                         var varName = getUnusedName(name, symbol);
33458                         var typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol)));
33459                         if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) {
33460                             serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignment ? 0 : 1);
33461                         }
33462                         else {
33463                             var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
33464                                 ts.createVariableDeclaration(varName, serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled))
33465                             ], 2));
33466                             addResult(statement, name === varName ? 1 : 0);
33467                         }
33468                         if (isExportAssignment) {
33469                             results.push(ts.createExportAssignment(undefined, undefined, isExportEquals, ts.createIdentifier(varName)));
33470                         }
33471                         else if (name !== varName) {
33472                             serializeExportSpecifier(name, varName);
33473                         }
33474                     }
33475                 }
33476                 function isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, hostSymbol) {
33477                     var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration);
33478                     return ts.getObjectFlags(typeToSerialize) & (16 | 32) &&
33479                         !getIndexInfoOfType(typeToSerialize, 0) &&
33480                         !getIndexInfoOfType(typeToSerialize, 1) &&
33481                         !!(ts.length(getPropertiesOfType(typeToSerialize)) || ts.length(getSignaturesOfType(typeToSerialize, 0))) &&
33482                         !ts.length(getSignaturesOfType(typeToSerialize, 1)) &&
33483                         !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) &&
33484                         !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) &&
33485                         !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) &&
33486                         !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return ts.some(p.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; }); }) &&
33487                         ts.every(getPropertiesOfType(typeToSerialize), function (p) { return ts.isIdentifierText(ts.symbolName(p), languageVersion) && !ts.isStringAKeyword(ts.symbolName(p)); });
33488                 }
33489                 function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) {
33490                     return function serializePropertySymbol(p, isStatic, baseType) {
33491                         var modifierFlags = ts.getDeclarationModifierFlagsFromSymbol(p);
33492                         var isPrivate = !!(modifierFlags & 8);
33493                         if (isStatic && (p.flags & (788968 | 1920 | 2097152))) {
33494                             return [];
33495                         }
33496                         if (p.flags & 4194304 ||
33497                             (baseType && getPropertyOfType(baseType, p.escapedName)
33498                                 && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p)
33499                                 && (p.flags & 16777216) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216)
33500                                 && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) {
33501                             return [];
33502                         }
33503                         var flag = (modifierFlags & ~256) | (isStatic ? 32 : 0);
33504                         var name = getPropertyNameNodeForSymbol(p, context);
33505                         var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression));
33506                         if (p.flags & 98304 && useAccessors) {
33507                             var result = [];
33508                             if (p.flags & 65536) {
33509                                 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));
33510                             }
33511                             if (p.flags & 32768) {
33512                                 var isPrivate_1 = modifierFlags & 8;
33513                                 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));
33514                             }
33515                             return result;
33516                         }
33517                         else if (p.flags & (4 | 3)) {
33518                             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);
33519                         }
33520                         if (p.flags & (8192 | 16)) {
33521                             var type = getTypeOfSymbol(p);
33522                             var signatures = getSignaturesOfType(type, 0);
33523                             if (flag & 8) {
33524                                 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]);
33525                             }
33526                             var results_1 = [];
33527                             for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) {
33528                                 var sig = signatures_3[_i];
33529                                 var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context);
33530                                 decl.name = name;
33531                                 if (flag) {
33532                                     decl.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(flag));
33533                                 }
33534                                 if (p.flags & 16777216) {
33535                                     decl.questionToken = ts.createToken(57);
33536                                 }
33537                                 results_1.push(ts.setTextRange(decl, sig.declaration));
33538                             }
33539                             return results_1;
33540                         }
33541                         return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags));
33542                     };
33543                 }
33544                 function serializePropertySymbolForInterface(p, baseType) {
33545                     return serializePropertySymbolForInterfaceWorker(p, false, baseType);
33546                 }
33547                 function serializeSignatures(kind, input, baseType, outputKind) {
33548                     var signatures = getSignaturesOfType(input, kind);
33549                     if (kind === 1) {
33550                         if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) {
33551                             return [];
33552                         }
33553                         if (baseType) {
33554                             var baseSigs = getSignaturesOfType(baseType, 1);
33555                             if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) {
33556                                 return [];
33557                             }
33558                             if (baseSigs.length === signatures.length) {
33559                                 var failed = false;
33560                                 for (var i = 0; i < baseSigs.length; i++) {
33561                                     if (!compareSignaturesIdentical(signatures[i], baseSigs[i], false, false, true, compareTypesIdentical)) {
33562                                         failed = true;
33563                                         break;
33564                                     }
33565                                 }
33566                                 if (!failed) {
33567                                     return [];
33568                                 }
33569                             }
33570                         }
33571                         var privateProtected = 0;
33572                         for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) {
33573                             var s = signatures_4[_i];
33574                             if (s.declaration) {
33575                                 privateProtected |= ts.getSelectedModifierFlags(s.declaration, 8 | 16);
33576                             }
33577                         }
33578                         if (privateProtected) {
33579                             return [ts.setTextRange(ts.createConstructor(undefined, ts.createModifiersFromModifierFlags(privateProtected), [], undefined), signatures[0].declaration)];
33580                         }
33581                     }
33582                     var results = [];
33583                     for (var _a = 0, signatures_5 = signatures; _a < signatures_5.length; _a++) {
33584                         var sig = signatures_5[_a];
33585                         var decl = signatureToSignatureDeclarationHelper(sig, outputKind, context);
33586                         results.push(ts.setTextRange(decl, sig.declaration));
33587                     }
33588                     return results;
33589                 }
33590                 function serializeIndexSignatures(input, baseType) {
33591                     var results = [];
33592                     for (var _i = 0, _a = [0, 1]; _i < _a.length; _i++) {
33593                         var type = _a[_i];
33594                         var info = getIndexInfoOfType(input, type);
33595                         if (info) {
33596                             if (baseType) {
33597                                 var baseInfo = getIndexInfoOfType(baseType, type);
33598                                 if (baseInfo) {
33599                                     if (isTypeIdenticalTo(info.type, baseInfo.type)) {
33600                                         continue;
33601                                     }
33602                                 }
33603                             }
33604                             results.push(indexInfoToIndexSignatureDeclarationHelper(info, type, context));
33605                         }
33606                     }
33607                     return results;
33608                 }
33609                 function serializeBaseType(t, staticType, rootName) {
33610                     var ref = trySerializeAsTypeReference(t);
33611                     if (ref) {
33612                         return ref;
33613                     }
33614                     var tempName = getUnusedName(rootName + "_base");
33615                     var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
33616                         ts.createVariableDeclaration(tempName, typeToTypeNodeHelper(staticType, context))
33617                     ], 2));
33618                     addResult(statement, 0);
33619                     return ts.createExpressionWithTypeArguments(undefined, ts.createIdentifier(tempName));
33620                 }
33621                 function trySerializeAsTypeReference(t) {
33622                     var typeArgs;
33623                     var reference;
33624                     if (t.target && getAccessibleSymbolChain(t.target.symbol, enclosingDeclaration, 111551, false)) {
33625                         typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); });
33626                         reference = symbolToExpression(t.target.symbol, context, 788968);
33627                     }
33628                     else if (t.symbol && getAccessibleSymbolChain(t.symbol, enclosingDeclaration, 111551, false)) {
33629                         reference = symbolToExpression(t.symbol, context, 788968);
33630                     }
33631                     if (reference) {
33632                         return ts.createExpressionWithTypeArguments(typeArgs, reference);
33633                     }
33634                 }
33635                 function getUnusedName(input, symbol) {
33636                     if (symbol) {
33637                         if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) {
33638                             return context.remappedSymbolNames.get("" + getSymbolId(symbol));
33639                         }
33640                     }
33641                     if (symbol) {
33642                         input = getNameCandidateWorker(symbol, input);
33643                     }
33644                     var i = 0;
33645                     var original = input;
33646                     while (context.usedSymbolNames.has(input)) {
33647                         i++;
33648                         input = original + "_" + i;
33649                     }
33650                     context.usedSymbolNames.set(input, true);
33651                     if (symbol) {
33652                         context.remappedSymbolNames.set("" + getSymbolId(symbol), input);
33653                     }
33654                     return input;
33655                 }
33656                 function getNameCandidateWorker(symbol, localName) {
33657                     if (localName === "default" || localName === "__class" || localName === "__function") {
33658                         var flags = context.flags;
33659                         context.flags |= 16777216;
33660                         var nameCandidate = getNameOfSymbolAsWritten(symbol, context);
33661                         context.flags = flags;
33662                         localName = nameCandidate.length > 0 && ts.isSingleOrDoubleQuote(nameCandidate.charCodeAt(0)) ? ts.stripQuotes(nameCandidate) : nameCandidate;
33663                     }
33664                     if (localName === "default") {
33665                         localName = "_default";
33666                     }
33667                     else if (localName === "export=") {
33668                         localName = "_exports";
33669                     }
33670                     localName = ts.isIdentifierText(localName, languageVersion) && !ts.isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-zA-Z0-9]/g, "_");
33671                     return localName;
33672                 }
33673                 function getInternalSymbolName(symbol, localName) {
33674                     if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) {
33675                         return context.remappedSymbolNames.get("" + getSymbolId(symbol));
33676                     }
33677                     localName = getNameCandidateWorker(symbol, localName);
33678                     context.remappedSymbolNames.set("" + getSymbolId(symbol), localName);
33679                     return localName;
33680                 }
33681             }
33682         }
33683         function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) {
33684             if (flags === void 0) { flags = 16384; }
33685             return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker);
33686             function typePredicateToStringWorker(writer) {
33687                 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));
33688                 var printer = ts.createPrinter({ removeComments: true });
33689                 var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
33690                 printer.writeNode(4, predicate, sourceFile, writer);
33691                 return writer;
33692             }
33693         }
33694         function formatUnionTypes(types) {
33695             var result = [];
33696             var flags = 0;
33697             for (var i = 0; i < types.length; i++) {
33698                 var t = types[i];
33699                 flags |= t.flags;
33700                 if (!(t.flags & 98304)) {
33701                     if (t.flags & (512 | 1024)) {
33702                         var baseType = t.flags & 512 ? booleanType : getBaseTypeOfEnumLiteralType(t);
33703                         if (baseType.flags & 1048576) {
33704                             var count = baseType.types.length;
33705                             if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) {
33706                                 result.push(baseType);
33707                                 i += count - 1;
33708                                 continue;
33709                             }
33710                         }
33711                     }
33712                     result.push(t);
33713                 }
33714             }
33715             if (flags & 65536)
33716                 result.push(nullType);
33717             if (flags & 32768)
33718                 result.push(undefinedType);
33719             return result || types;
33720         }
33721         function visibilityToString(flags) {
33722             if (flags === 8) {
33723                 return "private";
33724             }
33725             if (flags === 16) {
33726                 return "protected";
33727             }
33728             return "public";
33729         }
33730         function getTypeAliasForTypeLiteral(type) {
33731             if (type.symbol && type.symbol.flags & 2048) {
33732                 var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 182; });
33733                 if (node.kind === 247) {
33734                     return getSymbolOfNode(node);
33735                 }
33736             }
33737             return undefined;
33738         }
33739         function isTopLevelInExternalModuleAugmentation(node) {
33740             return node && node.parent &&
33741                 node.parent.kind === 250 &&
33742                 ts.isExternalModuleAugmentation(node.parent.parent);
33743         }
33744         function isDefaultBindingContext(location) {
33745             return location.kind === 290 || ts.isAmbientModule(location);
33746         }
33747         function getNameOfSymbolFromNameType(symbol, context) {
33748             var nameType = getSymbolLinks(symbol).nameType;
33749             if (nameType) {
33750                 if (nameType.flags & 384) {
33751                     var name = "" + nameType.value;
33752                     if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) {
33753                         return "\"" + ts.escapeString(name, 34) + "\"";
33754                     }
33755                     if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
33756                         return "[" + name + "]";
33757                     }
33758                     return name;
33759                 }
33760                 if (nameType.flags & 8192) {
33761                     return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]";
33762                 }
33763             }
33764         }
33765         function getNameOfSymbolAsWritten(symbol, context) {
33766             if (context && symbol.escapedName === "default" && !(context.flags & 16384) &&
33767                 (!(context.flags & 16777216) ||
33768                     !symbol.declarations ||
33769                     (context.enclosingDeclaration && ts.findAncestor(symbol.declarations[0], isDefaultBindingContext) !== ts.findAncestor(context.enclosingDeclaration, isDefaultBindingContext)))) {
33770                 return "default";
33771             }
33772             if (symbol.declarations && symbol.declarations.length) {
33773                 var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; });
33774                 var name_2 = declaration && ts.getNameOfDeclaration(declaration);
33775                 if (declaration && name_2) {
33776                     if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) {
33777                         return ts.symbolName(symbol);
33778                     }
33779                     if (ts.isComputedPropertyName(name_2) && !(ts.getCheckFlags(symbol) & 4096)) {
33780                         var nameType = getSymbolLinks(symbol).nameType;
33781                         if (nameType && nameType.flags & 384) {
33782                             var result = getNameOfSymbolFromNameType(symbol, context);
33783                             if (result !== undefined) {
33784                                 return result;
33785                             }
33786                         }
33787                     }
33788                     return ts.declarationNameToString(name_2);
33789                 }
33790                 if (!declaration) {
33791                     declaration = symbol.declarations[0];
33792                 }
33793                 if (declaration.parent && declaration.parent.kind === 242) {
33794                     return ts.declarationNameToString(declaration.parent.name);
33795                 }
33796                 switch (declaration.kind) {
33797                     case 214:
33798                     case 201:
33799                     case 202:
33800                         if (context && !context.encounteredError && !(context.flags & 131072)) {
33801                             context.encounteredError = true;
33802                         }
33803                         return declaration.kind === 214 ? "(Anonymous class)" : "(Anonymous function)";
33804                 }
33805             }
33806             var name = getNameOfSymbolFromNameType(symbol, context);
33807             return name !== undefined ? name : ts.symbolName(symbol);
33808         }
33809         function isDeclarationVisible(node) {
33810             if (node) {
33811                 var links = getNodeLinks(node);
33812                 if (links.isVisible === undefined) {
33813                     links.isVisible = !!determineIfDeclarationIsVisible();
33814                 }
33815                 return links.isVisible;
33816             }
33817             return false;
33818             function determineIfDeclarationIsVisible() {
33819                 switch (node.kind) {
33820                     case 315:
33821                     case 322:
33822                     case 316:
33823                         return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent));
33824                     case 191:
33825                         return isDeclarationVisible(node.parent.parent);
33826                     case 242:
33827                         if (ts.isBindingPattern(node.name) &&
33828                             !node.name.elements.length) {
33829                             return false;
33830                         }
33831                     case 249:
33832                     case 245:
33833                     case 246:
33834                     case 247:
33835                     case 244:
33836                     case 248:
33837                     case 253:
33838                         if (ts.isExternalModuleAugmentation(node)) {
33839                             return true;
33840                         }
33841                         var parent = getDeclarationContainer(node);
33842                         if (!(ts.getCombinedModifierFlags(node) & 1) &&
33843                             !(node.kind !== 253 && parent.kind !== 290 && parent.flags & 8388608)) {
33844                             return isGlobalSourceFile(parent);
33845                         }
33846                         return isDeclarationVisible(parent);
33847                     case 159:
33848                     case 158:
33849                     case 163:
33850                     case 164:
33851                     case 161:
33852                     case 160:
33853                         if (ts.hasModifier(node, 8 | 16)) {
33854                             return false;
33855                         }
33856                     case 162:
33857                     case 166:
33858                     case 165:
33859                     case 167:
33860                     case 156:
33861                     case 250:
33862                     case 170:
33863                     case 171:
33864                     case 173:
33865                     case 169:
33866                     case 174:
33867                     case 175:
33868                     case 178:
33869                     case 179:
33870                     case 182:
33871                         return isDeclarationVisible(node.parent);
33872                     case 255:
33873                     case 256:
33874                     case 258:
33875                         return false;
33876                     case 155:
33877                     case 290:
33878                     case 252:
33879                         return true;
33880                     case 259:
33881                         return false;
33882                     default:
33883                         return false;
33884                 }
33885             }
33886         }
33887         function collectLinkedAliases(node, setVisibility) {
33888             var exportSymbol;
33889             if (node.parent && node.parent.kind === 259) {
33890                 exportSymbol = resolveName(node, node.escapedText, 111551 | 788968 | 1920 | 2097152, undefined, node, false);
33891             }
33892             else if (node.parent.kind === 263) {
33893                 exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 | 788968 | 1920 | 2097152);
33894             }
33895             var result;
33896             var visited;
33897             if (exportSymbol) {
33898                 visited = ts.createMap();
33899                 visited.set("" + getSymbolId(exportSymbol), true);
33900                 buildVisibleNodeList(exportSymbol.declarations);
33901             }
33902             return result;
33903             function buildVisibleNodeList(declarations) {
33904                 ts.forEach(declarations, function (declaration) {
33905                     var resultNode = getAnyImportSyntax(declaration) || declaration;
33906                     if (setVisibility) {
33907                         getNodeLinks(declaration).isVisible = true;
33908                     }
33909                     else {
33910                         result = result || [];
33911                         ts.pushIfUnique(result, resultNode);
33912                     }
33913                     if (ts.isInternalModuleImportEqualsDeclaration(declaration)) {
33914                         var internalModuleReference = declaration.moduleReference;
33915                         var firstIdentifier = ts.getFirstIdentifier(internalModuleReference);
33916                         var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 | 788968 | 1920, undefined, undefined, false);
33917                         var id = importSymbol && "" + getSymbolId(importSymbol);
33918                         if (importSymbol && !visited.has(id)) {
33919                             visited.set(id, true);
33920                             buildVisibleNodeList(importSymbol.declarations);
33921                         }
33922                     }
33923                 });
33924             }
33925         }
33926         function pushTypeResolution(target, propertyName) {
33927             var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName);
33928             if (resolutionCycleStartIndex >= 0) {
33929                 var length_3 = resolutionTargets.length;
33930                 for (var i = resolutionCycleStartIndex; i < length_3; i++) {
33931                     resolutionResults[i] = false;
33932                 }
33933                 return false;
33934             }
33935             resolutionTargets.push(target);
33936             resolutionResults.push(true);
33937             resolutionPropertyNames.push(propertyName);
33938             return true;
33939         }
33940         function findResolutionCycleStartIndex(target, propertyName) {
33941             for (var i = resolutionTargets.length - 1; i >= 0; i--) {
33942                 if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) {
33943                     return -1;
33944                 }
33945                 if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) {
33946                     return i;
33947                 }
33948             }
33949             return -1;
33950         }
33951         function hasType(target, propertyName) {
33952             switch (propertyName) {
33953                 case 0:
33954                     return !!getSymbolLinks(target).type;
33955                 case 5:
33956                     return !!(getNodeLinks(target).resolvedEnumType);
33957                 case 2:
33958                     return !!getSymbolLinks(target).declaredType;
33959                 case 1:
33960                     return !!target.resolvedBaseConstructorType;
33961                 case 3:
33962                     return !!target.resolvedReturnType;
33963                 case 4:
33964                     return !!target.immediateBaseConstraint;
33965                 case 6:
33966                     return !!target.resolvedTypeArguments;
33967             }
33968             return ts.Debug.assertNever(propertyName);
33969         }
33970         function popTypeResolution() {
33971             resolutionTargets.pop();
33972             resolutionPropertyNames.pop();
33973             return resolutionResults.pop();
33974         }
33975         function getDeclarationContainer(node) {
33976             return ts.findAncestor(ts.getRootDeclaration(node), function (node) {
33977                 switch (node.kind) {
33978                     case 242:
33979                     case 243:
33980                     case 258:
33981                     case 257:
33982                     case 256:
33983                     case 255:
33984                         return false;
33985                     default:
33986                         return true;
33987                 }
33988             }).parent;
33989         }
33990         function getTypeOfPrototypeProperty(prototype) {
33991             var classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype));
33992             return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType;
33993         }
33994         function getTypeOfPropertyOfType(type, name) {
33995             var prop = getPropertyOfType(type, name);
33996             return prop ? getTypeOfSymbol(prop) : undefined;
33997         }
33998         function getTypeOfPropertyOrIndexSignature(type, name) {
33999             return getTypeOfPropertyOfType(type, name) || isNumericLiteralName(name) && getIndexTypeOfType(type, 1) || getIndexTypeOfType(type, 0) || unknownType;
34000         }
34001         function isTypeAny(type) {
34002             return type && (type.flags & 1) !== 0;
34003         }
34004         function getTypeForBindingElementParent(node) {
34005             var symbol = getSymbolOfNode(node);
34006             return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false);
34007         }
34008         function getRestType(source, properties, symbol) {
34009             source = filterType(source, function (t) { return !(t.flags & 98304); });
34010             if (source.flags & 131072) {
34011                 return emptyObjectType;
34012             }
34013             if (source.flags & 1048576) {
34014                 return mapType(source, function (t) { return getRestType(t, properties, symbol); });
34015             }
34016             var omitKeyType = getUnionType(ts.map(properties, getLiteralTypeFromPropertyName));
34017             if (isGenericObjectType(source) || isGenericIndexType(omitKeyType)) {
34018                 if (omitKeyType.flags & 131072) {
34019                     return source;
34020                 }
34021                 var omitTypeAlias = getGlobalOmitSymbol();
34022                 if (!omitTypeAlias) {
34023                     return errorType;
34024                 }
34025                 return getTypeAliasInstantiation(omitTypeAlias, [source, omitKeyType]);
34026             }
34027             var members = ts.createSymbolTable();
34028             for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
34029                 var prop = _a[_i];
34030                 if (!isTypeAssignableTo(getLiteralTypeFromProperty(prop, 8576), omitKeyType)
34031                     && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16))
34032                     && isSpreadableProperty(prop)) {
34033                     members.set(prop.escapedName, getSpreadSymbol(prop, false));
34034                 }
34035             }
34036             var stringIndexInfo = getIndexInfoOfType(source, 0);
34037             var numberIndexInfo = getIndexInfoOfType(source, 1);
34038             var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
34039             result.objectFlags |= 131072;
34040             return result;
34041         }
34042         function getFlowTypeOfDestructuring(node, declaredType) {
34043             var reference = getSyntheticElementAccess(node);
34044             return reference ? getFlowTypeOfReference(reference, declaredType) : declaredType;
34045         }
34046         function getSyntheticElementAccess(node) {
34047             var parentAccess = getParentElementAccess(node);
34048             if (parentAccess && parentAccess.flowNode) {
34049                 var propName = getDestructuringPropertyName(node);
34050                 if (propName) {
34051                     var result = ts.createNode(195, node.pos, node.end);
34052                     result.parent = node;
34053                     result.expression = parentAccess;
34054                     var literal = ts.createNode(10, node.pos, node.end);
34055                     literal.parent = result;
34056                     literal.text = propName;
34057                     result.argumentExpression = literal;
34058                     result.flowNode = parentAccess.flowNode;
34059                     return result;
34060                 }
34061             }
34062         }
34063         function getParentElementAccess(node) {
34064             var ancestor = node.parent.parent;
34065             switch (ancestor.kind) {
34066                 case 191:
34067                 case 281:
34068                     return getSyntheticElementAccess(ancestor);
34069                 case 192:
34070                     return getSyntheticElementAccess(node.parent);
34071                 case 242:
34072                     return ancestor.initializer;
34073                 case 209:
34074                     return ancestor.right;
34075             }
34076         }
34077         function getDestructuringPropertyName(node) {
34078             var parent = node.parent;
34079             if (node.kind === 191 && parent.kind === 189) {
34080                 return getLiteralPropertyNameText(node.propertyName || node.name);
34081             }
34082             if (node.kind === 281 || node.kind === 282) {
34083                 return getLiteralPropertyNameText(node.name);
34084             }
34085             return "" + parent.elements.indexOf(node);
34086         }
34087         function getLiteralPropertyNameText(name) {
34088             var type = getLiteralTypeFromPropertyName(name);
34089             return type.flags & (128 | 256) ? "" + type.value : undefined;
34090         }
34091         function getTypeForBindingElement(declaration) {
34092             var pattern = declaration.parent;
34093             var parentType = getTypeForBindingElementParent(pattern.parent);
34094             if (!parentType || isTypeAny(parentType)) {
34095                 return parentType;
34096             }
34097             if (strictNullChecks && declaration.flags & 8388608 && ts.isParameterDeclaration(declaration)) {
34098                 parentType = getNonNullableType(parentType);
34099             }
34100             else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536)) {
34101                 parentType = getTypeWithFacts(parentType, 524288);
34102             }
34103             var type;
34104             if (pattern.kind === 189) {
34105                 if (declaration.dotDotDotToken) {
34106                     parentType = getReducedType(parentType);
34107                     if (parentType.flags & 2 || !isValidSpreadType(parentType)) {
34108                         error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types);
34109                         return errorType;
34110                     }
34111                     var literalMembers = [];
34112                     for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
34113                         var element = _a[_i];
34114                         if (!element.dotDotDotToken) {
34115                             literalMembers.push(element.propertyName || element.name);
34116                         }
34117                     }
34118                     type = getRestType(parentType, literalMembers, declaration.symbol);
34119                 }
34120                 else {
34121                     var name = declaration.propertyName || declaration.name;
34122                     var indexType = getLiteralTypeFromPropertyName(name);
34123                     var declaredType = getConstraintForLocation(getIndexedAccessType(parentType, indexType, name), declaration.name);
34124                     type = getFlowTypeOfDestructuring(declaration, declaredType);
34125                 }
34126             }
34127             else {
34128                 var elementType = checkIteratedTypeOrElementType(65, parentType, undefinedType, pattern);
34129                 var index_1 = pattern.elements.indexOf(declaration);
34130                 if (declaration.dotDotDotToken) {
34131                     type = everyType(parentType, isTupleType) ?
34132                         mapType(parentType, function (t) { return sliceTupleType(t, index_1); }) :
34133                         createArrayType(elementType);
34134                 }
34135                 else if (isArrayLikeType(parentType)) {
34136                     var indexType = getLiteralType(index_1);
34137                     var accessFlags = hasDefaultValue(declaration) ? 8 : 0;
34138                     var declaredType = getConstraintForLocation(getIndexedAccessTypeOrUndefined(parentType, indexType, declaration.name, accessFlags) || errorType, declaration.name);
34139                     type = getFlowTypeOfDestructuring(declaration, declaredType);
34140                 }
34141                 else {
34142                     type = elementType;
34143                 }
34144             }
34145             if (!declaration.initializer) {
34146                 return type;
34147             }
34148             if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
34149                 return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768) ?
34150                     getTypeWithFacts(type, 524288) :
34151                     type;
34152             }
34153             return widenTypeInferredFromInitializer(declaration, getUnionType([getTypeWithFacts(type, 524288), checkDeclarationInitializer(declaration)], 2));
34154         }
34155         function getTypeForDeclarationFromJSDocComment(declaration) {
34156             var jsdocType = ts.getJSDocType(declaration);
34157             if (jsdocType) {
34158                 return getTypeFromTypeNode(jsdocType);
34159             }
34160             return undefined;
34161         }
34162         function isNullOrUndefined(node) {
34163             var expr = ts.skipParentheses(node);
34164             return expr.kind === 100 || expr.kind === 75 && getResolvedSymbol(expr) === undefinedSymbol;
34165         }
34166         function isEmptyArrayLiteral(node) {
34167             var expr = ts.skipParentheses(node);
34168             return expr.kind === 192 && expr.elements.length === 0;
34169         }
34170         function addOptionality(type, optional) {
34171             if (optional === void 0) { optional = true; }
34172             return strictNullChecks && optional ? getOptionalType(type) : type;
34173         }
34174         function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
34175             if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 231) {
34176                 var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression)));
34177                 return indexType.flags & (262144 | 4194304) ? getExtractStringType(indexType) : stringType;
34178             }
34179             if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 232) {
34180                 var forOfStatement = declaration.parent.parent;
34181                 return checkRightHandSideOfForOf(forOfStatement) || anyType;
34182             }
34183             if (ts.isBindingPattern(declaration.parent)) {
34184                 return getTypeForBindingElement(declaration);
34185             }
34186             var isOptional = includeOptionality && (ts.isParameter(declaration) && isJSDocOptionalParameter(declaration)
34187                 || !ts.isBindingElement(declaration) && !ts.isVariableDeclaration(declaration) && !!declaration.questionToken);
34188             var declaredType = tryGetTypeFromEffectiveTypeNode(declaration);
34189             if (declaredType) {
34190                 return addOptionality(declaredType, isOptional);
34191             }
34192             if ((noImplicitAny || ts.isInJSFile(declaration)) &&
34193                 declaration.kind === 242 && !ts.isBindingPattern(declaration.name) &&
34194                 !(ts.getCombinedModifierFlags(declaration) & 1) && !(declaration.flags & 8388608)) {
34195                 if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) {
34196                     return autoType;
34197                 }
34198                 if (declaration.initializer && isEmptyArrayLiteral(declaration.initializer)) {
34199                     return autoArrayType;
34200                 }
34201             }
34202             if (declaration.kind === 156) {
34203                 var func = declaration.parent;
34204                 if (func.kind === 164 && !hasNonBindableDynamicName(func)) {
34205                     var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 163);
34206                     if (getter) {
34207                         var getterSignature = getSignatureFromDeclaration(getter);
34208                         var thisParameter = getAccessorThisParameter(func);
34209                         if (thisParameter && declaration === thisParameter) {
34210                             ts.Debug.assert(!thisParameter.type);
34211                             return getTypeOfSymbol(getterSignature.thisParameter);
34212                         }
34213                         return getReturnTypeOfSignature(getterSignature);
34214                     }
34215                 }
34216                 if (ts.isInJSFile(declaration)) {
34217                     var typeTag = ts.getJSDocType(func);
34218                     if (typeTag && ts.isFunctionTypeNode(typeTag)) {
34219                         return getTypeAtPosition(getSignatureFromDeclaration(typeTag), func.parameters.indexOf(declaration));
34220                     }
34221                 }
34222                 var type = declaration.symbol.escapedName === "this" ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
34223                 if (type) {
34224                     return addOptionality(type, isOptional);
34225                 }
34226             }
34227             else if (ts.isInJSFile(declaration)) {
34228                 var containerObjectType = getJSContainerObjectType(declaration, getSymbolOfNode(declaration), ts.getDeclaredExpandoInitializer(declaration));
34229                 if (containerObjectType) {
34230                     return containerObjectType;
34231                 }
34232             }
34233             if (declaration.initializer) {
34234                 var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration));
34235                 return addOptionality(type, isOptional);
34236             }
34237             if (ts.isJsxAttribute(declaration)) {
34238                 return trueType;
34239             }
34240             if (ts.isBindingPattern(declaration.name)) {
34241                 return getTypeFromBindingPattern(declaration.name, false, true);
34242             }
34243             return undefined;
34244         }
34245         function getWidenedTypeForAssignmentDeclaration(symbol, resolvedSymbol) {
34246             var container = ts.getAssignedExpandoInitializer(symbol.valueDeclaration);
34247             if (container) {
34248                 var tag = ts.getJSDocTypeTag(container);
34249                 if (tag && tag.typeExpression) {
34250                     return getTypeFromTypeNode(tag.typeExpression);
34251                 }
34252                 var containerObjectType = getJSContainerObjectType(symbol.valueDeclaration, symbol, container);
34253                 return containerObjectType || getWidenedLiteralType(checkExpressionCached(container));
34254             }
34255             var definedInConstructor = false;
34256             var definedInMethod = false;
34257             var jsdocType;
34258             var types;
34259             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
34260                 var declaration = _a[_i];
34261                 var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration :
34262                     ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration :
34263                         undefined;
34264                 if (!expression) {
34265                     continue;
34266                 }
34267                 var kind = ts.isAccessExpression(expression)
34268                     ? ts.getAssignmentDeclarationPropertyAccessKind(expression)
34269                     : ts.getAssignmentDeclarationKind(expression);
34270                 if (kind === 4) {
34271                     if (isDeclarationInConstructor(expression)) {
34272                         definedInConstructor = true;
34273                     }
34274                     else {
34275                         definedInMethod = true;
34276                     }
34277                 }
34278                 if (!ts.isCallExpression(expression)) {
34279                     jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration);
34280                 }
34281                 if (!jsdocType) {
34282                     (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType);
34283                 }
34284             }
34285             var type = jsdocType;
34286             if (!type) {
34287                 if (!ts.length(types)) {
34288                     return errorType;
34289                 }
34290                 var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined;
34291                 if (definedInMethod) {
34292                     var propType = getTypeOfAssignmentDeclarationPropertyOfBaseType(symbol);
34293                     if (propType) {
34294                         (constructorTypes || (constructorTypes = [])).push(propType);
34295                         definedInConstructor = true;
34296                     }
34297                 }
34298                 var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304); }) ? constructorTypes : types;
34299                 type = getUnionType(sourceTypes, 2);
34300             }
34301             var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor));
34302             if (filterType(widened, function (t) { return !!(t.flags & ~98304); }) === neverType) {
34303                 reportImplicitAny(symbol.valueDeclaration, anyType);
34304                 return anyType;
34305             }
34306             return widened;
34307         }
34308         function getJSContainerObjectType(decl, symbol, init) {
34309             if (!ts.isInJSFile(decl) || !init || !ts.isObjectLiteralExpression(init) || init.properties.length) {
34310                 return undefined;
34311             }
34312             var exports = ts.createSymbolTable();
34313             while (ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl)) {
34314                 var s_2 = getSymbolOfNode(decl);
34315                 if (s_2 && ts.hasEntries(s_2.exports)) {
34316                     mergeSymbolTable(exports, s_2.exports);
34317                 }
34318                 decl = ts.isBinaryExpression(decl) ? decl.parent : decl.parent.parent;
34319             }
34320             var s = getSymbolOfNode(decl);
34321             if (s && ts.hasEntries(s.exports)) {
34322                 mergeSymbolTable(exports, s.exports);
34323             }
34324             var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, undefined, undefined);
34325             type.objectFlags |= 16384;
34326             return type;
34327         }
34328         function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) {
34329             var typeNode = ts.getEffectiveTypeAnnotationNode(expression.parent);
34330             if (typeNode) {
34331                 var type = getWidenedType(getTypeFromTypeNode(typeNode));
34332                 if (!declaredType) {
34333                     return type;
34334                 }
34335                 else if (declaredType !== errorType && type !== errorType && !isTypeIdenticalTo(declaredType, type)) {
34336                     errorNextVariableOrPropertyDeclarationMustHaveSameType(undefined, declaredType, declaration, type);
34337                 }
34338             }
34339             if (symbol.parent) {
34340                 var typeNode_2 = ts.getEffectiveTypeAnnotationNode(symbol.parent.valueDeclaration);
34341                 if (typeNode_2) {
34342                     return getTypeOfPropertyOfType(getTypeFromTypeNode(typeNode_2), symbol.escapedName);
34343                 }
34344             }
34345             return declaredType;
34346         }
34347         function getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) {
34348             if (ts.isCallExpression(expression)) {
34349                 if (resolvedSymbol) {
34350                     return getTypeOfSymbol(resolvedSymbol);
34351                 }
34352                 var objectLitType = checkExpressionCached(expression.arguments[2]);
34353                 var valueType = getTypeOfPropertyOfType(objectLitType, "value");
34354                 if (valueType) {
34355                     return valueType;
34356                 }
34357                 var getFunc = getTypeOfPropertyOfType(objectLitType, "get");
34358                 if (getFunc) {
34359                     var getSig = getSingleCallSignature(getFunc);
34360                     if (getSig) {
34361                         return getReturnTypeOfSignature(getSig);
34362                     }
34363                 }
34364                 var setFunc = getTypeOfPropertyOfType(objectLitType, "set");
34365                 if (setFunc) {
34366                     var setSig = getSingleCallSignature(setFunc);
34367                     if (setSig) {
34368                         return getTypeOfFirstParameterOfSignature(setSig);
34369                     }
34370                 }
34371                 return anyType;
34372             }
34373             if (containsSameNamedThisProperty(expression.left, expression.right)) {
34374                 return anyType;
34375             }
34376             var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : getWidenedLiteralType(checkExpressionCached(expression.right));
34377             if (type.flags & 524288 &&
34378                 kind === 2 &&
34379                 symbol.escapedName === "export=") {
34380                 var exportedType = resolveStructuredTypeMembers(type);
34381                 var members_4 = ts.createSymbolTable();
34382                 ts.copyEntries(exportedType.members, members_4);
34383                 if (resolvedSymbol && !resolvedSymbol.exports) {
34384                     resolvedSymbol.exports = ts.createSymbolTable();
34385                 }
34386                 (resolvedSymbol || symbol).exports.forEach(function (s, name) {
34387                     var _a;
34388                     var exportedMember = members_4.get(name);
34389                     if (exportedMember && exportedMember !== s) {
34390                         if (s.flags & 111551) {
34391                             if (ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) {
34392                                 var unescapedName = ts.unescapeLeadingUnderscores(s.escapedName);
34393                                 var exportedMemberName = ((_a = ts.tryCast(exportedMember.valueDeclaration, ts.isNamedDeclaration)) === null || _a === void 0 ? void 0 : _a.name) || exportedMember.valueDeclaration;
34394                                 ts.addRelatedInfo(error(s.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(exportedMemberName, ts.Diagnostics._0_was_also_declared_here, unescapedName));
34395                                 ts.addRelatedInfo(error(exportedMemberName, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(s.valueDeclaration, ts.Diagnostics._0_was_also_declared_here, unescapedName));
34396                             }
34397                             var union = createSymbol(s.flags | exportedMember.flags, name);
34398                             union.type = getUnionType([getTypeOfSymbol(s), getTypeOfSymbol(exportedMember)]);
34399                             union.valueDeclaration = exportedMember.valueDeclaration;
34400                             union.declarations = ts.concatenate(exportedMember.declarations, s.declarations);
34401                             members_4.set(name, union);
34402                         }
34403                         else {
34404                             members_4.set(name, mergeSymbol(s, exportedMember));
34405                         }
34406                     }
34407                     else {
34408                         members_4.set(name, s);
34409                     }
34410                 });
34411                 var result = createAnonymousType(exportedType.symbol, members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.stringIndexInfo, exportedType.numberIndexInfo);
34412                 result.objectFlags |= (ts.getObjectFlags(type) & 16384);
34413                 return result;
34414             }
34415             if (isEmptyArrayLiteralType(type)) {
34416                 reportImplicitAny(expression, anyArrayType);
34417                 return anyArrayType;
34418             }
34419             return type;
34420         }
34421         function containsSameNamedThisProperty(thisProperty, expression) {
34422             return ts.isPropertyAccessExpression(thisProperty)
34423                 && thisProperty.expression.kind === 104
34424                 && ts.forEachChildRecursively(expression, function (n) { return isMatchingReference(thisProperty, n); });
34425         }
34426         function isDeclarationInConstructor(expression) {
34427             var thisContainer = ts.getThisContainer(expression, false);
34428             return thisContainer.kind === 162 ||
34429                 thisContainer.kind === 244 ||
34430                 (thisContainer.kind === 201 && !ts.isPrototypePropertyAssignment(thisContainer.parent));
34431         }
34432         function getConstructorDefinedThisAssignmentTypes(types, declarations) {
34433             ts.Debug.assert(types.length === declarations.length);
34434             return types.filter(function (_, i) {
34435                 var declaration = declarations[i];
34436                 var expression = ts.isBinaryExpression(declaration) ? declaration :
34437                     ts.isBinaryExpression(declaration.parent) ? declaration.parent : undefined;
34438                 return expression && isDeclarationInConstructor(expression);
34439             });
34440         }
34441         function getTypeOfAssignmentDeclarationPropertyOfBaseType(property) {
34442             var parentDeclaration = ts.forEach(property.declarations, function (d) {
34443                 var parent = ts.getThisContainer(d, false).parent;
34444                 return ts.isClassLike(parent) && parent;
34445             });
34446             if (parentDeclaration) {
34447                 var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(parentDeclaration));
34448                 var baseClassType = classType && getBaseTypes(classType)[0];
34449                 if (baseClassType) {
34450                     return getTypeOfPropertyOfType(baseClassType, property.escapedName);
34451                 }
34452             }
34453         }
34454         function getTypeFromBindingElement(element, includePatternInType, reportErrors) {
34455             if (element.initializer) {
34456                 var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, true, false) : unknownType;
34457                 return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, contextualType)));
34458             }
34459             if (ts.isBindingPattern(element.name)) {
34460                 return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
34461             }
34462             if (reportErrors && !declarationBelongsToPrivateAmbientMember(element)) {
34463                 reportImplicitAny(element, anyType);
34464             }
34465             return includePatternInType ? nonInferrableAnyType : anyType;
34466         }
34467         function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) {
34468             var members = ts.createSymbolTable();
34469             var stringIndexInfo;
34470             var objectFlags = 128 | 1048576;
34471             ts.forEach(pattern.elements, function (e) {
34472                 var name = e.propertyName || e.name;
34473                 if (e.dotDotDotToken) {
34474                     stringIndexInfo = createIndexInfo(anyType, false);
34475                     return;
34476                 }
34477                 var exprType = getLiteralTypeFromPropertyName(name);
34478                 if (!isTypeUsableAsPropertyName(exprType)) {
34479                     objectFlags |= 512;
34480                     return;
34481                 }
34482                 var text = getPropertyNameFromType(exprType);
34483                 var flags = 4 | (e.initializer ? 16777216 : 0);
34484                 var symbol = createSymbol(flags, text);
34485                 symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors);
34486                 symbol.bindingElement = e;
34487                 members.set(symbol.escapedName, symbol);
34488             });
34489             var result = createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined);
34490             result.objectFlags |= objectFlags;
34491             if (includePatternInType) {
34492                 result.pattern = pattern;
34493                 result.objectFlags |= 1048576;
34494             }
34495             return result;
34496         }
34497         function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) {
34498             var elements = pattern.elements;
34499             var lastElement = ts.lastOrUndefined(elements);
34500             var hasRestElement = !!(lastElement && lastElement.kind === 191 && lastElement.dotDotDotToken);
34501             if (elements.length === 0 || elements.length === 1 && hasRestElement) {
34502                 return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType;
34503             }
34504             var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); });
34505             var minLength = ts.findLastIndex(elements, function (e) { return !ts.isOmittedExpression(e) && !hasDefaultValue(e); }, elements.length - (hasRestElement ? 2 : 1)) + 1;
34506             var result = createTupleType(elementTypes, minLength, hasRestElement);
34507             if (includePatternInType) {
34508                 result = cloneTypeReference(result);
34509                 result.pattern = pattern;
34510                 result.objectFlags |= 1048576;
34511             }
34512             return result;
34513         }
34514         function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) {
34515             if (includePatternInType === void 0) { includePatternInType = false; }
34516             if (reportErrors === void 0) { reportErrors = false; }
34517             return pattern.kind === 189
34518                 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors)
34519                 : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors);
34520         }
34521         function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
34522             return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, true), declaration, reportErrors);
34523         }
34524         function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors) {
34525             if (type) {
34526                 if (reportErrors) {
34527                     reportErrorsFromWidening(declaration, type);
34528                 }
34529                 if (type.flags & 8192 && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) {
34530                     type = esSymbolType;
34531                 }
34532                 return getWidenedType(type);
34533             }
34534             type = ts.isParameter(declaration) && declaration.dotDotDotToken ? anyArrayType : anyType;
34535             if (reportErrors) {
34536                 if (!declarationBelongsToPrivateAmbientMember(declaration)) {
34537                     reportImplicitAny(declaration, type);
34538                 }
34539             }
34540             return type;
34541         }
34542         function declarationBelongsToPrivateAmbientMember(declaration) {
34543             var root = ts.getRootDeclaration(declaration);
34544             var memberDeclaration = root.kind === 156 ? root.parent : root;
34545             return isPrivateWithinAmbient(memberDeclaration);
34546         }
34547         function tryGetTypeFromEffectiveTypeNode(declaration) {
34548             var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
34549             if (typeNode) {
34550                 return getTypeFromTypeNode(typeNode);
34551             }
34552         }
34553         function getTypeOfVariableOrParameterOrProperty(symbol) {
34554             var links = getSymbolLinks(symbol);
34555             if (!links.type) {
34556                 var type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
34557                 if (!links.type) {
34558                     links.type = type;
34559                 }
34560             }
34561             return links.type;
34562         }
34563         function getTypeOfVariableOrParameterOrPropertyWorker(symbol) {
34564             if (symbol.flags & 4194304) {
34565                 return getTypeOfPrototypeProperty(symbol);
34566             }
34567             if (symbol === requireSymbol) {
34568                 return anyType;
34569             }
34570             if (symbol.flags & 134217728) {
34571                 var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration));
34572                 var members = ts.createSymbolTable();
34573                 members.set("exports", fileSymbol);
34574                 return createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, undefined, undefined);
34575             }
34576             var declaration = symbol.valueDeclaration;
34577             if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) {
34578                 return anyType;
34579             }
34580             if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
34581                 if (!declaration.statements.length) {
34582                     return emptyObjectType;
34583                 }
34584                 return getWidenedType(getWidenedLiteralType(checkExpression(declaration.statements[0].expression)));
34585             }
34586             if (!pushTypeResolution(symbol, 0)) {
34587                 if (symbol.flags & 512 && !(symbol.flags & 67108864)) {
34588                     return getTypeOfFuncClassEnumModule(symbol);
34589                 }
34590                 return reportCircularityError(symbol);
34591             }
34592             var type;
34593             if (declaration.kind === 259) {
34594                 type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration);
34595             }
34596             else if (ts.isBinaryExpression(declaration) ||
34597                 (ts.isInJSFile(declaration) &&
34598                     (ts.isCallExpression(declaration) || (ts.isPropertyAccessExpression(declaration) || ts.isBindableStaticElementAccessExpression(declaration)) && ts.isBinaryExpression(declaration.parent)))) {
34599                 type = getWidenedTypeForAssignmentDeclaration(symbol);
34600             }
34601             else if (ts.isJSDocPropertyLikeTag(declaration)
34602                 || ts.isPropertyAccessExpression(declaration)
34603                 || ts.isElementAccessExpression(declaration)
34604                 || ts.isIdentifier(declaration)
34605                 || ts.isStringLiteralLike(declaration)
34606                 || ts.isNumericLiteral(declaration)
34607                 || ts.isClassDeclaration(declaration)
34608                 || ts.isFunctionDeclaration(declaration)
34609                 || (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration))
34610                 || ts.isMethodSignature(declaration)
34611                 || ts.isSourceFile(declaration)) {
34612                 if (symbol.flags & (16 | 8192 | 32 | 384 | 512)) {
34613                     return getTypeOfFuncClassEnumModule(symbol);
34614                 }
34615                 type = ts.isBinaryExpression(declaration.parent) ?
34616                     getWidenedTypeForAssignmentDeclaration(symbol) :
34617                     tryGetTypeFromEffectiveTypeNode(declaration) || anyType;
34618             }
34619             else if (ts.isPropertyAssignment(declaration)) {
34620                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkPropertyAssignment(declaration);
34621             }
34622             else if (ts.isJsxAttribute(declaration)) {
34623                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkJsxAttribute(declaration);
34624             }
34625             else if (ts.isShorthandPropertyAssignment(declaration)) {
34626                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0);
34627             }
34628             else if (ts.isObjectLiteralMethod(declaration)) {
34629                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0);
34630             }
34631             else if (ts.isParameter(declaration)
34632                 || ts.isPropertyDeclaration(declaration)
34633                 || ts.isPropertySignature(declaration)
34634                 || ts.isVariableDeclaration(declaration)
34635                 || ts.isBindingElement(declaration)) {
34636                 type = getWidenedTypeForVariableLikeDeclaration(declaration, true);
34637             }
34638             else if (ts.isEnumDeclaration(declaration)) {
34639                 type = getTypeOfFuncClassEnumModule(symbol);
34640             }
34641             else if (ts.isEnumMember(declaration)) {
34642                 type = getTypeOfEnumMember(symbol);
34643             }
34644             else if (ts.isAccessor(declaration)) {
34645                 type = resolveTypeOfAccessors(symbol);
34646             }
34647             else {
34648                 return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol));
34649             }
34650             if (!popTypeResolution()) {
34651                 if (symbol.flags & 512 && !(symbol.flags & 67108864)) {
34652                     return getTypeOfFuncClassEnumModule(symbol);
34653                 }
34654                 return reportCircularityError(symbol);
34655             }
34656             return type;
34657         }
34658         function getAnnotatedAccessorTypeNode(accessor) {
34659             if (accessor) {
34660                 if (accessor.kind === 163) {
34661                     var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor);
34662                     return getterTypeAnnotation;
34663                 }
34664                 else {
34665                     var setterTypeAnnotation = ts.getEffectiveSetAccessorTypeAnnotationNode(accessor);
34666                     return setterTypeAnnotation;
34667                 }
34668             }
34669             return undefined;
34670         }
34671         function getAnnotatedAccessorType(accessor) {
34672             var node = getAnnotatedAccessorTypeNode(accessor);
34673             return node && getTypeFromTypeNode(node);
34674         }
34675         function getAnnotatedAccessorThisParameter(accessor) {
34676             var parameter = getAccessorThisParameter(accessor);
34677             return parameter && parameter.symbol;
34678         }
34679         function getThisTypeOfDeclaration(declaration) {
34680             return getThisTypeOfSignature(getSignatureFromDeclaration(declaration));
34681         }
34682         function getTypeOfAccessors(symbol) {
34683             var links = getSymbolLinks(symbol);
34684             return links.type || (links.type = getTypeOfAccessorsWorker(symbol));
34685         }
34686         function getTypeOfAccessorsWorker(symbol) {
34687             if (!pushTypeResolution(symbol, 0)) {
34688                 return errorType;
34689             }
34690             var type = resolveTypeOfAccessors(symbol);
34691             if (!popTypeResolution()) {
34692                 type = anyType;
34693                 if (noImplicitAny) {
34694                     var getter = ts.getDeclarationOfKind(symbol, 163);
34695                     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));
34696                 }
34697             }
34698             return type;
34699         }
34700         function resolveTypeOfAccessors(symbol) {
34701             var getter = ts.getDeclarationOfKind(symbol, 163);
34702             var setter = ts.getDeclarationOfKind(symbol, 164);
34703             if (getter && ts.isInJSFile(getter)) {
34704                 var jsDocType = getTypeForDeclarationFromJSDocComment(getter);
34705                 if (jsDocType) {
34706                     return jsDocType;
34707                 }
34708             }
34709             var getterReturnType = getAnnotatedAccessorType(getter);
34710             if (getterReturnType) {
34711                 return getterReturnType;
34712             }
34713             else {
34714                 var setterParameterType = getAnnotatedAccessorType(setter);
34715                 if (setterParameterType) {
34716                     return setterParameterType;
34717                 }
34718                 else {
34719                     if (getter && getter.body) {
34720                         return getReturnTypeFromBody(getter);
34721                     }
34722                     else {
34723                         if (setter) {
34724                             if (!isPrivateWithinAmbient(setter)) {
34725                                 errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
34726                             }
34727                         }
34728                         else {
34729                             ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function");
34730                             if (!isPrivateWithinAmbient(getter)) {
34731                                 errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
34732                             }
34733                         }
34734                         return anyType;
34735                     }
34736                 }
34737             }
34738         }
34739         function getBaseTypeVariableOfClass(symbol) {
34740             var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol));
34741             return baseConstructorType.flags & 8650752 ? baseConstructorType :
34742                 baseConstructorType.flags & 2097152 ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752); }) :
34743                     undefined;
34744         }
34745         function getTypeOfFuncClassEnumModule(symbol) {
34746             var links = getSymbolLinks(symbol);
34747             var originalLinks = links;
34748             if (!links.type) {
34749                 var jsDeclaration = symbol.valueDeclaration && ts.getDeclarationOfExpando(symbol.valueDeclaration);
34750                 if (jsDeclaration) {
34751                     var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration));
34752                     if (merged) {
34753                         symbol = links = merged;
34754                     }
34755                 }
34756                 originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol);
34757             }
34758             return links.type;
34759         }
34760         function getTypeOfFuncClassEnumModuleWorker(symbol) {
34761             var declaration = symbol.valueDeclaration;
34762             if (symbol.flags & 1536 && ts.isShorthandAmbientModuleSymbol(symbol)) {
34763                 return anyType;
34764             }
34765             else if (declaration && (declaration.kind === 209 ||
34766                 ts.isAccessExpression(declaration) &&
34767                     declaration.parent.kind === 209)) {
34768                 return getWidenedTypeForAssignmentDeclaration(symbol);
34769             }
34770             else if (symbol.flags & 512 && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) {
34771                 var resolvedModule = resolveExternalModuleSymbol(symbol);
34772                 if (resolvedModule !== symbol) {
34773                     if (!pushTypeResolution(symbol, 0)) {
34774                         return errorType;
34775                     }
34776                     var exportEquals = getMergedSymbol(symbol.exports.get("export="));
34777                     var type_1 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
34778                     if (!popTypeResolution()) {
34779                         return reportCircularityError(symbol);
34780                     }
34781                     return type_1;
34782                 }
34783             }
34784             var type = createObjectType(16, symbol);
34785             if (symbol.flags & 32) {
34786                 var baseTypeVariable = getBaseTypeVariableOfClass(symbol);
34787                 return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type;
34788             }
34789             else {
34790                 return strictNullChecks && symbol.flags & 16777216 ? getOptionalType(type) : type;
34791             }
34792         }
34793         function getTypeOfEnumMember(symbol) {
34794             var links = getSymbolLinks(symbol);
34795             return links.type || (links.type = getDeclaredTypeOfEnumMember(symbol));
34796         }
34797         function getTypeOfAlias(symbol) {
34798             var links = getSymbolLinks(symbol);
34799             if (!links.type) {
34800                 var targetSymbol = resolveAlias(symbol);
34801                 links.type = targetSymbol.flags & 111551
34802                     ? getTypeOfSymbol(targetSymbol)
34803                     : errorType;
34804             }
34805             return links.type;
34806         }
34807         function getTypeOfInstantiatedSymbol(symbol) {
34808             var links = getSymbolLinks(symbol);
34809             if (!links.type) {
34810                 if (!pushTypeResolution(symbol, 0)) {
34811                     return links.type = errorType;
34812                 }
34813                 var type = instantiateType(getTypeOfSymbol(links.target), links.mapper);
34814                 if (!popTypeResolution()) {
34815                     type = reportCircularityError(symbol);
34816                 }
34817                 links.type = type;
34818             }
34819             return links.type;
34820         }
34821         function reportCircularityError(symbol) {
34822             var declaration = symbol.valueDeclaration;
34823             if (ts.getEffectiveTypeAnnotationNode(declaration)) {
34824                 error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
34825                 return errorType;
34826             }
34827             if (noImplicitAny && (declaration.kind !== 156 || declaration.initializer)) {
34828                 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));
34829             }
34830             return anyType;
34831         }
34832         function getTypeOfSymbolWithDeferredType(symbol) {
34833             var links = getSymbolLinks(symbol);
34834             if (!links.type) {
34835                 ts.Debug.assertIsDefined(links.deferralParent);
34836                 ts.Debug.assertIsDefined(links.deferralConstituents);
34837                 links.type = links.deferralParent.flags & 1048576 ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents);
34838             }
34839             return links.type;
34840         }
34841         function getTypeOfSymbol(symbol) {
34842             var checkFlags = ts.getCheckFlags(symbol);
34843             if (checkFlags & 65536) {
34844                 return getTypeOfSymbolWithDeferredType(symbol);
34845             }
34846             if (checkFlags & 1) {
34847                 return getTypeOfInstantiatedSymbol(symbol);
34848             }
34849             if (checkFlags & 262144) {
34850                 return getTypeOfMappedSymbol(symbol);
34851             }
34852             if (checkFlags & 8192) {
34853                 return getTypeOfReverseMappedSymbol(symbol);
34854             }
34855             if (symbol.flags & (3 | 4)) {
34856                 return getTypeOfVariableOrParameterOrProperty(symbol);
34857             }
34858             if (symbol.flags & (16 | 8192 | 32 | 384 | 512)) {
34859                 return getTypeOfFuncClassEnumModule(symbol);
34860             }
34861             if (symbol.flags & 8) {
34862                 return getTypeOfEnumMember(symbol);
34863             }
34864             if (symbol.flags & 98304) {
34865                 return getTypeOfAccessors(symbol);
34866             }
34867             if (symbol.flags & 2097152) {
34868                 return getTypeOfAlias(symbol);
34869             }
34870             return errorType;
34871         }
34872         function isReferenceToType(type, target) {
34873             return type !== undefined
34874                 && target !== undefined
34875                 && (ts.getObjectFlags(type) & 4) !== 0
34876                 && type.target === target;
34877         }
34878         function getTargetType(type) {
34879             return ts.getObjectFlags(type) & 4 ? type.target : type;
34880         }
34881         function hasBaseType(type, checkBase) {
34882             return check(type);
34883             function check(type) {
34884                 if (ts.getObjectFlags(type) & (3 | 4)) {
34885                     var target = getTargetType(type);
34886                     return target === checkBase || ts.some(getBaseTypes(target), check);
34887                 }
34888                 else if (type.flags & 2097152) {
34889                     return ts.some(type.types, check);
34890                 }
34891                 return false;
34892             }
34893         }
34894         function appendTypeParameters(typeParameters, declarations) {
34895             for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) {
34896                 var declaration = declarations_2[_i];
34897                 typeParameters = ts.appendIfUnique(typeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)));
34898             }
34899             return typeParameters;
34900         }
34901         function getOuterTypeParameters(node, includeThisTypes) {
34902             while (true) {
34903                 node = node.parent;
34904                 if (node && ts.isBinaryExpression(node)) {
34905                     var assignmentKind = ts.getAssignmentDeclarationKind(node);
34906                     if (assignmentKind === 6 || assignmentKind === 3) {
34907                         var symbol = getSymbolOfNode(node.left);
34908                         if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) {
34909                             node = symbol.parent.valueDeclaration;
34910                         }
34911                     }
34912                 }
34913                 if (!node) {
34914                     return undefined;
34915                 }
34916                 switch (node.kind) {
34917                     case 225:
34918                     case 245:
34919                     case 214:
34920                     case 246:
34921                     case 165:
34922                     case 166:
34923                     case 160:
34924                     case 170:
34925                     case 171:
34926                     case 300:
34927                     case 244:
34928                     case 161:
34929                     case 201:
34930                     case 202:
34931                     case 247:
34932                     case 321:
34933                     case 322:
34934                     case 316:
34935                     case 315:
34936                     case 186:
34937                     case 180:
34938                         var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes);
34939                         if (node.kind === 186) {
34940                             return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)));
34941                         }
34942                         else if (node.kind === 180) {
34943                             return ts.concatenate(outerTypeParameters, getInferTypeParameters(node));
34944                         }
34945                         else if (node.kind === 225 && !ts.isInJSFile(node)) {
34946                             break;
34947                         }
34948                         var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node));
34949                         var thisType = includeThisTypes &&
34950                             (node.kind === 245 || node.kind === 214 || node.kind === 246 || isJSConstructor(node)) &&
34951                             getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType;
34952                         return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters;
34953                 }
34954             }
34955         }
34956         function getOuterTypeParametersOfClassOrInterface(symbol) {
34957             var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 246);
34958             ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations");
34959             return getOuterTypeParameters(declaration);
34960         }
34961         function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) {
34962             var result;
34963             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
34964                 var node = _a[_i];
34965                 if (node.kind === 246 ||
34966                     node.kind === 245 ||
34967                     node.kind === 214 ||
34968                     isJSConstructor(node) ||
34969                     ts.isTypeAlias(node)) {
34970                     var declaration = node;
34971                     result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration));
34972                 }
34973             }
34974             return result;
34975         }
34976         function getTypeParametersOfClassOrInterface(symbol) {
34977             return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol));
34978         }
34979         function isMixinConstructorType(type) {
34980             var signatures = getSignaturesOfType(type, 1);
34981             if (signatures.length === 1) {
34982                 var s = signatures[0];
34983                 return !s.typeParameters && s.parameters.length === 1 && signatureHasRestParameter(s) && getElementTypeOfArrayType(getTypeOfParameter(s.parameters[0])) === anyType;
34984             }
34985             return false;
34986         }
34987         function isConstructorType(type) {
34988             if (getSignaturesOfType(type, 1).length > 0) {
34989                 return true;
34990             }
34991             if (type.flags & 8650752) {
34992                 var constraint = getBaseConstraintOfType(type);
34993                 return !!constraint && isMixinConstructorType(constraint);
34994             }
34995             return false;
34996         }
34997         function getBaseTypeNodeOfClass(type) {
34998             return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration);
34999         }
35000         function getConstructorsForTypeArguments(type, typeArgumentNodes, location) {
35001             var typeArgCount = ts.length(typeArgumentNodes);
35002             var isJavascript = ts.isInJSFile(location);
35003             return ts.filter(getSignaturesOfType(type, 1), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); });
35004         }
35005         function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) {
35006             var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location);
35007             var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode);
35008             return ts.sameMap(signatures, function (sig) { return ts.some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments, ts.isInJSFile(location)) : sig; });
35009         }
35010         function getBaseConstructorTypeOfClass(type) {
35011             if (!type.resolvedBaseConstructorType) {
35012                 var decl = type.symbol.valueDeclaration;
35013                 var extended = ts.getEffectiveBaseTypeNode(decl);
35014                 var baseTypeNode = getBaseTypeNodeOfClass(type);
35015                 if (!baseTypeNode) {
35016                     return type.resolvedBaseConstructorType = undefinedType;
35017                 }
35018                 if (!pushTypeResolution(type, 1)) {
35019                     return errorType;
35020                 }
35021                 var baseConstructorType = checkExpression(baseTypeNode.expression);
35022                 if (extended && baseTypeNode !== extended) {
35023                     ts.Debug.assert(!extended.typeArguments);
35024                     checkExpression(extended.expression);
35025                 }
35026                 if (baseConstructorType.flags & (524288 | 2097152)) {
35027                     resolveStructuredTypeMembers(baseConstructorType);
35028                 }
35029                 if (!popTypeResolution()) {
35030                     error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol));
35031                     return type.resolvedBaseConstructorType = errorType;
35032                 }
35033                 if (!(baseConstructorType.flags & 1) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) {
35034                     var err = error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType));
35035                     if (baseConstructorType.flags & 262144) {
35036                         var constraint = getConstraintFromTypeParameter(baseConstructorType);
35037                         var ctorReturn = unknownType;
35038                         if (constraint) {
35039                             var ctorSig = getSignaturesOfType(constraint, 1);
35040                             if (ctorSig[0]) {
35041                                 ctorReturn = getReturnTypeOfSignature(ctorSig[0]);
35042                             }
35043                         }
35044                         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)));
35045                     }
35046                     return type.resolvedBaseConstructorType = errorType;
35047                 }
35048                 type.resolvedBaseConstructorType = baseConstructorType;
35049             }
35050             return type.resolvedBaseConstructorType;
35051         }
35052         function getImplementsTypes(type) {
35053             var resolvedImplementsTypes = ts.emptyArray;
35054             for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) {
35055                 var declaration = _a[_i];
35056                 var implementsTypeNodes = ts.getEffectiveImplementsTypeNodes(declaration);
35057                 if (!implementsTypeNodes)
35058                     continue;
35059                 for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) {
35060                     var node = implementsTypeNodes_1[_b];
35061                     var implementsType = getTypeFromTypeNode(node);
35062                     if (implementsType !== errorType) {
35063                         if (resolvedImplementsTypes === ts.emptyArray) {
35064                             resolvedImplementsTypes = [implementsType];
35065                         }
35066                         else {
35067                             resolvedImplementsTypes.push(implementsType);
35068                         }
35069                     }
35070                 }
35071             }
35072             return resolvedImplementsTypes;
35073         }
35074         function getBaseTypes(type) {
35075             if (!type.resolvedBaseTypes) {
35076                 if (type.objectFlags & 8) {
35077                     type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters || ts.emptyArray), type.readonly)];
35078                 }
35079                 else if (type.symbol.flags & (32 | 64)) {
35080                     if (type.symbol.flags & 32) {
35081                         resolveBaseTypesOfClass(type);
35082                     }
35083                     if (type.symbol.flags & 64) {
35084                         resolveBaseTypesOfInterface(type);
35085                     }
35086                 }
35087                 else {
35088                     ts.Debug.fail("type must be class or interface");
35089                 }
35090             }
35091             return type.resolvedBaseTypes;
35092         }
35093         function resolveBaseTypesOfClass(type) {
35094             type.resolvedBaseTypes = ts.resolvingEmptyArray;
35095             var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type));
35096             if (!(baseConstructorType.flags & (524288 | 2097152 | 1))) {
35097                 return type.resolvedBaseTypes = ts.emptyArray;
35098             }
35099             var baseTypeNode = getBaseTypeNodeOfClass(type);
35100             var baseType;
35101             var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined;
35102             if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 &&
35103                 areAllOuterTypeParametersApplied(originalBaseType)) {
35104                 baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol);
35105             }
35106             else if (baseConstructorType.flags & 1) {
35107                 baseType = baseConstructorType;
35108             }
35109             else {
35110                 var constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments, baseTypeNode);
35111                 if (!constructors.length) {
35112                     error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments);
35113                     return type.resolvedBaseTypes = ts.emptyArray;
35114                 }
35115                 baseType = getReturnTypeOfSignature(constructors[0]);
35116             }
35117             if (baseType === errorType) {
35118                 return type.resolvedBaseTypes = ts.emptyArray;
35119             }
35120             var reducedBaseType = getReducedType(baseType);
35121             if (!isValidBaseType(reducedBaseType)) {
35122                 var elaboration = elaborateNeverIntersection(undefined, baseType);
35123                 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));
35124                 diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(baseTypeNode.expression, diagnostic));
35125                 return type.resolvedBaseTypes = ts.emptyArray;
35126             }
35127             if (type === reducedBaseType || hasBaseType(reducedBaseType, type)) {
35128                 error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 2));
35129                 return type.resolvedBaseTypes = ts.emptyArray;
35130             }
35131             if (type.resolvedBaseTypes === ts.resolvingEmptyArray) {
35132                 type.members = undefined;
35133             }
35134             return type.resolvedBaseTypes = [reducedBaseType];
35135         }
35136         function areAllOuterTypeParametersApplied(type) {
35137             var outerTypeParameters = type.outerTypeParameters;
35138             if (outerTypeParameters) {
35139                 var last_1 = outerTypeParameters.length - 1;
35140                 var typeArguments = getTypeArguments(type);
35141                 return outerTypeParameters[last_1].symbol !== typeArguments[last_1].symbol;
35142             }
35143             return true;
35144         }
35145         function isValidBaseType(type) {
35146             if (type.flags & 262144) {
35147                 var constraint = getBaseConstraintOfType(type);
35148                 if (constraint) {
35149                     return isValidBaseType(constraint);
35150                 }
35151             }
35152             return !!(type.flags & (524288 | 67108864 | 1) && !isGenericMappedType(type) ||
35153                 type.flags & 2097152 && ts.every(type.types, isValidBaseType));
35154         }
35155         function resolveBaseTypesOfInterface(type) {
35156             type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray;
35157             for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) {
35158                 var declaration = _a[_i];
35159                 if (declaration.kind === 246 && ts.getInterfaceBaseTypeNodes(declaration)) {
35160                     for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) {
35161                         var node = _c[_b];
35162                         var baseType = getReducedType(getTypeFromTypeNode(node));
35163                         if (baseType !== errorType) {
35164                             if (isValidBaseType(baseType)) {
35165                                 if (type !== baseType && !hasBaseType(baseType, type)) {
35166                                     if (type.resolvedBaseTypes === ts.emptyArray) {
35167                                         type.resolvedBaseTypes = [baseType];
35168                                     }
35169                                     else {
35170                                         type.resolvedBaseTypes.push(baseType);
35171                                     }
35172                                 }
35173                                 else {
35174                                     error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 2));
35175                                 }
35176                             }
35177                             else {
35178                                 error(node, ts.Diagnostics.An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members);
35179                             }
35180                         }
35181                     }
35182                 }
35183             }
35184         }
35185         function isThislessInterface(symbol) {
35186             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
35187                 var declaration = _a[_i];
35188                 if (declaration.kind === 246) {
35189                     if (declaration.flags & 128) {
35190                         return false;
35191                     }
35192                     var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration);
35193                     if (baseTypeNodes) {
35194                         for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) {
35195                             var node = baseTypeNodes_1[_b];
35196                             if (ts.isEntityNameExpression(node.expression)) {
35197                                 var baseSymbol = resolveEntityName(node.expression, 788968, true);
35198                                 if (!baseSymbol || !(baseSymbol.flags & 64) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) {
35199                                     return false;
35200                                 }
35201                             }
35202                         }
35203                     }
35204                 }
35205             }
35206             return true;
35207         }
35208         function getDeclaredTypeOfClassOrInterface(symbol) {
35209             var links = getSymbolLinks(symbol);
35210             var originalLinks = links;
35211             if (!links.declaredType) {
35212                 var kind = symbol.flags & 32 ? 1 : 2;
35213                 var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration));
35214                 if (merged) {
35215                     symbol = links = merged;
35216                 }
35217                 var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol);
35218                 var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol);
35219                 var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
35220                 if (outerTypeParameters || localTypeParameters || kind === 1 || !isThislessInterface(symbol)) {
35221                     type.objectFlags |= 4;
35222                     type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters);
35223                     type.outerTypeParameters = outerTypeParameters;
35224                     type.localTypeParameters = localTypeParameters;
35225                     type.instantiations = ts.createMap();
35226                     type.instantiations.set(getTypeListId(type.typeParameters), type);
35227                     type.target = type;
35228                     type.resolvedTypeArguments = type.typeParameters;
35229                     type.thisType = createTypeParameter(symbol);
35230                     type.thisType.isThisType = true;
35231                     type.thisType.constraint = type;
35232                 }
35233             }
35234             return links.declaredType;
35235         }
35236         function getDeclaredTypeOfTypeAlias(symbol) {
35237             var links = getSymbolLinks(symbol);
35238             if (!links.declaredType) {
35239                 if (!pushTypeResolution(symbol, 2)) {
35240                     return errorType;
35241                 }
35242                 var declaration = ts.Debug.checkDefined(ts.find(symbol.declarations, ts.isTypeAlias), "Type alias symbol with no valid declaration found");
35243                 var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type;
35244                 var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType;
35245                 if (popTypeResolution()) {
35246                     var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
35247                     if (typeParameters) {
35248                         links.typeParameters = typeParameters;
35249                         links.instantiations = ts.createMap();
35250                         links.instantiations.set(getTypeListId(typeParameters), type);
35251                     }
35252                 }
35253                 else {
35254                     type = errorType;
35255                     error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
35256                 }
35257                 links.declaredType = type;
35258             }
35259             return links.declaredType;
35260         }
35261         function isStringConcatExpression(expr) {
35262             if (ts.isStringLiteralLike(expr)) {
35263                 return true;
35264             }
35265             else if (expr.kind === 209) {
35266                 return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right);
35267             }
35268             return false;
35269         }
35270         function isLiteralEnumMember(member) {
35271             var expr = member.initializer;
35272             if (!expr) {
35273                 return !(member.flags & 8388608);
35274             }
35275             switch (expr.kind) {
35276                 case 10:
35277                 case 8:
35278                 case 14:
35279                     return true;
35280                 case 207:
35281                     return expr.operator === 40 &&
35282                         expr.operand.kind === 8;
35283                 case 75:
35284                     return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText);
35285                 case 209:
35286                     return isStringConcatExpression(expr);
35287                 default:
35288                     return false;
35289             }
35290         }
35291         function getEnumKind(symbol) {
35292             var links = getSymbolLinks(symbol);
35293             if (links.enumKind !== undefined) {
35294                 return links.enumKind;
35295             }
35296             var hasNonLiteralMember = false;
35297             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
35298                 var declaration = _a[_i];
35299                 if (declaration.kind === 248) {
35300                     for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) {
35301                         var member = _c[_b];
35302                         if (member.initializer && ts.isStringLiteralLike(member.initializer)) {
35303                             return links.enumKind = 1;
35304                         }
35305                         if (!isLiteralEnumMember(member)) {
35306                             hasNonLiteralMember = true;
35307                         }
35308                     }
35309                 }
35310             }
35311             return links.enumKind = hasNonLiteralMember ? 0 : 1;
35312         }
35313         function getBaseTypeOfEnumLiteralType(type) {
35314             return type.flags & 1024 && !(type.flags & 1048576) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type;
35315         }
35316         function getDeclaredTypeOfEnum(symbol) {
35317             var links = getSymbolLinks(symbol);
35318             if (links.declaredType) {
35319                 return links.declaredType;
35320             }
35321             if (getEnumKind(symbol) === 1) {
35322                 enumCount++;
35323                 var memberTypeList = [];
35324                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
35325                     var declaration = _a[_i];
35326                     if (declaration.kind === 248) {
35327                         for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) {
35328                             var member = _c[_b];
35329                             var value = getEnumMemberValue(member);
35330                             var memberType = getFreshTypeOfLiteralType(getLiteralType(value !== undefined ? value : 0, enumCount, getSymbolOfNode(member)));
35331                             getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType;
35332                             memberTypeList.push(getRegularTypeOfLiteralType(memberType));
35333                         }
35334                     }
35335                 }
35336                 if (memberTypeList.length) {
35337                     var enumType_1 = getUnionType(memberTypeList, 1, symbol, undefined);
35338                     if (enumType_1.flags & 1048576) {
35339                         enumType_1.flags |= 1024;
35340                         enumType_1.symbol = symbol;
35341                     }
35342                     return links.declaredType = enumType_1;
35343                 }
35344             }
35345             var enumType = createType(32);
35346             enumType.symbol = symbol;
35347             return links.declaredType = enumType;
35348         }
35349         function getDeclaredTypeOfEnumMember(symbol) {
35350             var links = getSymbolLinks(symbol);
35351             if (!links.declaredType) {
35352                 var enumType = getDeclaredTypeOfEnum(getParentOfSymbol(symbol));
35353                 if (!links.declaredType) {
35354                     links.declaredType = enumType;
35355                 }
35356             }
35357             return links.declaredType;
35358         }
35359         function getDeclaredTypeOfTypeParameter(symbol) {
35360             var links = getSymbolLinks(symbol);
35361             return links.declaredType || (links.declaredType = createTypeParameter(symbol));
35362         }
35363         function getDeclaredTypeOfAlias(symbol) {
35364             var links = getSymbolLinks(symbol);
35365             return links.declaredType || (links.declaredType = getDeclaredTypeOfSymbol(resolveAlias(symbol)));
35366         }
35367         function getDeclaredTypeOfSymbol(symbol) {
35368             return tryGetDeclaredTypeOfSymbol(symbol) || errorType;
35369         }
35370         function tryGetDeclaredTypeOfSymbol(symbol) {
35371             if (symbol.flags & (32 | 64)) {
35372                 return getDeclaredTypeOfClassOrInterface(symbol);
35373             }
35374             if (symbol.flags & 524288) {
35375                 return getDeclaredTypeOfTypeAlias(symbol);
35376             }
35377             if (symbol.flags & 262144) {
35378                 return getDeclaredTypeOfTypeParameter(symbol);
35379             }
35380             if (symbol.flags & 384) {
35381                 return getDeclaredTypeOfEnum(symbol);
35382             }
35383             if (symbol.flags & 8) {
35384                 return getDeclaredTypeOfEnumMember(symbol);
35385             }
35386             if (symbol.flags & 2097152) {
35387                 return getDeclaredTypeOfAlias(symbol);
35388             }
35389             return undefined;
35390         }
35391         function isThislessType(node) {
35392             switch (node.kind) {
35393                 case 125:
35394                 case 148:
35395                 case 143:
35396                 case 140:
35397                 case 151:
35398                 case 128:
35399                 case 144:
35400                 case 141:
35401                 case 110:
35402                 case 146:
35403                 case 100:
35404                 case 137:
35405                 case 187:
35406                     return true;
35407                 case 174:
35408                     return isThislessType(node.elementType);
35409                 case 169:
35410                     return !node.typeArguments || node.typeArguments.every(isThislessType);
35411             }
35412             return false;
35413         }
35414         function isThislessTypeParameter(node) {
35415             var constraint = ts.getEffectiveConstraintOfTypeParameter(node);
35416             return !constraint || isThislessType(constraint);
35417         }
35418         function isThislessVariableLikeDeclaration(node) {
35419             var typeNode = ts.getEffectiveTypeAnnotationNode(node);
35420             return typeNode ? isThislessType(typeNode) : !ts.hasInitializer(node);
35421         }
35422         function isThislessFunctionLikeDeclaration(node) {
35423             var returnType = ts.getEffectiveReturnTypeNode(node);
35424             var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
35425             return (node.kind === 162 || (!!returnType && isThislessType(returnType))) &&
35426                 node.parameters.every(isThislessVariableLikeDeclaration) &&
35427                 typeParameters.every(isThislessTypeParameter);
35428         }
35429         function isThisless(symbol) {
35430             if (symbol.declarations && symbol.declarations.length === 1) {
35431                 var declaration = symbol.declarations[0];
35432                 if (declaration) {
35433                     switch (declaration.kind) {
35434                         case 159:
35435                         case 158:
35436                             return isThislessVariableLikeDeclaration(declaration);
35437                         case 161:
35438                         case 160:
35439                         case 162:
35440                         case 163:
35441                         case 164:
35442                             return isThislessFunctionLikeDeclaration(declaration);
35443                     }
35444                 }
35445             }
35446             return false;
35447         }
35448         function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) {
35449             var result = ts.createSymbolTable();
35450             for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
35451                 var symbol = symbols_2[_i];
35452                 result.set(symbol.escapedName, mappingThisOnly && isThisless(symbol) ? symbol : instantiateSymbol(symbol, mapper));
35453             }
35454             return result;
35455         }
35456         function addInheritedMembers(symbols, baseSymbols) {
35457             for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) {
35458                 var s = baseSymbols_1[_i];
35459                 if (!symbols.has(s.escapedName) && !isStaticPrivateIdentifierProperty(s)) {
35460                     symbols.set(s.escapedName, s);
35461                 }
35462             }
35463         }
35464         function isStaticPrivateIdentifierProperty(s) {
35465             return !!s.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(s.valueDeclaration) && ts.hasModifier(s.valueDeclaration, 32);
35466         }
35467         function resolveDeclaredMembers(type) {
35468             if (!type.declaredProperties) {
35469                 var symbol = type.symbol;
35470                 var members = getMembersOfSymbol(symbol);
35471                 type.declaredProperties = getNamedMembers(members);
35472                 type.declaredCallSignatures = ts.emptyArray;
35473                 type.declaredConstructSignatures = ts.emptyArray;
35474                 type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call"));
35475                 type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new"));
35476                 type.declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, 0);
35477                 type.declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, 1);
35478             }
35479             return type;
35480         }
35481         function isTypeUsableAsPropertyName(type) {
35482             return !!(type.flags & 8576);
35483         }
35484         function isLateBindableName(node) {
35485             if (!ts.isComputedPropertyName(node) && !ts.isElementAccessExpression(node)) {
35486                 return false;
35487             }
35488             var expr = ts.isComputedPropertyName(node) ? node.expression : node.argumentExpression;
35489             return ts.isEntityNameExpression(expr)
35490                 && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr));
35491         }
35492         function isLateBoundName(name) {
35493             return name.charCodeAt(0) === 95 &&
35494                 name.charCodeAt(1) === 95 &&
35495                 name.charCodeAt(2) === 64;
35496         }
35497         function hasLateBindableName(node) {
35498             var name = ts.getNameOfDeclaration(node);
35499             return !!name && isLateBindableName(name);
35500         }
35501         function hasNonBindableDynamicName(node) {
35502             return ts.hasDynamicName(node) && !hasLateBindableName(node);
35503         }
35504         function isNonBindableDynamicName(node) {
35505             return ts.isDynamicName(node) && !isLateBindableName(node);
35506         }
35507         function getPropertyNameFromType(type) {
35508             if (type.flags & 8192) {
35509                 return type.escapedName;
35510             }
35511             if (type.flags & (128 | 256)) {
35512                 return ts.escapeLeadingUnderscores("" + type.value);
35513             }
35514             return ts.Debug.fail();
35515         }
35516         function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) {
35517             ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096), "Expected a late-bound symbol.");
35518             symbol.flags |= symbolFlags;
35519             getSymbolLinks(member.symbol).lateSymbol = symbol;
35520             if (!symbol.declarations) {
35521                 symbol.declarations = [member];
35522             }
35523             else {
35524                 symbol.declarations.push(member);
35525             }
35526             if (symbolFlags & 111551) {
35527                 if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) {
35528                     symbol.valueDeclaration = member;
35529                 }
35530             }
35531         }
35532         function lateBindMember(parent, earlySymbols, lateSymbols, decl) {
35533             ts.Debug.assert(!!decl.symbol, "The member is expected to have a symbol.");
35534             var links = getNodeLinks(decl);
35535             if (!links.resolvedSymbol) {
35536                 links.resolvedSymbol = decl.symbol;
35537                 var declName = ts.isBinaryExpression(decl) ? decl.left : decl.name;
35538                 var type = ts.isElementAccessExpression(declName) ? checkExpressionCached(declName.argumentExpression) : checkComputedPropertyName(declName);
35539                 if (isTypeUsableAsPropertyName(type)) {
35540                     var memberName = getPropertyNameFromType(type);
35541                     var symbolFlags = decl.symbol.flags;
35542                     var lateSymbol = lateSymbols.get(memberName);
35543                     if (!lateSymbol)
35544                         lateSymbols.set(memberName, lateSymbol = createSymbol(0, memberName, 4096));
35545                     var earlySymbol = earlySymbols && earlySymbols.get(memberName);
35546                     if (lateSymbol.flags & getExcludedSymbolFlags(symbolFlags) || earlySymbol) {
35547                         var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
35548                         var name_3 = !(type.flags & 8192) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName);
35549                         ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_3); });
35550                         error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_3);
35551                         lateSymbol = createSymbol(0, memberName, 4096);
35552                     }
35553                     lateSymbol.nameType = type;
35554                     addDeclarationToLateBoundSymbol(lateSymbol, decl, symbolFlags);
35555                     if (lateSymbol.parent) {
35556                         ts.Debug.assert(lateSymbol.parent === parent, "Existing symbol parent should match new one");
35557                     }
35558                     else {
35559                         lateSymbol.parent = parent;
35560                     }
35561                     return links.resolvedSymbol = lateSymbol;
35562                 }
35563             }
35564             return links.resolvedSymbol;
35565         }
35566         function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) {
35567             var links = getSymbolLinks(symbol);
35568             if (!links[resolutionKind]) {
35569                 var isStatic = resolutionKind === "resolvedExports";
35570                 var earlySymbols = !isStatic ? symbol.members :
35571                     symbol.flags & 1536 ? getExportsOfModuleWorker(symbol) :
35572                         symbol.exports;
35573                 links[resolutionKind] = earlySymbols || emptySymbols;
35574                 var lateSymbols = ts.createSymbolTable();
35575                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
35576                     var decl = _a[_i];
35577                     var members = ts.getMembersOfDeclaration(decl);
35578                     if (members) {
35579                         for (var _b = 0, members_5 = members; _b < members_5.length; _b++) {
35580                             var member = members_5[_b];
35581                             if (isStatic === ts.hasStaticModifier(member) && hasLateBindableName(member)) {
35582                                 lateBindMember(symbol, earlySymbols, lateSymbols, member);
35583                             }
35584                         }
35585                     }
35586                 }
35587                 var assignments = symbol.assignmentDeclarationMembers;
35588                 if (assignments) {
35589                     var decls = ts.arrayFrom(assignments.values());
35590                     for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) {
35591                         var member = decls_1[_c];
35592                         var assignmentKind = ts.getAssignmentDeclarationKind(member);
35593                         var isInstanceMember = assignmentKind === 3
35594                             || assignmentKind === 4
35595                             || assignmentKind === 9
35596                             || assignmentKind === 6;
35597                         if (isStatic === !isInstanceMember && hasLateBindableName(member)) {
35598                             lateBindMember(symbol, earlySymbols, lateSymbols, member);
35599                         }
35600                     }
35601                 }
35602                 links[resolutionKind] = combineSymbolTables(earlySymbols, lateSymbols) || emptySymbols;
35603             }
35604             return links[resolutionKind];
35605         }
35606         function getMembersOfSymbol(symbol) {
35607             return symbol.flags & 6256
35608                 ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers")
35609                 : symbol.members || emptySymbols;
35610         }
35611         function getLateBoundSymbol(symbol) {
35612             if (symbol.flags & 106500 && symbol.escapedName === "__computed") {
35613                 var links = getSymbolLinks(symbol);
35614                 if (!links.lateSymbol && ts.some(symbol.declarations, hasLateBindableName)) {
35615                     var parent = getMergedSymbol(symbol.parent);
35616                     if (ts.some(symbol.declarations, ts.hasStaticModifier)) {
35617                         getExportsOfSymbol(parent);
35618                     }
35619                     else {
35620                         getMembersOfSymbol(parent);
35621                     }
35622                 }
35623                 return links.lateSymbol || (links.lateSymbol = symbol);
35624             }
35625             return symbol;
35626         }
35627         function getTypeWithThisArgument(type, thisArgument, needApparentType) {
35628             if (ts.getObjectFlags(type) & 4) {
35629                 var target = type.target;
35630                 var typeArguments = getTypeArguments(type);
35631                 if (ts.length(target.typeParameters) === ts.length(typeArguments)) {
35632                     var ref = createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType]));
35633                     return needApparentType ? getApparentType(ref) : ref;
35634                 }
35635             }
35636             else if (type.flags & 2097152) {
35637                 return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); }));
35638             }
35639             return needApparentType ? getApparentType(type) : type;
35640         }
35641         function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) {
35642             var mapper;
35643             var members;
35644             var callSignatures;
35645             var constructSignatures;
35646             var stringIndexInfo;
35647             var numberIndexInfo;
35648             if (ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) {
35649                 members = source.symbol ? getMembersOfSymbol(source.symbol) : ts.createSymbolTable(source.declaredProperties);
35650                 callSignatures = source.declaredCallSignatures;
35651                 constructSignatures = source.declaredConstructSignatures;
35652                 stringIndexInfo = source.declaredStringIndexInfo;
35653                 numberIndexInfo = source.declaredNumberIndexInfo;
35654             }
35655             else {
35656                 mapper = createTypeMapper(typeParameters, typeArguments);
35657                 members = createInstantiatedSymbolTable(source.declaredProperties, mapper, typeParameters.length === 1);
35658                 callSignatures = instantiateSignatures(source.declaredCallSignatures, mapper);
35659                 constructSignatures = instantiateSignatures(source.declaredConstructSignatures, mapper);
35660                 stringIndexInfo = instantiateIndexInfo(source.declaredStringIndexInfo, mapper);
35661                 numberIndexInfo = instantiateIndexInfo(source.declaredNumberIndexInfo, mapper);
35662             }
35663             var baseTypes = getBaseTypes(source);
35664             if (baseTypes.length) {
35665                 if (source.symbol && members === getMembersOfSymbol(source.symbol)) {
35666                     members = ts.createSymbolTable(source.declaredProperties);
35667                 }
35668                 setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
35669                 var thisArgument = ts.lastOrUndefined(typeArguments);
35670                 for (var _i = 0, baseTypes_1 = baseTypes; _i < baseTypes_1.length; _i++) {
35671                     var baseType = baseTypes_1[_i];
35672                     var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType;
35673                     addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType));
35674                     callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0));
35675                     constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1));
35676                     if (!stringIndexInfo) {
35677                         stringIndexInfo = instantiatedBaseType === anyType ?
35678                             createIndexInfo(anyType, false) :
35679                             getIndexInfoOfType(instantiatedBaseType, 0);
35680                     }
35681                     numberIndexInfo = numberIndexInfo || getIndexInfoOfType(instantiatedBaseType, 1);
35682                 }
35683             }
35684             setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
35685         }
35686         function resolveClassOrInterfaceMembers(type) {
35687             resolveObjectTypeMembers(type, resolveDeclaredMembers(type), ts.emptyArray, ts.emptyArray);
35688         }
35689         function resolveTypeReferenceMembers(type) {
35690             var source = resolveDeclaredMembers(type.target);
35691             var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]);
35692             var typeArguments = getTypeArguments(type);
35693             var paddedTypeArguments = typeArguments.length === typeParameters.length ? typeArguments : ts.concatenate(typeArguments, [type]);
35694             resolveObjectTypeMembers(type, source, typeParameters, paddedTypeArguments);
35695         }
35696         function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, flags) {
35697             var sig = new Signature(checker, flags);
35698             sig.declaration = declaration;
35699             sig.typeParameters = typeParameters;
35700             sig.parameters = parameters;
35701             sig.thisParameter = thisParameter;
35702             sig.resolvedReturnType = resolvedReturnType;
35703             sig.resolvedTypePredicate = resolvedTypePredicate;
35704             sig.minArgumentCount = minArgumentCount;
35705             sig.target = undefined;
35706             sig.mapper = undefined;
35707             sig.unionSignatures = undefined;
35708             return sig;
35709         }
35710         function cloneSignature(sig) {
35711             var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, undefined, undefined, sig.minArgumentCount, sig.flags & 3);
35712             result.target = sig.target;
35713             result.mapper = sig.mapper;
35714             result.unionSignatures = sig.unionSignatures;
35715             return result;
35716         }
35717         function createUnionSignature(signature, unionSignatures) {
35718             var result = cloneSignature(signature);
35719             result.unionSignatures = unionSignatures;
35720             result.target = undefined;
35721             result.mapper = undefined;
35722             return result;
35723         }
35724         function getOptionalCallSignature(signature, callChainFlags) {
35725             if ((signature.flags & 12) === callChainFlags) {
35726                 return signature;
35727             }
35728             if (!signature.optionalCallSignatureCache) {
35729                 signature.optionalCallSignatureCache = {};
35730             }
35731             var key = callChainFlags === 4 ? "inner" : "outer";
35732             return signature.optionalCallSignatureCache[key]
35733                 || (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags));
35734         }
35735         function createOptionalCallSignature(signature, callChainFlags) {
35736             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.");
35737             var result = cloneSignature(signature);
35738             result.flags |= callChainFlags;
35739             return result;
35740         }
35741         function getExpandedParameters(sig) {
35742             if (signatureHasRestParameter(sig)) {
35743                 var restIndex_1 = sig.parameters.length - 1;
35744                 var restParameter = sig.parameters[restIndex_1];
35745                 var restType = getTypeOfSymbol(restParameter);
35746                 if (isTupleType(restType)) {
35747                     var elementTypes = getTypeArguments(restType);
35748                     var minLength_1 = restType.target.minLength;
35749                     var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1;
35750                     var restParams = ts.map(elementTypes, function (t, i) {
35751                         var name = getParameterNameAtPosition(sig, restIndex_1 + i);
35752                         var checkFlags = i === tupleRestIndex_1 ? 32768 :
35753                             i >= minLength_1 ? 16384 : 0;
35754                         var symbol = createSymbol(1, name, checkFlags);
35755                         symbol.type = i === tupleRestIndex_1 ? createArrayType(t) : t;
35756                         return symbol;
35757                     });
35758                     return ts.concatenate(sig.parameters.slice(0, restIndex_1), restParams);
35759                 }
35760             }
35761             return sig.parameters;
35762         }
35763         function getDefaultConstructSignatures(classType) {
35764             var baseConstructorType = getBaseConstructorTypeOfClass(classType);
35765             var baseSignatures = getSignaturesOfType(baseConstructorType, 1);
35766             if (baseSignatures.length === 0) {
35767                 return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, undefined, 0, 0)];
35768             }
35769             var baseTypeNode = getBaseTypeNodeOfClass(classType);
35770             var isJavaScript = ts.isInJSFile(baseTypeNode);
35771             var typeArguments = typeArgumentsFromTypeReferenceNode(baseTypeNode);
35772             var typeArgCount = ts.length(typeArguments);
35773             var result = [];
35774             for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) {
35775                 var baseSig = baseSignatures_1[_i];
35776                 var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters);
35777                 var typeParamCount = ts.length(baseSig.typeParameters);
35778                 if (isJavaScript || typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) {
35779                     var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig);
35780                     sig.typeParameters = classType.localTypeParameters;
35781                     sig.resolvedReturnType = classType;
35782                     result.push(sig);
35783                 }
35784             }
35785             return result;
35786         }
35787         function findMatchingSignature(signatureList, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes) {
35788             for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) {
35789                 var s = signatureList_1[_i];
35790                 if (compareSignaturesIdentical(s, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes, partialMatch ? compareTypesSubtypeOf : compareTypesIdentical)) {
35791                     return s;
35792                 }
35793             }
35794         }
35795         function findMatchingSignatures(signatureLists, signature, listIndex) {
35796             if (signature.typeParameters) {
35797                 if (listIndex > 0) {
35798                     return undefined;
35799                 }
35800                 for (var i = 1; i < signatureLists.length; i++) {
35801                     if (!findMatchingSignature(signatureLists[i], signature, false, false, false)) {
35802                         return undefined;
35803                     }
35804                 }
35805                 return [signature];
35806             }
35807             var result;
35808             for (var i = 0; i < signatureLists.length; i++) {
35809                 var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, true, false, true);
35810                 if (!match) {
35811                     return undefined;
35812                 }
35813                 result = ts.appendIfUnique(result, match);
35814             }
35815             return result;
35816         }
35817         function getUnionSignatures(signatureLists) {
35818             var result;
35819             var indexWithLengthOverOne;
35820             for (var i = 0; i < signatureLists.length; i++) {
35821                 if (signatureLists[i].length === 0)
35822                     return ts.emptyArray;
35823                 if (signatureLists[i].length > 1) {
35824                     indexWithLengthOverOne = indexWithLengthOverOne === undefined ? i : -1;
35825                 }
35826                 for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) {
35827                     var signature = _a[_i];
35828                     if (!result || !findMatchingSignature(result, signature, false, false, true)) {
35829                         var unionSignatures = findMatchingSignatures(signatureLists, signature, i);
35830                         if (unionSignatures) {
35831                             var s = signature;
35832                             if (unionSignatures.length > 1) {
35833                                 var thisParameter = signature.thisParameter;
35834                                 var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; });
35835                                 if (firstThisParameterOfUnionSignatures) {
35836                                     var thisType = getIntersectionType(ts.mapDefined(unionSignatures, function (sig) { return sig.thisParameter && getTypeOfSymbol(sig.thisParameter); }));
35837                                     thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType);
35838                                 }
35839                                 s = createUnionSignature(signature, unionSignatures);
35840                                 s.thisParameter = thisParameter;
35841                             }
35842                             (result || (result = [])).push(s);
35843                         }
35844                     }
35845                 }
35846             }
35847             if (!ts.length(result) && indexWithLengthOverOne !== -1) {
35848                 var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0];
35849                 var results = masterList.slice();
35850                 var _loop_9 = function (signatures) {
35851                     if (signatures !== masterList) {
35852                         var signature_1 = signatures[0];
35853                         ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass");
35854                         results = signature_1.typeParameters && ts.some(results, function (s) { return !!s.typeParameters; }) ? undefined : ts.map(results, function (sig) { return combineSignaturesOfUnionMembers(sig, signature_1); });
35855                         if (!results) {
35856                             return "break";
35857                         }
35858                     }
35859                 };
35860                 for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) {
35861                     var signatures = signatureLists_1[_b];
35862                     var state_3 = _loop_9(signatures);
35863                     if (state_3 === "break")
35864                         break;
35865                 }
35866                 result = results;
35867             }
35868             return result || ts.emptyArray;
35869         }
35870         function combineUnionThisParam(left, right) {
35871             if (!left || !right) {
35872                 return left || right;
35873             }
35874             var thisType = getIntersectionType([getTypeOfSymbol(left), getTypeOfSymbol(right)]);
35875             return createSymbolWithType(left, thisType);
35876         }
35877         function combineUnionParameters(left, right) {
35878             var leftCount = getParameterCount(left);
35879             var rightCount = getParameterCount(right);
35880             var longest = leftCount >= rightCount ? left : right;
35881             var shorter = longest === left ? right : left;
35882             var longestCount = longest === left ? leftCount : rightCount;
35883             var eitherHasEffectiveRest = (hasEffectiveRestParameter(left) || hasEffectiveRestParameter(right));
35884             var needsExtraRestElement = eitherHasEffectiveRest && !hasEffectiveRestParameter(longest);
35885             var params = new Array(longestCount + (needsExtraRestElement ? 1 : 0));
35886             for (var i = 0; i < longestCount; i++) {
35887                 var longestParamType = tryGetTypeAtPosition(longest, i);
35888                 var shorterParamType = tryGetTypeAtPosition(shorter, i) || unknownType;
35889                 var unionParamType = getIntersectionType([longestParamType, shorterParamType]);
35890                 var isRestParam = eitherHasEffectiveRest && !needsExtraRestElement && i === (longestCount - 1);
35891                 var isOptional = i >= getMinArgumentCount(longest) && i >= getMinArgumentCount(shorter);
35892                 var leftName = i >= leftCount ? undefined : getParameterNameAtPosition(left, i);
35893                 var rightName = i >= rightCount ? undefined : getParameterNameAtPosition(right, i);
35894                 var paramName = leftName === rightName ? leftName :
35895                     !leftName ? rightName :
35896                         !rightName ? leftName :
35897                             undefined;
35898                 var paramSymbol = createSymbol(1 | (isOptional && !isRestParam ? 16777216 : 0), paramName || "arg" + i);
35899                 paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType;
35900                 params[i] = paramSymbol;
35901             }
35902             if (needsExtraRestElement) {
35903                 var restParamSymbol = createSymbol(1, "args");
35904                 restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount));
35905                 params[longestCount] = restParamSymbol;
35906             }
35907             return params;
35908         }
35909         function combineSignaturesOfUnionMembers(left, right) {
35910             var declaration = left.declaration;
35911             var params = combineUnionParameters(left, right);
35912             var thisParam = combineUnionThisParam(left.thisParameter, right.thisParameter);
35913             var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount);
35914             var result = createSignature(declaration, left.typeParameters || right.typeParameters, thisParam, params, undefined, undefined, minArgCount, (left.flags | right.flags) & 3);
35915             result.unionSignatures = ts.concatenate(left.unionSignatures || [left], [right]);
35916             return result;
35917         }
35918         function getUnionIndexInfo(types, kind) {
35919             var indexTypes = [];
35920             var isAnyReadonly = false;
35921             for (var _i = 0, types_3 = types; _i < types_3.length; _i++) {
35922                 var type = types_3[_i];
35923                 var indexInfo = getIndexInfoOfType(getApparentType(type), kind);
35924                 if (!indexInfo) {
35925                     return undefined;
35926                 }
35927                 indexTypes.push(indexInfo.type);
35928                 isAnyReadonly = isAnyReadonly || indexInfo.isReadonly;
35929             }
35930             return createIndexInfo(getUnionType(indexTypes, 2), isAnyReadonly);
35931         }
35932         function resolveUnionTypeMembers(type) {
35933             var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0); }));
35934             var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1); }));
35935             var stringIndexInfo = getUnionIndexInfo(type.types, 0);
35936             var numberIndexInfo = getUnionIndexInfo(type.types, 1);
35937             setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
35938         }
35939         function intersectTypes(type1, type2) {
35940             return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]);
35941         }
35942         function intersectIndexInfos(info1, info2) {
35943             return !info1 ? info2 : !info2 ? info1 : createIndexInfo(getIntersectionType([info1.type, info2.type]), info1.isReadonly && info2.isReadonly);
35944         }
35945         function unionSpreadIndexInfos(info1, info2) {
35946             return info1 && info2 && createIndexInfo(getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly);
35947         }
35948         function findMixins(types) {
35949             var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1).length > 0; });
35950             var mixinFlags = ts.map(types, isMixinConstructorType);
35951             if (constructorTypeCount > 0 && constructorTypeCount === ts.countWhere(mixinFlags, function (b) { return b; })) {
35952                 var firstMixinIndex = mixinFlags.indexOf(true);
35953                 mixinFlags[firstMixinIndex] = false;
35954             }
35955             return mixinFlags;
35956         }
35957         function includeMixinType(type, types, mixinFlags, index) {
35958             var mixedTypes = [];
35959             for (var i = 0; i < types.length; i++) {
35960                 if (i === index) {
35961                     mixedTypes.push(type);
35962                 }
35963                 else if (mixinFlags[i]) {
35964                     mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1)[0]));
35965                 }
35966             }
35967             return getIntersectionType(mixedTypes);
35968         }
35969         function resolveIntersectionTypeMembers(type) {
35970             var callSignatures;
35971             var constructSignatures;
35972             var stringIndexInfo;
35973             var numberIndexInfo;
35974             var types = type.types;
35975             var mixinFlags = findMixins(types);
35976             var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; });
35977             var _loop_10 = function (i) {
35978                 var t = type.types[i];
35979                 if (!mixinFlags[i]) {
35980                     var signatures = getSignaturesOfType(t, 1);
35981                     if (signatures.length && mixinCount > 0) {
35982                         signatures = ts.map(signatures, function (s) {
35983                             var clone = cloneSignature(s);
35984                             clone.resolvedReturnType = includeMixinType(getReturnTypeOfSignature(s), types, mixinFlags, i);
35985                             return clone;
35986                         });
35987                     }
35988                     constructSignatures = appendSignatures(constructSignatures, signatures);
35989                 }
35990                 callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0));
35991                 stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0));
35992                 numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1));
35993             };
35994             for (var i = 0; i < types.length; i++) {
35995                 _loop_10(i);
35996             }
35997             setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo);
35998         }
35999         function appendSignatures(signatures, newSignatures) {
36000             var _loop_11 = function (sig) {
36001                 if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, false, false, false, compareTypesIdentical); })) {
36002                     signatures = ts.append(signatures, sig);
36003                 }
36004             };
36005             for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) {
36006                 var sig = newSignatures_1[_i];
36007                 _loop_11(sig);
36008             }
36009             return signatures;
36010         }
36011         function resolveAnonymousTypeMembers(type) {
36012             var symbol = getMergedSymbol(type.symbol);
36013             if (type.target) {
36014                 setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
36015                 var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false);
36016                 var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0), type.mapper);
36017                 var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1), type.mapper);
36018                 var stringIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 0), type.mapper);
36019                 var numberIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 1), type.mapper);
36020                 setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
36021             }
36022             else if (symbol.flags & 2048) {
36023                 setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
36024                 var members = getMembersOfSymbol(symbol);
36025                 var callSignatures = getSignaturesOfSymbol(members.get("__call"));
36026                 var constructSignatures = getSignaturesOfSymbol(members.get("__new"));
36027                 var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0);
36028                 var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1);
36029                 setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
36030             }
36031             else {
36032                 var members = emptySymbols;
36033                 var stringIndexInfo = void 0;
36034                 if (symbol.exports) {
36035                     members = getExportsOfSymbol(symbol);
36036                     if (symbol === globalThisSymbol) {
36037                         var varsOnly_1 = ts.createMap();
36038                         members.forEach(function (p) {
36039                             if (!(p.flags & 418)) {
36040                                 varsOnly_1.set(p.escapedName, p);
36041                             }
36042                         });
36043                         members = varsOnly_1;
36044                     }
36045                 }
36046                 setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, undefined, undefined);
36047                 if (symbol.flags & 32) {
36048                     var classType = getDeclaredTypeOfClassOrInterface(symbol);
36049                     var baseConstructorType = getBaseConstructorTypeOfClass(classType);
36050                     if (baseConstructorType.flags & (524288 | 2097152 | 8650752)) {
36051                         members = ts.createSymbolTable(getNamedMembers(members));
36052                         addInheritedMembers(members, getPropertiesOfType(baseConstructorType));
36053                     }
36054                     else if (baseConstructorType === anyType) {
36055                         stringIndexInfo = createIndexInfo(anyType, false);
36056                     }
36057                 }
36058                 var numberIndexInfo = symbol.flags & 384 && (getDeclaredTypeOfSymbol(symbol).flags & 32 ||
36059                     ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296); })) ? enumNumberIndexInfo : undefined;
36060                 setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
36061                 if (symbol.flags & (16 | 8192)) {
36062                     type.callSignatures = getSignaturesOfSymbol(symbol);
36063                 }
36064                 if (symbol.flags & 32) {
36065                     var classType_1 = getDeclaredTypeOfClassOrInterface(symbol);
36066                     var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor")) : ts.emptyArray;
36067                     if (symbol.flags & 16) {
36068                         constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ?
36069                             createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, undefined, sig.minArgumentCount, sig.flags & 3) :
36070                             undefined; }));
36071                     }
36072                     if (!constructSignatures.length) {
36073                         constructSignatures = getDefaultConstructSignatures(classType_1);
36074                     }
36075                     type.constructSignatures = constructSignatures;
36076                 }
36077             }
36078         }
36079         function resolveReverseMappedTypeMembers(type) {
36080             var indexInfo = getIndexInfoOfType(type.source, 0);
36081             var modifiers = getMappedTypeModifiers(type.mappedType);
36082             var readonlyMask = modifiers & 1 ? false : true;
36083             var optionalMask = modifiers & 4 ? 0 : 16777216;
36084             var stringIndexInfo = indexInfo && createIndexInfo(inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly);
36085             var members = ts.createSymbolTable();
36086             for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) {
36087                 var prop = _a[_i];
36088                 var checkFlags = 8192 | (readonlyMask && isReadonlySymbol(prop) ? 8 : 0);
36089                 var inferredProp = createSymbol(4 | prop.flags & optionalMask, prop.escapedName, checkFlags);
36090                 inferredProp.declarations = prop.declarations;
36091                 inferredProp.nameType = getSymbolLinks(prop).nameType;
36092                 inferredProp.propertyType = getTypeOfSymbol(prop);
36093                 inferredProp.mappedType = type.mappedType;
36094                 inferredProp.constraintType = type.constraintType;
36095                 members.set(prop.escapedName, inferredProp);
36096             }
36097             setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined);
36098         }
36099         function getLowerBoundOfKeyType(type) {
36100             if (type.flags & (1 | 131068)) {
36101                 return type;
36102             }
36103             if (type.flags & 4194304) {
36104                 return getIndexType(getApparentType(type.type));
36105             }
36106             if (type.flags & 16777216) {
36107                 if (type.root.isDistributive) {
36108                     var checkType = type.checkType;
36109                     var constraint = getLowerBoundOfKeyType(checkType);
36110                     if (constraint !== checkType) {
36111                         return getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
36112                     }
36113                 }
36114                 return type;
36115             }
36116             if (type.flags & 1048576) {
36117                 return getUnionType(ts.sameMap(type.types, getLowerBoundOfKeyType));
36118             }
36119             if (type.flags & 2097152) {
36120                 return getIntersectionType(ts.sameMap(type.types, getLowerBoundOfKeyType));
36121             }
36122             return neverType;
36123         }
36124         function resolveMappedTypeMembers(type) {
36125             var members = ts.createSymbolTable();
36126             var stringIndexInfo;
36127             var numberIndexInfo;
36128             setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
36129             var typeParameter = getTypeParameterFromMappedType(type);
36130             var constraintType = getConstraintTypeFromMappedType(type);
36131             var templateType = getTemplateTypeFromMappedType(type.target || type);
36132             var modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
36133             var templateModifiers = getMappedTypeModifiers(type);
36134             var include = keyofStringsOnly ? 128 : 8576;
36135             if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
36136                 for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) {
36137                     var prop = _a[_i];
36138                     addMemberForKeyType(getLiteralTypeFromProperty(prop, include));
36139                 }
36140                 if (modifiersType.flags & 1 || getIndexInfoOfType(modifiersType, 0)) {
36141                     addMemberForKeyType(stringType);
36142                 }
36143                 if (!keyofStringsOnly && getIndexInfoOfType(modifiersType, 1)) {
36144                     addMemberForKeyType(numberType);
36145                 }
36146             }
36147             else {
36148                 forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
36149             }
36150             setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
36151             function addMemberForKeyType(t) {
36152                 var templateMapper = appendTypeMapping(type.mapper, typeParameter, t);
36153                 if (isTypeUsableAsPropertyName(t)) {
36154                     var propName = getPropertyNameFromType(t);
36155                     var modifiersProp = getPropertyOfType(modifiersType, propName);
36156                     var isOptional = !!(templateModifiers & 4 ||
36157                         !(templateModifiers & 8) && modifiersProp && modifiersProp.flags & 16777216);
36158                     var isReadonly = !!(templateModifiers & 1 ||
36159                         !(templateModifiers & 2) && modifiersProp && isReadonlySymbol(modifiersProp));
36160                     var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216;
36161                     var prop = createSymbol(4 | (isOptional ? 16777216 : 0), propName, 262144 | (isReadonly ? 8 : 0) | (stripOptional ? 524288 : 0));
36162                     prop.mappedType = type;
36163                     prop.mapper = templateMapper;
36164                     if (modifiersProp) {
36165                         prop.syntheticOrigin = modifiersProp;
36166                         prop.declarations = modifiersProp.declarations;
36167                     }
36168                     prop.nameType = t;
36169                     members.set(propName, prop);
36170                 }
36171                 else if (t.flags & (1 | 4 | 8 | 32)) {
36172                     var propType = instantiateType(templateType, templateMapper);
36173                     if (t.flags & (1 | 4)) {
36174                         stringIndexInfo = createIndexInfo(propType, !!(templateModifiers & 1));
36175                     }
36176                     else {
36177                         numberIndexInfo = createIndexInfo(numberIndexInfo ? getUnionType([numberIndexInfo.type, propType]) : propType, !!(templateModifiers & 1));
36178                     }
36179                 }
36180             }
36181         }
36182         function getTypeOfMappedSymbol(symbol) {
36183             if (!symbol.type) {
36184                 if (!pushTypeResolution(symbol, 0)) {
36185                     return errorType;
36186                 }
36187                 var templateType = getTemplateTypeFromMappedType(symbol.mappedType.target || symbol.mappedType);
36188                 var propType = instantiateType(templateType, symbol.mapper);
36189                 var type = strictNullChecks && symbol.flags & 16777216 && !maybeTypeOfKind(propType, 32768 | 16384) ? getOptionalType(propType) :
36190                     symbol.checkFlags & 524288 ? getTypeWithFacts(propType, 524288) :
36191                         propType;
36192                 if (!popTypeResolution()) {
36193                     error(currentNode, ts.Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(symbol.mappedType));
36194                     type = errorType;
36195                 }
36196                 symbol.type = type;
36197                 symbol.mapper = undefined;
36198             }
36199             return symbol.type;
36200         }
36201         function getTypeParameterFromMappedType(type) {
36202             return type.typeParameter ||
36203                 (type.typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(type.declaration.typeParameter)));
36204         }
36205         function getConstraintTypeFromMappedType(type) {
36206             return type.constraintType ||
36207                 (type.constraintType = getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)) || errorType);
36208         }
36209         function getTemplateTypeFromMappedType(type) {
36210             return type.templateType ||
36211                 (type.templateType = type.declaration.type ?
36212                     instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!(getMappedTypeModifiers(type) & 4)), type.mapper) :
36213                     errorType);
36214         }
36215         function getConstraintDeclarationForMappedType(type) {
36216             return ts.getEffectiveConstraintOfTypeParameter(type.declaration.typeParameter);
36217         }
36218         function isMappedTypeWithKeyofConstraintDeclaration(type) {
36219             var constraintDeclaration = getConstraintDeclarationForMappedType(type);
36220             return constraintDeclaration.kind === 184 &&
36221                 constraintDeclaration.operator === 134;
36222         }
36223         function getModifiersTypeFromMappedType(type) {
36224             if (!type.modifiersType) {
36225                 if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
36226                     type.modifiersType = instantiateType(getTypeFromTypeNode(getConstraintDeclarationForMappedType(type).type), type.mapper);
36227                 }
36228                 else {
36229                     var declaredType = getTypeFromMappedTypeNode(type.declaration);
36230                     var constraint = getConstraintTypeFromMappedType(declaredType);
36231                     var extendedConstraint = constraint && constraint.flags & 262144 ? getConstraintOfTypeParameter(constraint) : constraint;
36232                     type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 ? instantiateType(extendedConstraint.type, type.mapper) : unknownType;
36233                 }
36234             }
36235             return type.modifiersType;
36236         }
36237         function getMappedTypeModifiers(type) {
36238             var declaration = type.declaration;
36239             return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 ? 2 : 1 : 0) |
36240                 (declaration.questionToken ? declaration.questionToken.kind === 40 ? 8 : 4 : 0);
36241         }
36242         function getMappedTypeOptionality(type) {
36243             var modifiers = getMappedTypeModifiers(type);
36244             return modifiers & 8 ? -1 : modifiers & 4 ? 1 : 0;
36245         }
36246         function getCombinedMappedTypeOptionality(type) {
36247             var optionality = getMappedTypeOptionality(type);
36248             var modifiersType = getModifiersTypeFromMappedType(type);
36249             return optionality || (isGenericMappedType(modifiersType) ? getMappedTypeOptionality(modifiersType) : 0);
36250         }
36251         function isPartialMappedType(type) {
36252             return !!(ts.getObjectFlags(type) & 32 && getMappedTypeModifiers(type) & 4);
36253         }
36254         function isGenericMappedType(type) {
36255             return !!(ts.getObjectFlags(type) & 32) && isGenericIndexType(getConstraintTypeFromMappedType(type));
36256         }
36257         function resolveStructuredTypeMembers(type) {
36258             if (!type.members) {
36259                 if (type.flags & 524288) {
36260                     if (type.objectFlags & 4) {
36261                         resolveTypeReferenceMembers(type);
36262                     }
36263                     else if (type.objectFlags & 3) {
36264                         resolveClassOrInterfaceMembers(type);
36265                     }
36266                     else if (type.objectFlags & 2048) {
36267                         resolveReverseMappedTypeMembers(type);
36268                     }
36269                     else if (type.objectFlags & 16) {
36270                         resolveAnonymousTypeMembers(type);
36271                     }
36272                     else if (type.objectFlags & 32) {
36273                         resolveMappedTypeMembers(type);
36274                     }
36275                 }
36276                 else if (type.flags & 1048576) {
36277                     resolveUnionTypeMembers(type);
36278                 }
36279                 else if (type.flags & 2097152) {
36280                     resolveIntersectionTypeMembers(type);
36281                 }
36282             }
36283             return type;
36284         }
36285         function getPropertiesOfObjectType(type) {
36286             if (type.flags & 524288) {
36287                 return resolveStructuredTypeMembers(type).properties;
36288             }
36289             return ts.emptyArray;
36290         }
36291         function getPropertyOfObjectType(type, name) {
36292             if (type.flags & 524288) {
36293                 var resolved = resolveStructuredTypeMembers(type);
36294                 var symbol = resolved.members.get(name);
36295                 if (symbol && symbolIsValue(symbol)) {
36296                     return symbol;
36297                 }
36298             }
36299         }
36300         function getPropertiesOfUnionOrIntersectionType(type) {
36301             if (!type.resolvedProperties) {
36302                 var members = ts.createSymbolTable();
36303                 for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
36304                     var current = _a[_i];
36305                     for (var _b = 0, _c = getPropertiesOfType(current); _b < _c.length; _b++) {
36306                         var prop = _c[_b];
36307                         if (!members.has(prop.escapedName)) {
36308                             var combinedProp = getPropertyOfUnionOrIntersectionType(type, prop.escapedName);
36309                             if (combinedProp) {
36310                                 members.set(prop.escapedName, combinedProp);
36311                             }
36312                         }
36313                     }
36314                     if (type.flags & 1048576 && !getIndexInfoOfType(current, 0) && !getIndexInfoOfType(current, 1)) {
36315                         break;
36316                     }
36317                 }
36318                 type.resolvedProperties = getNamedMembers(members);
36319             }
36320             return type.resolvedProperties;
36321         }
36322         function getPropertiesOfType(type) {
36323             type = getReducedApparentType(type);
36324             return type.flags & 3145728 ?
36325                 getPropertiesOfUnionOrIntersectionType(type) :
36326                 getPropertiesOfObjectType(type);
36327         }
36328         function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) {
36329             var list = obj.properties;
36330             return list.some(function (property) {
36331                 var nameType = property.name && getLiteralTypeFromPropertyName(property.name);
36332                 var name = nameType && isTypeUsableAsPropertyName(nameType) ? getPropertyNameFromType(nameType) : undefined;
36333                 var expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name);
36334                 return !!expected && isLiteralType(expected) && !isTypeAssignableTo(getTypeOfNode(property), expected);
36335             });
36336         }
36337         function getAllPossiblePropertiesOfTypes(types) {
36338             var unionType = getUnionType(types);
36339             if (!(unionType.flags & 1048576)) {
36340                 return getAugmentedPropertiesOfType(unionType);
36341             }
36342             var props = ts.createSymbolTable();
36343             for (var _i = 0, types_4 = types; _i < types_4.length; _i++) {
36344                 var memberType = types_4[_i];
36345                 for (var _a = 0, _b = getAugmentedPropertiesOfType(memberType); _a < _b.length; _a++) {
36346                     var escapedName = _b[_a].escapedName;
36347                     if (!props.has(escapedName)) {
36348                         var prop = createUnionOrIntersectionProperty(unionType, escapedName);
36349                         if (prop)
36350                             props.set(escapedName, prop);
36351                     }
36352                 }
36353             }
36354             return ts.arrayFrom(props.values());
36355         }
36356         function getConstraintOfType(type) {
36357             return type.flags & 262144 ? getConstraintOfTypeParameter(type) :
36358                 type.flags & 8388608 ? getConstraintOfIndexedAccess(type) :
36359                     type.flags & 16777216 ? getConstraintOfConditionalType(type) :
36360                         getBaseConstraintOfType(type);
36361         }
36362         function getConstraintOfTypeParameter(typeParameter) {
36363             return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined;
36364         }
36365         function getConstraintOfIndexedAccess(type) {
36366             return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : undefined;
36367         }
36368         function getSimplifiedTypeOrConstraint(type) {
36369             var simplified = getSimplifiedType(type, false);
36370             return simplified !== type ? simplified : getConstraintOfType(type);
36371         }
36372         function getConstraintFromIndexedAccess(type) {
36373             var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType);
36374             if (indexConstraint && indexConstraint !== type.indexType) {
36375                 var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint);
36376                 if (indexedAccess) {
36377                     return indexedAccess;
36378                 }
36379             }
36380             var objectConstraint = getSimplifiedTypeOrConstraint(type.objectType);
36381             if (objectConstraint && objectConstraint !== type.objectType) {
36382                 return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType);
36383             }
36384             return undefined;
36385         }
36386         function getDefaultConstraintOfConditionalType(type) {
36387             if (!type.resolvedDefaultConstraint) {
36388                 var trueConstraint = getInferredTrueTypeFromConditionalType(type);
36389                 var falseConstraint = getFalseTypeFromConditionalType(type);
36390                 type.resolvedDefaultConstraint = isTypeAny(trueConstraint) ? falseConstraint : isTypeAny(falseConstraint) ? trueConstraint : getUnionType([trueConstraint, falseConstraint]);
36391             }
36392             return type.resolvedDefaultConstraint;
36393         }
36394         function getConstraintOfDistributiveConditionalType(type) {
36395             if (type.root.isDistributive && type.restrictiveInstantiation !== type) {
36396                 var simplified = getSimplifiedType(type.checkType, false);
36397                 var constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified;
36398                 if (constraint && constraint !== type.checkType) {
36399                     var instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
36400                     if (!(instantiated.flags & 131072)) {
36401                         return instantiated;
36402                     }
36403                 }
36404             }
36405             return undefined;
36406         }
36407         function getConstraintFromConditionalType(type) {
36408             return getConstraintOfDistributiveConditionalType(type) || getDefaultConstraintOfConditionalType(type);
36409         }
36410         function getConstraintOfConditionalType(type) {
36411             return hasNonCircularBaseConstraint(type) ? getConstraintFromConditionalType(type) : undefined;
36412         }
36413         function getEffectiveConstraintOfIntersection(types, targetIsUnion) {
36414             var constraints;
36415             var hasDisjointDomainType = false;
36416             for (var _i = 0, types_5 = types; _i < types_5.length; _i++) {
36417                 var t = types_5[_i];
36418                 if (t.flags & 63176704) {
36419                     var constraint = getConstraintOfType(t);
36420                     while (constraint && constraint.flags & (262144 | 4194304 | 16777216)) {
36421                         constraint = getConstraintOfType(constraint);
36422                     }
36423                     if (constraint) {
36424                         constraints = ts.append(constraints, constraint);
36425                         if (targetIsUnion) {
36426                             constraints = ts.append(constraints, t);
36427                         }
36428                     }
36429                 }
36430                 else if (t.flags & 67238908) {
36431                     hasDisjointDomainType = true;
36432                 }
36433             }
36434             if (constraints && (targetIsUnion || hasDisjointDomainType)) {
36435                 if (hasDisjointDomainType) {
36436                     for (var _a = 0, types_6 = types; _a < types_6.length; _a++) {
36437                         var t = types_6[_a];
36438                         if (t.flags & 67238908) {
36439                             constraints = ts.append(constraints, t);
36440                         }
36441                     }
36442                 }
36443                 return getIntersectionType(constraints);
36444             }
36445             return undefined;
36446         }
36447         function getBaseConstraintOfType(type) {
36448             if (type.flags & (58982400 | 3145728)) {
36449                 var constraint = getResolvedBaseConstraint(type);
36450                 return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined;
36451             }
36452             return type.flags & 4194304 ? keyofConstraintType : undefined;
36453         }
36454         function getBaseConstraintOrType(type) {
36455             return getBaseConstraintOfType(type) || type;
36456         }
36457         function hasNonCircularBaseConstraint(type) {
36458             return getResolvedBaseConstraint(type) !== circularConstraintType;
36459         }
36460         function getResolvedBaseConstraint(type) {
36461             var nonTerminating = false;
36462             return type.resolvedBaseConstraint ||
36463                 (type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type));
36464             function getImmediateBaseConstraint(t) {
36465                 if (!t.immediateBaseConstraint) {
36466                     if (!pushTypeResolution(t, 4)) {
36467                         return circularConstraintType;
36468                     }
36469                     if (constraintDepth >= 50) {
36470                         error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
36471                         nonTerminating = true;
36472                         return t.immediateBaseConstraint = noConstraintType;
36473                     }
36474                     constraintDepth++;
36475                     var result = computeBaseConstraint(getSimplifiedType(t, false));
36476                     constraintDepth--;
36477                     if (!popTypeResolution()) {
36478                         if (t.flags & 262144) {
36479                             var errorNode = getConstraintDeclaration(t);
36480                             if (errorNode) {
36481                                 var diagnostic = error(errorNode, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(t));
36482                                 if (currentNode && !ts.isNodeDescendantOf(errorNode, currentNode) && !ts.isNodeDescendantOf(currentNode, errorNode)) {
36483                                     ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(currentNode, ts.Diagnostics.Circularity_originates_in_type_at_this_location));
36484                                 }
36485                             }
36486                         }
36487                         result = circularConstraintType;
36488                     }
36489                     if (nonTerminating) {
36490                         result = circularConstraintType;
36491                     }
36492                     t.immediateBaseConstraint = result || noConstraintType;
36493                 }
36494                 return t.immediateBaseConstraint;
36495             }
36496             function getBaseConstraint(t) {
36497                 var c = getImmediateBaseConstraint(t);
36498                 return c !== noConstraintType && c !== circularConstraintType ? c : undefined;
36499             }
36500             function computeBaseConstraint(t) {
36501                 if (t.flags & 262144) {
36502                     var constraint = getConstraintFromTypeParameter(t);
36503                     return t.isThisType || !constraint ?
36504                         constraint :
36505                         getBaseConstraint(constraint);
36506                 }
36507                 if (t.flags & 3145728) {
36508                     var types = t.types;
36509                     var baseTypes = [];
36510                     for (var _i = 0, types_7 = types; _i < types_7.length; _i++) {
36511                         var type_2 = types_7[_i];
36512                         var baseType = getBaseConstraint(type_2);
36513                         if (baseType) {
36514                             baseTypes.push(baseType);
36515                         }
36516                     }
36517                     return t.flags & 1048576 && baseTypes.length === types.length ? getUnionType(baseTypes) :
36518                         t.flags & 2097152 && baseTypes.length ? getIntersectionType(baseTypes) :
36519                             undefined;
36520                 }
36521                 if (t.flags & 4194304) {
36522                     return keyofConstraintType;
36523                 }
36524                 if (t.flags & 8388608) {
36525                     var baseObjectType = getBaseConstraint(t.objectType);
36526                     var baseIndexType = getBaseConstraint(t.indexType);
36527                     var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType);
36528                     return baseIndexedAccess && getBaseConstraint(baseIndexedAccess);
36529                 }
36530                 if (t.flags & 16777216) {
36531                     var constraint = getConstraintFromConditionalType(t);
36532                     constraintDepth++;
36533                     var result = constraint && getBaseConstraint(constraint);
36534                     constraintDepth--;
36535                     return result;
36536                 }
36537                 if (t.flags & 33554432) {
36538                     return getBaseConstraint(t.substitute);
36539                 }
36540                 return t;
36541             }
36542         }
36543         function getApparentTypeOfIntersectionType(type) {
36544             return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(type, type, true));
36545         }
36546         function getResolvedTypeParameterDefault(typeParameter) {
36547             if (!typeParameter.default) {
36548                 if (typeParameter.target) {
36549                     var targetDefault = getResolvedTypeParameterDefault(typeParameter.target);
36550                     typeParameter.default = targetDefault ? instantiateType(targetDefault, typeParameter.mapper) : noConstraintType;
36551                 }
36552                 else {
36553                     typeParameter.default = resolvingDefaultType;
36554                     var defaultDeclaration = typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameterDeclaration(decl) && decl.default; });
36555                     var defaultType = defaultDeclaration ? getTypeFromTypeNode(defaultDeclaration) : noConstraintType;
36556                     if (typeParameter.default === resolvingDefaultType) {
36557                         typeParameter.default = defaultType;
36558                     }
36559                 }
36560             }
36561             else if (typeParameter.default === resolvingDefaultType) {
36562                 typeParameter.default = circularConstraintType;
36563             }
36564             return typeParameter.default;
36565         }
36566         function getDefaultFromTypeParameter(typeParameter) {
36567             var defaultType = getResolvedTypeParameterDefault(typeParameter);
36568             return defaultType !== noConstraintType && defaultType !== circularConstraintType ? defaultType : undefined;
36569         }
36570         function hasNonCircularTypeParameterDefault(typeParameter) {
36571             return getResolvedTypeParameterDefault(typeParameter) !== circularConstraintType;
36572         }
36573         function hasTypeParameterDefault(typeParameter) {
36574             return !!(typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameterDeclaration(decl) && decl.default; }));
36575         }
36576         function getApparentTypeOfMappedType(type) {
36577             return type.resolvedApparentType || (type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type));
36578         }
36579         function getResolvedApparentTypeOfMappedType(type) {
36580             var typeVariable = getHomomorphicTypeVariable(type);
36581             if (typeVariable) {
36582                 var constraint = getConstraintOfTypeParameter(typeVariable);
36583                 if (constraint && (isArrayType(constraint) || isTupleType(constraint))) {
36584                     return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
36585                 }
36586             }
36587             return type;
36588         }
36589         function getApparentType(type) {
36590             var t = type.flags & 63176704 ? getBaseConstraintOfType(type) || unknownType : type;
36591             return ts.getObjectFlags(t) & 32 ? getApparentTypeOfMappedType(t) :
36592                 t.flags & 2097152 ? getApparentTypeOfIntersectionType(t) :
36593                     t.flags & 132 ? globalStringType :
36594                         t.flags & 296 ? globalNumberType :
36595                             t.flags & 2112 ? getGlobalBigIntType(languageVersion >= 7) :
36596                                 t.flags & 528 ? globalBooleanType :
36597                                     t.flags & 12288 ? getGlobalESSymbolType(languageVersion >= 2) :
36598                                         t.flags & 67108864 ? emptyObjectType :
36599                                             t.flags & 4194304 ? keyofConstraintType :
36600                                                 t.flags & 2 && !strictNullChecks ? emptyObjectType :
36601                                                     t;
36602         }
36603         function getReducedApparentType(type) {
36604             return getReducedType(getApparentType(getReducedType(type)));
36605         }
36606         function createUnionOrIntersectionProperty(containingType, name) {
36607             var singleProp;
36608             var propSet;
36609             var indexTypes;
36610             var isUnion = containingType.flags & 1048576;
36611             var optionalFlag = isUnion ? 0 : 16777216;
36612             var syntheticFlag = 4;
36613             var checkFlags = 0;
36614             for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) {
36615                 var current = _a[_i];
36616                 var type = getApparentType(current);
36617                 if (!(type === errorType || type.flags & 131072)) {
36618                     var prop = getPropertyOfType(type, name);
36619                     var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
36620                     if (prop) {
36621                         if (isUnion) {
36622                             optionalFlag |= (prop.flags & 16777216);
36623                         }
36624                         else {
36625                             optionalFlag &= prop.flags;
36626                         }
36627                         if (!singleProp) {
36628                             singleProp = prop;
36629                         }
36630                         else if (prop !== singleProp) {
36631                             if (!propSet) {
36632                                 propSet = ts.createMap();
36633                                 propSet.set("" + getSymbolId(singleProp), singleProp);
36634                             }
36635                             var id = "" + getSymbolId(prop);
36636                             if (!propSet.has(id)) {
36637                                 propSet.set(id, prop);
36638                             }
36639                         }
36640                         checkFlags |= (isReadonlySymbol(prop) ? 8 : 0) |
36641                             (!(modifiers & 24) ? 256 : 0) |
36642                             (modifiers & 16 ? 512 : 0) |
36643                             (modifiers & 8 ? 1024 : 0) |
36644                             (modifiers & 32 ? 2048 : 0);
36645                         if (!isPrototypeProperty(prop)) {
36646                             syntheticFlag = 2;
36647                         }
36648                     }
36649                     else if (isUnion) {
36650                         var indexInfo = !isLateBoundName(name) && (isNumericLiteralName(name) && getIndexInfoOfType(type, 1) || getIndexInfoOfType(type, 0));
36651                         if (indexInfo) {
36652                             checkFlags |= 32 | (indexInfo.isReadonly ? 8 : 0);
36653                             indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type);
36654                         }
36655                         else if (isObjectLiteralType(type)) {
36656                             checkFlags |= 32;
36657                             indexTypes = ts.append(indexTypes, undefinedType);
36658                         }
36659                         else {
36660                             checkFlags |= 16;
36661                         }
36662                     }
36663                 }
36664             }
36665             if (!singleProp || isUnion && (propSet || checkFlags & 48) && checkFlags & (1024 | 512)) {
36666                 return undefined;
36667             }
36668             if (!propSet && !(checkFlags & 16) && !indexTypes) {
36669                 return singleProp;
36670             }
36671             var props = propSet ? ts.arrayFrom(propSet.values()) : [singleProp];
36672             var declarations;
36673             var firstType;
36674             var nameType;
36675             var propTypes = [];
36676             var firstValueDeclaration;
36677             var hasNonUniformValueDeclaration = false;
36678             for (var _b = 0, props_1 = props; _b < props_1.length; _b++) {
36679                 var prop = props_1[_b];
36680                 if (!firstValueDeclaration) {
36681                     firstValueDeclaration = prop.valueDeclaration;
36682                 }
36683                 else if (prop.valueDeclaration && prop.valueDeclaration !== firstValueDeclaration) {
36684                     hasNonUniformValueDeclaration = true;
36685                 }
36686                 declarations = ts.addRange(declarations, prop.declarations);
36687                 var type = getTypeOfSymbol(prop);
36688                 if (!firstType) {
36689                     firstType = type;
36690                     nameType = getSymbolLinks(prop).nameType;
36691                 }
36692                 else if (type !== firstType) {
36693                     checkFlags |= 64;
36694                 }
36695                 if (isLiteralType(type)) {
36696                     checkFlags |= 128;
36697                 }
36698                 if (type.flags & 131072) {
36699                     checkFlags |= 131072;
36700                 }
36701                 propTypes.push(type);
36702             }
36703             ts.addRange(propTypes, indexTypes);
36704             var result = createSymbol(4 | optionalFlag, name, syntheticFlag | checkFlags);
36705             result.containingType = containingType;
36706             if (!hasNonUniformValueDeclaration && firstValueDeclaration) {
36707                 result.valueDeclaration = firstValueDeclaration;
36708                 if (firstValueDeclaration.symbol.parent) {
36709                     result.parent = firstValueDeclaration.symbol.parent;
36710                 }
36711             }
36712             result.declarations = declarations;
36713             result.nameType = nameType;
36714             if (propTypes.length > 2) {
36715                 result.checkFlags |= 65536;
36716                 result.deferralParent = containingType;
36717                 result.deferralConstituents = propTypes;
36718             }
36719             else {
36720                 result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes);
36721             }
36722             return result;
36723         }
36724         function getUnionOrIntersectionProperty(type, name) {
36725             var properties = type.propertyCache || (type.propertyCache = ts.createSymbolTable());
36726             var property = properties.get(name);
36727             if (!property) {
36728                 property = createUnionOrIntersectionProperty(type, name);
36729                 if (property) {
36730                     properties.set(name, property);
36731                 }
36732             }
36733             return property;
36734         }
36735         function getPropertyOfUnionOrIntersectionType(type, name) {
36736             var property = getUnionOrIntersectionProperty(type, name);
36737             return property && !(ts.getCheckFlags(property) & 16) ? property : undefined;
36738         }
36739         function getReducedType(type) {
36740             if (type.flags & 1048576 && type.objectFlags & 268435456) {
36741                 return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type));
36742             }
36743             else if (type.flags & 2097152) {
36744                 if (!(type.objectFlags & 268435456)) {
36745                     type.objectFlags |= 268435456 |
36746                         (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 536870912 : 0);
36747                 }
36748                 return type.objectFlags & 536870912 ? neverType : type;
36749             }
36750             return type;
36751         }
36752         function getReducedUnionType(unionType) {
36753             var reducedTypes = ts.sameMap(unionType.types, getReducedType);
36754             if (reducedTypes === unionType.types) {
36755                 return unionType;
36756             }
36757             var reduced = getUnionType(reducedTypes);
36758             if (reduced.flags & 1048576) {
36759                 reduced.resolvedReducedType = reduced;
36760             }
36761             return reduced;
36762         }
36763         function isNeverReducedProperty(prop) {
36764             return isDiscriminantWithNeverType(prop) || isConflictingPrivateProperty(prop);
36765         }
36766         function isDiscriminantWithNeverType(prop) {
36767             return !(prop.flags & 16777216) &&
36768                 (ts.getCheckFlags(prop) & (192 | 131072)) === 192 &&
36769                 !!(getTypeOfSymbol(prop).flags & 131072);
36770         }
36771         function isConflictingPrivateProperty(prop) {
36772             return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024);
36773         }
36774         function elaborateNeverIntersection(errorInfo, type) {
36775             if (ts.getObjectFlags(type) & 536870912) {
36776                 var neverProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isDiscriminantWithNeverType);
36777                 if (neverProp) {
36778                     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));
36779                 }
36780                 var privateProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isConflictingPrivateProperty);
36781                 if (privateProp) {
36782                     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));
36783                 }
36784             }
36785             return errorInfo;
36786         }
36787         function getPropertyOfType(type, name) {
36788             type = getReducedApparentType(type);
36789             if (type.flags & 524288) {
36790                 var resolved = resolveStructuredTypeMembers(type);
36791                 var symbol = resolved.members.get(name);
36792                 if (symbol && symbolIsValue(symbol)) {
36793                     return symbol;
36794                 }
36795                 var functionType = resolved === anyFunctionType ? globalFunctionType :
36796                     resolved.callSignatures.length ? globalCallableFunctionType :
36797                         resolved.constructSignatures.length ? globalNewableFunctionType :
36798                             undefined;
36799                 if (functionType) {
36800                     var symbol_1 = getPropertyOfObjectType(functionType, name);
36801                     if (symbol_1) {
36802                         return symbol_1;
36803                     }
36804                 }
36805                 return getPropertyOfObjectType(globalObjectType, name);
36806             }
36807             if (type.flags & 3145728) {
36808                 return getPropertyOfUnionOrIntersectionType(type, name);
36809             }
36810             return undefined;
36811         }
36812         function getSignaturesOfStructuredType(type, kind) {
36813             if (type.flags & 3670016) {
36814                 var resolved = resolveStructuredTypeMembers(type);
36815                 return kind === 0 ? resolved.callSignatures : resolved.constructSignatures;
36816             }
36817             return ts.emptyArray;
36818         }
36819         function getSignaturesOfType(type, kind) {
36820             return getSignaturesOfStructuredType(getReducedApparentType(type), kind);
36821         }
36822         function getIndexInfoOfStructuredType(type, kind) {
36823             if (type.flags & 3670016) {
36824                 var resolved = resolveStructuredTypeMembers(type);
36825                 return kind === 0 ? resolved.stringIndexInfo : resolved.numberIndexInfo;
36826             }
36827         }
36828         function getIndexTypeOfStructuredType(type, kind) {
36829             var info = getIndexInfoOfStructuredType(type, kind);
36830             return info && info.type;
36831         }
36832         function getIndexInfoOfType(type, kind) {
36833             return getIndexInfoOfStructuredType(getReducedApparentType(type), kind);
36834         }
36835         function getIndexTypeOfType(type, kind) {
36836             return getIndexTypeOfStructuredType(getReducedApparentType(type), kind);
36837         }
36838         function getImplicitIndexTypeOfType(type, kind) {
36839             if (isObjectTypeWithInferableIndex(type)) {
36840                 var propTypes = [];
36841                 for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
36842                     var prop = _a[_i];
36843                     if (kind === 0 || isNumericLiteralName(prop.escapedName)) {
36844                         propTypes.push(getTypeOfSymbol(prop));
36845                     }
36846                 }
36847                 if (kind === 0) {
36848                     ts.append(propTypes, getIndexTypeOfType(type, 1));
36849                 }
36850                 if (propTypes.length) {
36851                     return getUnionType(propTypes);
36852                 }
36853             }
36854             return undefined;
36855         }
36856         function getTypeParametersFromDeclaration(declaration) {
36857             var result;
36858             for (var _i = 0, _a = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _a.length; _i++) {
36859                 var node = _a[_i];
36860                 result = ts.appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol));
36861             }
36862             return result;
36863         }
36864         function symbolsToArray(symbols) {
36865             var result = [];
36866             symbols.forEach(function (symbol, id) {
36867                 if (!isReservedMemberName(id)) {
36868                     result.push(symbol);
36869                 }
36870             });
36871             return result;
36872         }
36873         function isJSDocOptionalParameter(node) {
36874             return ts.isInJSFile(node) && (node.type && node.type.kind === 299
36875                 || ts.getJSDocParameterTags(node).some(function (_a) {
36876                     var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression;
36877                     return isBracketed || !!typeExpression && typeExpression.type.kind === 299;
36878                 }));
36879         }
36880         function tryFindAmbientModule(moduleName, withAugmentations) {
36881             if (ts.isExternalModuleNameRelative(moduleName)) {
36882                 return undefined;
36883             }
36884             var symbol = getSymbol(globals, '"' + moduleName + '"', 512);
36885             return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol;
36886         }
36887         function isOptionalParameter(node) {
36888             if (ts.hasQuestionToken(node) || isOptionalJSDocParameterTag(node) || isJSDocOptionalParameter(node)) {
36889                 return true;
36890             }
36891             if (node.initializer) {
36892                 var signature = getSignatureFromDeclaration(node.parent);
36893                 var parameterIndex = node.parent.parameters.indexOf(node);
36894                 ts.Debug.assert(parameterIndex >= 0);
36895                 return parameterIndex >= getMinArgumentCount(signature, true);
36896             }
36897             var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent);
36898             if (iife) {
36899                 return !node.type &&
36900                     !node.dotDotDotToken &&
36901                     node.parent.parameters.indexOf(node) >= iife.arguments.length;
36902             }
36903             return false;
36904         }
36905         function isOptionalJSDocParameterTag(node) {
36906             if (!ts.isJSDocParameterTag(node)) {
36907                 return false;
36908             }
36909             var isBracketed = node.isBracketed, typeExpression = node.typeExpression;
36910             return isBracketed || !!typeExpression && typeExpression.type.kind === 299;
36911         }
36912         function createTypePredicate(kind, parameterName, parameterIndex, type) {
36913             return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type };
36914         }
36915         function getMinTypeArgumentCount(typeParameters) {
36916             var minTypeArgumentCount = 0;
36917             if (typeParameters) {
36918                 for (var i = 0; i < typeParameters.length; i++) {
36919                     if (!hasTypeParameterDefault(typeParameters[i])) {
36920                         minTypeArgumentCount = i + 1;
36921                     }
36922                 }
36923             }
36924             return minTypeArgumentCount;
36925         }
36926         function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, isJavaScriptImplicitAny) {
36927             var numTypeParameters = ts.length(typeParameters);
36928             if (!numTypeParameters) {
36929                 return [];
36930             }
36931             var numTypeArguments = ts.length(typeArguments);
36932             if (isJavaScriptImplicitAny || (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters)) {
36933                 var result = typeArguments ? typeArguments.slice() : [];
36934                 for (var i = numTypeArguments; i < numTypeParameters; i++) {
36935                     result[i] = errorType;
36936                 }
36937                 var baseDefaultType = getDefaultTypeArgumentType(isJavaScriptImplicitAny);
36938                 for (var i = numTypeArguments; i < numTypeParameters; i++) {
36939                     var defaultType = getDefaultFromTypeParameter(typeParameters[i]);
36940                     if (isJavaScriptImplicitAny && defaultType && (isTypeIdenticalTo(defaultType, unknownType) || isTypeIdenticalTo(defaultType, emptyObjectType))) {
36941                         defaultType = anyType;
36942                     }
36943                     result[i] = defaultType ? instantiateType(defaultType, createTypeMapper(typeParameters, result)) : baseDefaultType;
36944                 }
36945                 result.length = typeParameters.length;
36946                 return result;
36947             }
36948             return typeArguments && typeArguments.slice();
36949         }
36950         function getSignatureFromDeclaration(declaration) {
36951             var links = getNodeLinks(declaration);
36952             if (!links.resolvedSignature) {
36953                 var parameters = [];
36954                 var flags = 0;
36955                 var minArgumentCount = 0;
36956                 var thisParameter = void 0;
36957                 var hasThisParameter = false;
36958                 var iife = ts.getImmediatelyInvokedFunctionExpression(declaration);
36959                 var isJSConstructSignature = ts.isJSDocConstructSignature(declaration);
36960                 var isUntypedSignatureInJSFile = !iife &&
36961                     ts.isInJSFile(declaration) &&
36962                     ts.isValueSignatureDeclaration(declaration) &&
36963                     !ts.hasJSDocParameterTags(declaration) &&
36964                     !ts.getJSDocType(declaration);
36965                 if (isUntypedSignatureInJSFile) {
36966                     flags |= 16;
36967                 }
36968                 for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) {
36969                     var param = declaration.parameters[i];
36970                     var paramSymbol = param.symbol;
36971                     var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type;
36972                     if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) {
36973                         var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551, undefined, undefined, false);
36974                         paramSymbol = resolvedSymbol;
36975                     }
36976                     if (i === 0 && paramSymbol.escapedName === "this") {
36977                         hasThisParameter = true;
36978                         thisParameter = param.symbol;
36979                     }
36980                     else {
36981                         parameters.push(paramSymbol);
36982                     }
36983                     if (type && type.kind === 187) {
36984                         flags |= 2;
36985                     }
36986                     var isOptionalParameter_1 = isOptionalJSDocParameterTag(param) ||
36987                         param.initializer || param.questionToken || param.dotDotDotToken ||
36988                         iife && parameters.length > iife.arguments.length && !type ||
36989                         isJSDocOptionalParameter(param);
36990                     if (!isOptionalParameter_1) {
36991                         minArgumentCount = parameters.length;
36992                     }
36993                 }
36994                 if ((declaration.kind === 163 || declaration.kind === 164) &&
36995                     !hasNonBindableDynamicName(declaration) &&
36996                     (!hasThisParameter || !thisParameter)) {
36997                     var otherKind = declaration.kind === 163 ? 164 : 163;
36998                     var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind);
36999                     if (other) {
37000                         thisParameter = getAnnotatedAccessorThisParameter(other);
37001                     }
37002                 }
37003                 var classType = declaration.kind === 162 ?
37004                     getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol))
37005                     : undefined;
37006                 var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration);
37007                 if (ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) {
37008                     flags |= 1;
37009                 }
37010                 links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, undefined, undefined, minArgumentCount, flags);
37011             }
37012             return links.resolvedSignature;
37013         }
37014         function maybeAddJsSyntheticRestParameter(declaration, parameters) {
37015             if (ts.isJSDocSignature(declaration) || !containsArgumentsReference(declaration)) {
37016                 return false;
37017             }
37018             var lastParam = ts.lastOrUndefined(declaration.parameters);
37019             var lastParamTags = lastParam ? ts.getJSDocParameterTags(lastParam) : ts.getJSDocTags(declaration).filter(ts.isJSDocParameterTag);
37020             var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) {
37021                 return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined;
37022             });
37023             var syntheticArgsSymbol = createSymbol(3, "args", 32768);
37024             syntheticArgsSymbol.type = lastParamVariadicType ? createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)) : anyArrayType;
37025             if (lastParamVariadicType) {
37026                 parameters.pop();
37027             }
37028             parameters.push(syntheticArgsSymbol);
37029             return true;
37030         }
37031         function getSignatureOfTypeTag(node) {
37032             if (!(ts.isInJSFile(node) && ts.isFunctionLikeDeclaration(node)))
37033                 return undefined;
37034             var typeTag = ts.getJSDocTypeTag(node);
37035             var signature = typeTag && typeTag.typeExpression && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
37036             return signature && getErasedSignature(signature);
37037         }
37038         function getReturnTypeOfTypeTag(node) {
37039             var signature = getSignatureOfTypeTag(node);
37040             return signature && getReturnTypeOfSignature(signature);
37041         }
37042         function containsArgumentsReference(declaration) {
37043             var links = getNodeLinks(declaration);
37044             if (links.containsArgumentsReference === undefined) {
37045                 if (links.flags & 8192) {
37046                     links.containsArgumentsReference = true;
37047                 }
37048                 else {
37049                     links.containsArgumentsReference = traverse(declaration.body);
37050                 }
37051             }
37052             return links.containsArgumentsReference;
37053             function traverse(node) {
37054                 if (!node)
37055                     return false;
37056                 switch (node.kind) {
37057                     case 75:
37058                         return node.escapedText === "arguments" && ts.isExpressionNode(node);
37059                     case 159:
37060                     case 161:
37061                     case 163:
37062                     case 164:
37063                         return node.name.kind === 154
37064                             && traverse(node.name);
37065                     default:
37066                         return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse);
37067                 }
37068             }
37069         }
37070         function getSignaturesOfSymbol(symbol) {
37071             if (!symbol)
37072                 return ts.emptyArray;
37073             var result = [];
37074             for (var i = 0; i < symbol.declarations.length; i++) {
37075                 var decl = symbol.declarations[i];
37076                 if (!ts.isFunctionLike(decl))
37077                     continue;
37078                 if (i > 0 && decl.body) {
37079                     var previous = symbol.declarations[i - 1];
37080                     if (decl.parent === previous.parent && decl.kind === previous.kind && decl.pos === previous.end) {
37081                         continue;
37082                     }
37083                 }
37084                 result.push(getSignatureFromDeclaration(decl));
37085             }
37086             return result;
37087         }
37088         function resolveExternalModuleTypeByLiteral(name) {
37089             var moduleSym = resolveExternalModuleName(name, name);
37090             if (moduleSym) {
37091                 var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym);
37092                 if (resolvedModuleSymbol) {
37093                     return getTypeOfSymbol(resolvedModuleSymbol);
37094                 }
37095             }
37096             return anyType;
37097         }
37098         function getThisTypeOfSignature(signature) {
37099             if (signature.thisParameter) {
37100                 return getTypeOfSymbol(signature.thisParameter);
37101             }
37102         }
37103         function getTypePredicateOfSignature(signature) {
37104             if (!signature.resolvedTypePredicate) {
37105                 if (signature.target) {
37106                     var targetTypePredicate = getTypePredicateOfSignature(signature.target);
37107                     signature.resolvedTypePredicate = targetTypePredicate ? instantiateTypePredicate(targetTypePredicate, signature.mapper) : noTypePredicate;
37108                 }
37109                 else if (signature.unionSignatures) {
37110                     signature.resolvedTypePredicate = getUnionTypePredicate(signature.unionSignatures) || noTypePredicate;
37111                 }
37112                 else {
37113                     var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
37114                     var jsdocPredicate = void 0;
37115                     if (!type && ts.isInJSFile(signature.declaration)) {
37116                         var jsdocSignature = getSignatureOfTypeTag(signature.declaration);
37117                         if (jsdocSignature && signature !== jsdocSignature) {
37118                             jsdocPredicate = getTypePredicateOfSignature(jsdocSignature);
37119                         }
37120                     }
37121                     signature.resolvedTypePredicate = type && ts.isTypePredicateNode(type) ?
37122                         createTypePredicateFromTypePredicateNode(type, signature) :
37123                         jsdocPredicate || noTypePredicate;
37124                 }
37125                 ts.Debug.assert(!!signature.resolvedTypePredicate);
37126             }
37127             return signature.resolvedTypePredicate === noTypePredicate ? undefined : signature.resolvedTypePredicate;
37128         }
37129         function createTypePredicateFromTypePredicateNode(node, signature) {
37130             var parameterName = node.parameterName;
37131             var type = node.type && getTypeFromTypeNode(node.type);
37132             return parameterName.kind === 183 ?
37133                 createTypePredicate(node.assertsModifier ? 2 : 0, undefined, undefined, type) :
37134                 createTypePredicate(node.assertsModifier ? 3 : 1, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type);
37135         }
37136         function getReturnTypeOfSignature(signature) {
37137             if (!signature.resolvedReturnType) {
37138                 if (!pushTypeResolution(signature, 3)) {
37139                     return errorType;
37140                 }
37141                 var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) :
37142                     signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2) :
37143                         getReturnTypeFromAnnotation(signature.declaration) ||
37144                             (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration));
37145                 if (signature.flags & 4) {
37146                     type = addOptionalTypeMarker(type);
37147                 }
37148                 else if (signature.flags & 8) {
37149                     type = getOptionalType(type);
37150                 }
37151                 if (!popTypeResolution()) {
37152                     if (signature.declaration) {
37153                         var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration);
37154                         if (typeNode) {
37155                             error(typeNode, ts.Diagnostics.Return_type_annotation_circularly_references_itself);
37156                         }
37157                         else if (noImplicitAny) {
37158                             var declaration = signature.declaration;
37159                             var name = ts.getNameOfDeclaration(declaration);
37160                             if (name) {
37161                                 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));
37162                             }
37163                             else {
37164                                 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);
37165                             }
37166                         }
37167                     }
37168                     type = anyType;
37169                 }
37170                 signature.resolvedReturnType = type;
37171             }
37172             return signature.resolvedReturnType;
37173         }
37174         function getReturnTypeFromAnnotation(declaration) {
37175             if (declaration.kind === 162) {
37176                 return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol));
37177             }
37178             if (ts.isJSDocConstructSignature(declaration)) {
37179                 return getTypeFromTypeNode(declaration.parameters[0].type);
37180             }
37181             var typeNode = ts.getEffectiveReturnTypeNode(declaration);
37182             if (typeNode) {
37183                 return getTypeFromTypeNode(typeNode);
37184             }
37185             if (declaration.kind === 163 && !hasNonBindableDynamicName(declaration)) {
37186                 var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration);
37187                 if (jsDocType) {
37188                     return jsDocType;
37189                 }
37190                 var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 164);
37191                 var setterType = getAnnotatedAccessorType(setter);
37192                 if (setterType) {
37193                     return setterType;
37194                 }
37195             }
37196             return getReturnTypeOfTypeTag(declaration);
37197         }
37198         function isResolvingReturnTypeOfSignature(signature) {
37199             return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3) >= 0;
37200         }
37201         function getRestTypeOfSignature(signature) {
37202             return tryGetRestTypeOfSignature(signature) || anyType;
37203         }
37204         function tryGetRestTypeOfSignature(signature) {
37205             if (signatureHasRestParameter(signature)) {
37206                 var sigRestType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
37207                 var restType = isTupleType(sigRestType) ? getRestTypeOfTupleType(sigRestType) : sigRestType;
37208                 return restType && getIndexTypeOfType(restType, 1);
37209             }
37210             return undefined;
37211         }
37212         function getSignatureInstantiation(signature, typeArguments, isJavascript, inferredTypeParameters) {
37213             var instantiatedSignature = getSignatureInstantiationWithoutFillingInTypeArguments(signature, fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript));
37214             if (inferredTypeParameters) {
37215                 var returnSignature = getSingleCallOrConstructSignature(getReturnTypeOfSignature(instantiatedSignature));
37216                 if (returnSignature) {
37217                     var newReturnSignature = cloneSignature(returnSignature);
37218                     newReturnSignature.typeParameters = inferredTypeParameters;
37219                     var newInstantiatedSignature = cloneSignature(instantiatedSignature);
37220                     newInstantiatedSignature.resolvedReturnType = getOrCreateTypeFromSignature(newReturnSignature);
37221                     return newInstantiatedSignature;
37222                 }
37223             }
37224             return instantiatedSignature;
37225         }
37226         function getSignatureInstantiationWithoutFillingInTypeArguments(signature, typeArguments) {
37227             var instantiations = signature.instantiations || (signature.instantiations = ts.createMap());
37228             var id = getTypeListId(typeArguments);
37229             var instantiation = instantiations.get(id);
37230             if (!instantiation) {
37231                 instantiations.set(id, instantiation = createSignatureInstantiation(signature, typeArguments));
37232             }
37233             return instantiation;
37234         }
37235         function createSignatureInstantiation(signature, typeArguments) {
37236             return instantiateSignature(signature, createSignatureTypeMapper(signature, typeArguments), true);
37237         }
37238         function createSignatureTypeMapper(signature, typeArguments) {
37239             return createTypeMapper(signature.typeParameters, typeArguments);
37240         }
37241         function getErasedSignature(signature) {
37242             return signature.typeParameters ?
37243                 signature.erasedSignatureCache || (signature.erasedSignatureCache = createErasedSignature(signature)) :
37244                 signature;
37245         }
37246         function createErasedSignature(signature) {
37247             return instantiateSignature(signature, createTypeEraser(signature.typeParameters), true);
37248         }
37249         function getCanonicalSignature(signature) {
37250             return signature.typeParameters ?
37251                 signature.canonicalSignatureCache || (signature.canonicalSignatureCache = createCanonicalSignature(signature)) :
37252                 signature;
37253         }
37254         function createCanonicalSignature(signature) {
37255             return getSignatureInstantiation(signature, ts.map(signature.typeParameters, function (tp) { return tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp; }), ts.isInJSFile(signature.declaration));
37256         }
37257         function getBaseSignature(signature) {
37258             var typeParameters = signature.typeParameters;
37259             if (typeParameters) {
37260                 var typeEraser_1 = createTypeEraser(typeParameters);
37261                 var baseConstraints = ts.map(typeParameters, function (tp) { return instantiateType(getBaseConstraintOfType(tp), typeEraser_1) || unknownType; });
37262                 return instantiateSignature(signature, createTypeMapper(typeParameters, baseConstraints), true);
37263             }
37264             return signature;
37265         }
37266         function getOrCreateTypeFromSignature(signature) {
37267             if (!signature.isolatedSignatureType) {
37268                 var kind = signature.declaration ? signature.declaration.kind : 0;
37269                 var isConstructor = kind === 162 || kind === 166 || kind === 171;
37270                 var type = createObjectType(16);
37271                 type.members = emptySymbols;
37272                 type.properties = ts.emptyArray;
37273                 type.callSignatures = !isConstructor ? [signature] : ts.emptyArray;
37274                 type.constructSignatures = isConstructor ? [signature] : ts.emptyArray;
37275                 signature.isolatedSignatureType = type;
37276             }
37277             return signature.isolatedSignatureType;
37278         }
37279         function getIndexSymbol(symbol) {
37280             return symbol.members.get("__index");
37281         }
37282         function getIndexDeclarationOfSymbol(symbol, kind) {
37283             var syntaxKind = kind === 1 ? 140 : 143;
37284             var indexSymbol = getIndexSymbol(symbol);
37285             if (indexSymbol) {
37286                 for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
37287                     var decl = _a[_i];
37288                     var node = ts.cast(decl, ts.isIndexSignatureDeclaration);
37289                     if (node.parameters.length === 1) {
37290                         var parameter = node.parameters[0];
37291                         if (parameter.type && parameter.type.kind === syntaxKind) {
37292                             return node;
37293                         }
37294                     }
37295                 }
37296             }
37297             return undefined;
37298         }
37299         function createIndexInfo(type, isReadonly, declaration) {
37300             return { type: type, isReadonly: isReadonly, declaration: declaration };
37301         }
37302         function getIndexInfoOfSymbol(symbol, kind) {
37303             var declaration = getIndexDeclarationOfSymbol(symbol, kind);
37304             if (declaration) {
37305                 return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasModifier(declaration, 64), declaration);
37306             }
37307             return undefined;
37308         }
37309         function getConstraintDeclaration(type) {
37310             return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0];
37311         }
37312         function getInferredTypeParameterConstraint(typeParameter) {
37313             var inferences;
37314             if (typeParameter.symbol) {
37315                 for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) {
37316                     var declaration = _a[_i];
37317                     if (declaration.parent.kind === 181) {
37318                         var grandParent = declaration.parent.parent;
37319                         if (grandParent.kind === 169) {
37320                             var typeReference = grandParent;
37321                             var typeParameters = getTypeParametersForTypeReference(typeReference);
37322                             if (typeParameters) {
37323                                 var index = typeReference.typeArguments.indexOf(declaration.parent);
37324                                 if (index < typeParameters.length) {
37325                                     var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]);
37326                                     if (declaredConstraint) {
37327                                         var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters));
37328                                         var constraint = instantiateType(declaredConstraint, mapper);
37329                                         if (constraint !== typeParameter) {
37330                                             inferences = ts.append(inferences, constraint);
37331                                         }
37332                                     }
37333                                 }
37334                             }
37335                         }
37336                         else if (grandParent.kind === 156 && grandParent.dotDotDotToken) {
37337                             inferences = ts.append(inferences, createArrayType(unknownType));
37338                         }
37339                     }
37340                 }
37341             }
37342             return inferences && getIntersectionType(inferences);
37343         }
37344         function getConstraintFromTypeParameter(typeParameter) {
37345             if (!typeParameter.constraint) {
37346                 if (typeParameter.target) {
37347                     var targetConstraint = getConstraintOfTypeParameter(typeParameter.target);
37348                     typeParameter.constraint = targetConstraint ? instantiateType(targetConstraint, typeParameter.mapper) : noConstraintType;
37349                 }
37350                 else {
37351                     var constraintDeclaration = getConstraintDeclaration(typeParameter);
37352                     if (!constraintDeclaration) {
37353                         typeParameter.constraint = getInferredTypeParameterConstraint(typeParameter) || noConstraintType;
37354                     }
37355                     else {
37356                         var type = getTypeFromTypeNode(constraintDeclaration);
37357                         if (type.flags & 1 && type !== errorType) {
37358                             type = constraintDeclaration.parent.parent.kind === 186 ? keyofConstraintType : unknownType;
37359                         }
37360                         typeParameter.constraint = type;
37361                     }
37362                 }
37363             }
37364             return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint;
37365         }
37366         function getParentSymbolOfTypeParameter(typeParameter) {
37367             var tp = ts.getDeclarationOfKind(typeParameter.symbol, 155);
37368             var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent;
37369             return host && getSymbolOfNode(host);
37370         }
37371         function getTypeListId(types) {
37372             var result = "";
37373             if (types) {
37374                 var length_4 = types.length;
37375                 var i = 0;
37376                 while (i < length_4) {
37377                     var startId = types[i].id;
37378                     var count = 1;
37379                     while (i + count < length_4 && types[i + count].id === startId + count) {
37380                         count++;
37381                     }
37382                     if (result.length) {
37383                         result += ",";
37384                     }
37385                     result += startId;
37386                     if (count > 1) {
37387                         result += ":" + count;
37388                     }
37389                     i += count;
37390                 }
37391             }
37392             return result;
37393         }
37394         function getPropagatingFlagsOfTypes(types, excludeKinds) {
37395             var result = 0;
37396             for (var _i = 0, types_8 = types; _i < types_8.length; _i++) {
37397                 var type = types_8[_i];
37398                 if (!(type.flags & excludeKinds)) {
37399                     result |= ts.getObjectFlags(type);
37400                 }
37401             }
37402             return result & 3670016;
37403         }
37404         function createTypeReference(target, typeArguments) {
37405             var id = getTypeListId(typeArguments);
37406             var type = target.instantiations.get(id);
37407             if (!type) {
37408                 type = createObjectType(4, target.symbol);
37409                 target.instantiations.set(id, type);
37410                 type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, 0) : 0;
37411                 type.target = target;
37412                 type.resolvedTypeArguments = typeArguments;
37413             }
37414             return type;
37415         }
37416         function cloneTypeReference(source) {
37417             var type = createType(source.flags);
37418             type.symbol = source.symbol;
37419             type.objectFlags = source.objectFlags;
37420             type.target = source.target;
37421             type.resolvedTypeArguments = source.resolvedTypeArguments;
37422             return type;
37423         }
37424         function createDeferredTypeReference(target, node, mapper) {
37425             var aliasSymbol = getAliasSymbolForTypeNode(node);
37426             var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
37427             var type = createObjectType(4, target.symbol);
37428             type.target = target;
37429             type.node = node;
37430             type.mapper = mapper;
37431             type.aliasSymbol = aliasSymbol;
37432             type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments;
37433             return type;
37434         }
37435         function getTypeArguments(type) {
37436             var _a, _b;
37437             if (!type.resolvedTypeArguments) {
37438                 if (!pushTypeResolution(type, 6)) {
37439                     return ((_a = type.target.localTypeParameters) === null || _a === void 0 ? void 0 : _a.map(function () { return errorType; })) || ts.emptyArray;
37440                 }
37441                 var node = type.node;
37442                 var typeArguments = !node ? ts.emptyArray :
37443                     node.kind === 169 ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) :
37444                         node.kind === 174 ? [getTypeFromTypeNode(node.elementType)] :
37445                             ts.map(node.elementTypes, getTypeFromTypeNode);
37446                 if (popTypeResolution()) {
37447                     type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments;
37448                 }
37449                 else {
37450                     type.resolvedTypeArguments = ((_b = type.target.localTypeParameters) === null || _b === void 0 ? void 0 : _b.map(function () { return errorType; })) || ts.emptyArray;
37451                     error(type.node || currentNode, type.target.symbol
37452                         ? ts.Diagnostics.Type_arguments_for_0_circularly_reference_themselves
37453                         : ts.Diagnostics.Tuple_type_arguments_circularly_reference_themselves, type.target.symbol && symbolToString(type.target.symbol));
37454                 }
37455             }
37456             return type.resolvedTypeArguments;
37457         }
37458         function getTypeReferenceArity(type) {
37459             return ts.length(type.target.typeParameters);
37460         }
37461         function getTypeFromClassOrInterfaceReference(node, symbol) {
37462             var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol));
37463             var typeParameters = type.localTypeParameters;
37464             if (typeParameters) {
37465                 var numTypeArguments = ts.length(node.typeArguments);
37466                 var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters);
37467                 var isJs = ts.isInJSFile(node);
37468                 var isJsImplicitAny = !noImplicitAny && isJs;
37469                 if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) {
37470                     var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent);
37471                     var diag = minTypeArgumentCount === typeParameters.length ?
37472                         missingAugmentsTag ?
37473                             ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag :
37474                             ts.Diagnostics.Generic_type_0_requires_1_type_argument_s :
37475                         missingAugmentsTag ?
37476                             ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag :
37477                             ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments;
37478                     var typeStr = typeToString(type, undefined, 2);
37479                     error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length);
37480                     if (!isJs) {
37481                         return errorType;
37482                     }
37483                 }
37484                 if (node.kind === 169 && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) {
37485                     return createDeferredTypeReference(type, node, undefined);
37486                 }
37487                 var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgumentsFromTypeReferenceNode(node), typeParameters, minTypeArgumentCount, isJs));
37488                 return createTypeReference(type, typeArguments);
37489             }
37490             return checkNoTypeArguments(node, symbol) ? type : errorType;
37491         }
37492         function getTypeAliasInstantiation(symbol, typeArguments) {
37493             var type = getDeclaredTypeOfSymbol(symbol);
37494             var links = getSymbolLinks(symbol);
37495             var typeParameters = links.typeParameters;
37496             var id = getTypeListId(typeArguments);
37497             var instantiation = links.instantiations.get(id);
37498             if (!instantiation) {
37499                 links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration)))));
37500             }
37501             return instantiation;
37502         }
37503         function getTypeFromTypeAliasReference(node, symbol) {
37504             var type = getDeclaredTypeOfSymbol(symbol);
37505             var typeParameters = getSymbolLinks(symbol).typeParameters;
37506             if (typeParameters) {
37507                 var numTypeArguments = ts.length(node.typeArguments);
37508                 var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters);
37509                 if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) {
37510                     error(node, minTypeArgumentCount === typeParameters.length ?
37511                         ts.Diagnostics.Generic_type_0_requires_1_type_argument_s :
37512                         ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length);
37513                     return errorType;
37514                 }
37515                 return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node));
37516             }
37517             return checkNoTypeArguments(node, symbol) ? type : errorType;
37518         }
37519         function getTypeReferenceName(node) {
37520             switch (node.kind) {
37521                 case 169:
37522                     return node.typeName;
37523                 case 216:
37524                     var expr = node.expression;
37525                     if (ts.isEntityNameExpression(expr)) {
37526                         return expr;
37527                     }
37528             }
37529             return undefined;
37530         }
37531         function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) {
37532             if (!typeReferenceName) {
37533                 return unknownSymbol;
37534             }
37535             return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol;
37536         }
37537         function getTypeReferenceType(node, symbol) {
37538             if (symbol === unknownSymbol) {
37539                 return errorType;
37540             }
37541             symbol = getExpandoSymbol(symbol) || symbol;
37542             if (symbol.flags & (32 | 64)) {
37543                 return getTypeFromClassOrInterfaceReference(node, symbol);
37544             }
37545             if (symbol.flags & 524288) {
37546                 return getTypeFromTypeAliasReference(node, symbol);
37547             }
37548             var res = tryGetDeclaredTypeOfSymbol(symbol);
37549             if (res) {
37550                 return checkNoTypeArguments(node, symbol) ? getRegularTypeOfLiteralType(res) : errorType;
37551             }
37552             if (symbol.flags & 111551 && isJSDocTypeReference(node)) {
37553                 var jsdocType = getTypeFromJSDocValueReference(node, symbol);
37554                 if (jsdocType) {
37555                     return jsdocType;
37556                 }
37557                 else {
37558                     resolveTypeReferenceName(getTypeReferenceName(node), 788968);
37559                     return getTypeOfSymbol(symbol);
37560                 }
37561             }
37562             return errorType;
37563         }
37564         function getTypeFromJSDocValueReference(node, symbol) {
37565             var links = getNodeLinks(node);
37566             if (!links.resolvedJSDocType) {
37567                 var valueType = getTypeOfSymbol(symbol);
37568                 var typeType = valueType;
37569                 if (symbol.valueDeclaration) {
37570                     var decl = ts.getRootDeclaration(symbol.valueDeclaration);
37571                     var isRequireAlias = false;
37572                     if (ts.isVariableDeclaration(decl) && decl.initializer) {
37573                         var expr = decl.initializer;
37574                         while (ts.isPropertyAccessExpression(expr)) {
37575                             expr = expr.expression;
37576                         }
37577                         isRequireAlias = ts.isCallExpression(expr) && ts.isRequireCall(expr, true) && !!valueType.symbol;
37578                     }
37579                     var isImportTypeWithQualifier = node.kind === 188 && node.qualifier;
37580                     if (valueType.symbol && (isRequireAlias || isImportTypeWithQualifier)) {
37581                         typeType = getTypeReferenceType(node, valueType.symbol);
37582                     }
37583                 }
37584                 links.resolvedJSDocType = typeType;
37585             }
37586             return links.resolvedJSDocType;
37587         }
37588         function getSubstitutionType(baseType, substitute) {
37589             if (substitute.flags & 3 || substitute === baseType) {
37590                 return baseType;
37591             }
37592             var id = getTypeId(baseType) + ">" + getTypeId(substitute);
37593             var cached = substitutionTypes.get(id);
37594             if (cached) {
37595                 return cached;
37596             }
37597             var result = createType(33554432);
37598             result.baseType = baseType;
37599             result.substitute = substitute;
37600             substitutionTypes.set(id, result);
37601             return result;
37602         }
37603         function isUnaryTupleTypeNode(node) {
37604             return node.kind === 175 && node.elementTypes.length === 1;
37605         }
37606         function getImpliedConstraint(type, checkNode, extendsNode) {
37607             return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elementTypes[0], extendsNode.elementTypes[0]) :
37608                 getActualTypeVariable(getTypeFromTypeNode(checkNode)) === type ? getTypeFromTypeNode(extendsNode) :
37609                     undefined;
37610         }
37611         function getConditionalFlowTypeOfType(type, node) {
37612             var constraints;
37613             while (node && !ts.isStatement(node) && node.kind !== 303) {
37614                 var parent = node.parent;
37615                 if (parent.kind === 180 && node === parent.trueType) {
37616                     var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType);
37617                     if (constraint) {
37618                         constraints = ts.append(constraints, constraint);
37619                     }
37620                 }
37621                 node = parent;
37622             }
37623             return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
37624         }
37625         function isJSDocTypeReference(node) {
37626             return !!(node.flags & 4194304) && (node.kind === 169 || node.kind === 188);
37627         }
37628         function checkNoTypeArguments(node, symbol) {
37629             if (node.typeArguments) {
37630                 error(node, ts.Diagnostics.Type_0_is_not_generic, symbol ? symbolToString(symbol) : node.typeName ? ts.declarationNameToString(node.typeName) : anon);
37631                 return false;
37632             }
37633             return true;
37634         }
37635         function getIntendedTypeFromJSDocTypeReference(node) {
37636             if (ts.isIdentifier(node.typeName)) {
37637                 var typeArgs = node.typeArguments;
37638                 switch (node.typeName.escapedText) {
37639                     case "String":
37640                         checkNoTypeArguments(node);
37641                         return stringType;
37642                     case "Number":
37643                         checkNoTypeArguments(node);
37644                         return numberType;
37645                     case "Boolean":
37646                         checkNoTypeArguments(node);
37647                         return booleanType;
37648                     case "Void":
37649                         checkNoTypeArguments(node);
37650                         return voidType;
37651                     case "Undefined":
37652                         checkNoTypeArguments(node);
37653                         return undefinedType;
37654                     case "Null":
37655                         checkNoTypeArguments(node);
37656                         return nullType;
37657                     case "Function":
37658                     case "function":
37659                         checkNoTypeArguments(node);
37660                         return globalFunctionType;
37661                     case "array":
37662                         return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined;
37663                     case "promise":
37664                         return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined;
37665                     case "Object":
37666                         if (typeArgs && typeArgs.length === 2) {
37667                             if (ts.isJSDocIndexSignature(node)) {
37668                                 var indexed = getTypeFromTypeNode(typeArgs[0]);
37669                                 var target = getTypeFromTypeNode(typeArgs[1]);
37670                                 var index = createIndexInfo(target, false);
37671                                 return createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, indexed === stringType ? index : undefined, indexed === numberType ? index : undefined);
37672                             }
37673                             return anyType;
37674                         }
37675                         checkNoTypeArguments(node);
37676                         return !noImplicitAny ? anyType : undefined;
37677                 }
37678             }
37679         }
37680         function getTypeFromJSDocNullableTypeNode(node) {
37681             var type = getTypeFromTypeNode(node.type);
37682             return strictNullChecks ? getNullableType(type, 65536) : type;
37683         }
37684         function getTypeFromTypeReference(node) {
37685             var links = getNodeLinks(node);
37686             if (!links.resolvedType) {
37687                 if (ts.isConstTypeReference(node) && ts.isAssertionExpression(node.parent)) {
37688                     links.resolvedSymbol = unknownSymbol;
37689                     return links.resolvedType = checkExpressionCached(node.parent.expression);
37690                 }
37691                 var symbol = void 0;
37692                 var type = void 0;
37693                 var meaning = 788968;
37694                 if (isJSDocTypeReference(node)) {
37695                     type = getIntendedTypeFromJSDocTypeReference(node);
37696                     if (!type) {
37697                         symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, true);
37698                         if (symbol === unknownSymbol) {
37699                             symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551);
37700                         }
37701                         else {
37702                             resolveTypeReferenceName(getTypeReferenceName(node), meaning);
37703                         }
37704                         type = getTypeReferenceType(node, symbol);
37705                     }
37706                 }
37707                 if (!type) {
37708                     symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning);
37709                     type = getTypeReferenceType(node, symbol);
37710                 }
37711                 links.resolvedSymbol = symbol;
37712                 links.resolvedType = type;
37713             }
37714             return links.resolvedType;
37715         }
37716         function typeArgumentsFromTypeReferenceNode(node) {
37717             return ts.map(node.typeArguments, getTypeFromTypeNode);
37718         }
37719         function getTypeFromTypeQueryNode(node) {
37720             var links = getNodeLinks(node);
37721             if (!links.resolvedType) {
37722                 links.resolvedType = getRegularTypeOfLiteralType(getWidenedType(checkExpression(node.exprName)));
37723             }
37724             return links.resolvedType;
37725         }
37726         function getTypeOfGlobalSymbol(symbol, arity) {
37727             function getTypeDeclaration(symbol) {
37728                 var declarations = symbol.declarations;
37729                 for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) {
37730                     var declaration = declarations_3[_i];
37731                     switch (declaration.kind) {
37732                         case 245:
37733                         case 246:
37734                         case 248:
37735                             return declaration;
37736                     }
37737                 }
37738             }
37739             if (!symbol) {
37740                 return arity ? emptyGenericType : emptyObjectType;
37741             }
37742             var type = getDeclaredTypeOfSymbol(symbol);
37743             if (!(type.flags & 524288)) {
37744                 error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol));
37745                 return arity ? emptyGenericType : emptyObjectType;
37746             }
37747             if (ts.length(type.typeParameters) !== arity) {
37748                 error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, ts.symbolName(symbol), arity);
37749                 return arity ? emptyGenericType : emptyObjectType;
37750             }
37751             return type;
37752         }
37753         function getGlobalValueSymbol(name, reportErrors) {
37754             return getGlobalSymbol(name, 111551, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined);
37755         }
37756         function getGlobalTypeSymbol(name, reportErrors) {
37757             return getGlobalSymbol(name, 788968, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined);
37758         }
37759         function getGlobalSymbol(name, meaning, diagnostic) {
37760             return resolveName(undefined, name, meaning, diagnostic, name, false);
37761         }
37762         function getGlobalType(name, arity, reportErrors) {
37763             var symbol = getGlobalTypeSymbol(name, reportErrors);
37764             return symbol || reportErrors ? getTypeOfGlobalSymbol(symbol, arity) : undefined;
37765         }
37766         function getGlobalTypedPropertyDescriptorType() {
37767             return deferredGlobalTypedPropertyDescriptorType || (deferredGlobalTypedPropertyDescriptorType = getGlobalType("TypedPropertyDescriptor", 1, true)) || emptyGenericType;
37768         }
37769         function getGlobalTemplateStringsArrayType() {
37770             return deferredGlobalTemplateStringsArrayType || (deferredGlobalTemplateStringsArrayType = getGlobalType("TemplateStringsArray", 0, true)) || emptyObjectType;
37771         }
37772         function getGlobalImportMetaType() {
37773             return deferredGlobalImportMetaType || (deferredGlobalImportMetaType = getGlobalType("ImportMeta", 0, true)) || emptyObjectType;
37774         }
37775         function getGlobalESSymbolConstructorSymbol(reportErrors) {
37776             return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors));
37777         }
37778         function getGlobalESSymbolType(reportErrors) {
37779             return deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", 0, reportErrors)) || emptyObjectType;
37780         }
37781         function getGlobalPromiseType(reportErrors) {
37782             return deferredGlobalPromiseType || (deferredGlobalPromiseType = getGlobalType("Promise", 1, reportErrors)) || emptyGenericType;
37783         }
37784         function getGlobalPromiseLikeType(reportErrors) {
37785             return deferredGlobalPromiseLikeType || (deferredGlobalPromiseLikeType = getGlobalType("PromiseLike", 1, reportErrors)) || emptyGenericType;
37786         }
37787         function getGlobalPromiseConstructorSymbol(reportErrors) {
37788             return deferredGlobalPromiseConstructorSymbol || (deferredGlobalPromiseConstructorSymbol = getGlobalValueSymbol("Promise", reportErrors));
37789         }
37790         function getGlobalPromiseConstructorLikeType(reportErrors) {
37791             return deferredGlobalPromiseConstructorLikeType || (deferredGlobalPromiseConstructorLikeType = getGlobalType("PromiseConstructorLike", 0, reportErrors)) || emptyObjectType;
37792         }
37793         function getGlobalAsyncIterableType(reportErrors) {
37794             return deferredGlobalAsyncIterableType || (deferredGlobalAsyncIterableType = getGlobalType("AsyncIterable", 1, reportErrors)) || emptyGenericType;
37795         }
37796         function getGlobalAsyncIteratorType(reportErrors) {
37797             return deferredGlobalAsyncIteratorType || (deferredGlobalAsyncIteratorType = getGlobalType("AsyncIterator", 3, reportErrors)) || emptyGenericType;
37798         }
37799         function getGlobalAsyncIterableIteratorType(reportErrors) {
37800             return deferredGlobalAsyncIterableIteratorType || (deferredGlobalAsyncIterableIteratorType = getGlobalType("AsyncIterableIterator", 1, reportErrors)) || emptyGenericType;
37801         }
37802         function getGlobalAsyncGeneratorType(reportErrors) {
37803             return deferredGlobalAsyncGeneratorType || (deferredGlobalAsyncGeneratorType = getGlobalType("AsyncGenerator", 3, reportErrors)) || emptyGenericType;
37804         }
37805         function getGlobalIterableType(reportErrors) {
37806             return deferredGlobalIterableType || (deferredGlobalIterableType = getGlobalType("Iterable", 1, reportErrors)) || emptyGenericType;
37807         }
37808         function getGlobalIteratorType(reportErrors) {
37809             return deferredGlobalIteratorType || (deferredGlobalIteratorType = getGlobalType("Iterator", 3, reportErrors)) || emptyGenericType;
37810         }
37811         function getGlobalIterableIteratorType(reportErrors) {
37812             return deferredGlobalIterableIteratorType || (deferredGlobalIterableIteratorType = getGlobalType("IterableIterator", 1, reportErrors)) || emptyGenericType;
37813         }
37814         function getGlobalGeneratorType(reportErrors) {
37815             return deferredGlobalGeneratorType || (deferredGlobalGeneratorType = getGlobalType("Generator", 3, reportErrors)) || emptyGenericType;
37816         }
37817         function getGlobalIteratorYieldResultType(reportErrors) {
37818             return deferredGlobalIteratorYieldResultType || (deferredGlobalIteratorYieldResultType = getGlobalType("IteratorYieldResult", 1, reportErrors)) || emptyGenericType;
37819         }
37820         function getGlobalIteratorReturnResultType(reportErrors) {
37821             return deferredGlobalIteratorReturnResultType || (deferredGlobalIteratorReturnResultType = getGlobalType("IteratorReturnResult", 1, reportErrors)) || emptyGenericType;
37822         }
37823         function getGlobalTypeOrUndefined(name, arity) {
37824             if (arity === void 0) { arity = 0; }
37825             var symbol = getGlobalSymbol(name, 788968, undefined);
37826             return symbol && getTypeOfGlobalSymbol(symbol, arity);
37827         }
37828         function getGlobalExtractSymbol() {
37829             return deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalSymbol("Extract", 524288, ts.Diagnostics.Cannot_find_global_type_0));
37830         }
37831         function getGlobalOmitSymbol() {
37832             return deferredGlobalOmitSymbol || (deferredGlobalOmitSymbol = getGlobalSymbol("Omit", 524288, ts.Diagnostics.Cannot_find_global_type_0));
37833         }
37834         function getGlobalBigIntType(reportErrors) {
37835             return deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", 0, reportErrors)) || emptyObjectType;
37836         }
37837         function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) {
37838             return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType;
37839         }
37840         function createTypedPropertyDescriptorType(propertyType) {
37841             return createTypeFromGenericGlobalType(getGlobalTypedPropertyDescriptorType(), [propertyType]);
37842         }
37843         function createIterableType(iteratedType) {
37844             return createTypeFromGenericGlobalType(getGlobalIterableType(true), [iteratedType]);
37845         }
37846         function createArrayType(elementType, readonly) {
37847             return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]);
37848         }
37849         function getArrayOrTupleTargetType(node) {
37850             var readonly = isReadonlyTypeOperator(node.parent);
37851             if (node.kind === 174 || node.elementTypes.length === 1 && node.elementTypes[0].kind === 177) {
37852                 return readonly ? globalReadonlyArrayType : globalArrayType;
37853             }
37854             var lastElement = ts.lastOrUndefined(node.elementTypes);
37855             var restElement = lastElement && lastElement.kind === 177 ? lastElement : undefined;
37856             var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 176 && n !== restElement; }) + 1;
37857             return getTupleTypeOfArity(node.elementTypes.length, minLength, !!restElement, readonly, undefined);
37858         }
37859         function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) {
37860             return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 174 ? mayResolveTypeAlias(node.elementType) :
37861                 node.kind === 175 ? ts.some(node.elementTypes, mayResolveTypeAlias) :
37862                     hasDefaultTypeArguments || ts.some(node.typeArguments, mayResolveTypeAlias));
37863         }
37864         function isResolvedByTypeAlias(node) {
37865             var parent = node.parent;
37866             switch (parent.kind) {
37867                 case 182:
37868                 case 169:
37869                 case 178:
37870                 case 179:
37871                 case 185:
37872                 case 180:
37873                 case 184:
37874                 case 174:
37875                 case 175:
37876                     return isResolvedByTypeAlias(parent);
37877                 case 247:
37878                     return true;
37879             }
37880             return false;
37881         }
37882         function mayResolveTypeAlias(node) {
37883             switch (node.kind) {
37884                 case 169:
37885                     return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node.typeName, 788968).flags & 524288);
37886                 case 172:
37887                     return true;
37888                 case 184:
37889                     return node.operator !== 147 && mayResolveTypeAlias(node.type);
37890                 case 182:
37891                 case 176:
37892                 case 299:
37893                 case 297:
37894                 case 298:
37895                 case 294:
37896                     return mayResolveTypeAlias(node.type);
37897                 case 177:
37898                     return node.type.kind !== 174 || mayResolveTypeAlias(node.type.elementType);
37899                 case 178:
37900                 case 179:
37901                     return ts.some(node.types, mayResolveTypeAlias);
37902                 case 185:
37903                     return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType);
37904                 case 180:
37905                     return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) ||
37906                         mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType);
37907             }
37908             return false;
37909         }
37910         function getTypeFromArrayOrTupleTypeNode(node) {
37911             var links = getNodeLinks(node);
37912             if (!links.resolvedType) {
37913                 var target = getArrayOrTupleTargetType(node);
37914                 if (target === emptyGenericType) {
37915                     links.resolvedType = emptyObjectType;
37916                 }
37917                 else if (isDeferredTypeReferenceNode(node)) {
37918                     links.resolvedType = node.kind === 175 && node.elementTypes.length === 0 ? target :
37919                         createDeferredTypeReference(target, node, undefined);
37920                 }
37921                 else {
37922                     var elementTypes = node.kind === 174 ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elementTypes, getTypeFromTypeNode);
37923                     links.resolvedType = createTypeReference(target, elementTypes);
37924                 }
37925             }
37926             return links.resolvedType;
37927         }
37928         function isReadonlyTypeOperator(node) {
37929             return ts.isTypeOperatorNode(node) && node.operator === 138;
37930         }
37931         function createTupleTypeOfArity(arity, minLength, hasRestElement, readonly, associatedNames) {
37932             var typeParameters;
37933             var properties = [];
37934             var maxLength = hasRestElement ? arity - 1 : arity;
37935             if (arity) {
37936                 typeParameters = new Array(arity);
37937                 for (var i = 0; i < arity; i++) {
37938                     var typeParameter = typeParameters[i] = createTypeParameter();
37939                     if (i < maxLength) {
37940                         var property = createSymbol(4 | (i >= minLength ? 16777216 : 0), "" + i, readonly ? 8 : 0);
37941                         property.type = typeParameter;
37942                         properties.push(property);
37943                     }
37944                 }
37945             }
37946             var literalTypes = [];
37947             for (var i = minLength; i <= maxLength; i++)
37948                 literalTypes.push(getLiteralType(i));
37949             var lengthSymbol = createSymbol(4, "length");
37950             lengthSymbol.type = hasRestElement ? numberType : getUnionType(literalTypes);
37951             properties.push(lengthSymbol);
37952             var type = createObjectType(8 | 4);
37953             type.typeParameters = typeParameters;
37954             type.outerTypeParameters = undefined;
37955             type.localTypeParameters = typeParameters;
37956             type.instantiations = ts.createMap();
37957             type.instantiations.set(getTypeListId(type.typeParameters), type);
37958             type.target = type;
37959             type.resolvedTypeArguments = type.typeParameters;
37960             type.thisType = createTypeParameter();
37961             type.thisType.isThisType = true;
37962             type.thisType.constraint = type;
37963             type.declaredProperties = properties;
37964             type.declaredCallSignatures = ts.emptyArray;
37965             type.declaredConstructSignatures = ts.emptyArray;
37966             type.declaredStringIndexInfo = undefined;
37967             type.declaredNumberIndexInfo = undefined;
37968             type.minLength = minLength;
37969             type.hasRestElement = hasRestElement;
37970             type.readonly = readonly;
37971             type.associatedNames = associatedNames;
37972             return type;
37973         }
37974         function getTupleTypeOfArity(arity, minLength, hasRestElement, readonly, associatedNames) {
37975             var key = arity + (hasRestElement ? "+" : ",") + minLength + (readonly ? "R" : "") + (associatedNames && associatedNames.length ? "," + associatedNames.join(",") : "");
37976             var type = tupleTypes.get(key);
37977             if (!type) {
37978                 tupleTypes.set(key, type = createTupleTypeOfArity(arity, minLength, hasRestElement, readonly, associatedNames));
37979             }
37980             return type;
37981         }
37982         function createTupleType(elementTypes, minLength, hasRestElement, readonly, associatedNames) {
37983             if (minLength === void 0) { minLength = elementTypes.length; }
37984             if (hasRestElement === void 0) { hasRestElement = false; }
37985             if (readonly === void 0) { readonly = false; }
37986             var arity = elementTypes.length;
37987             if (arity === 1 && hasRestElement) {
37988                 return createArrayType(elementTypes[0], readonly);
37989             }
37990             var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, readonly, associatedNames);
37991             return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType;
37992         }
37993         function sliceTupleType(type, index) {
37994             var tuple = type.target;
37995             if (tuple.hasRestElement) {
37996                 index = Math.min(index, getTypeReferenceArity(type) - 1);
37997             }
37998             return createTupleType(getTypeArguments(type).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index));
37999         }
38000         function getTypeFromOptionalTypeNode(node) {
38001             var type = getTypeFromTypeNode(node.type);
38002             return strictNullChecks ? getOptionalType(type) : type;
38003         }
38004         function getTypeId(type) {
38005             return type.id;
38006         }
38007         function containsType(types, type) {
38008             return ts.binarySearch(types, type, getTypeId, ts.compareValues) >= 0;
38009         }
38010         function insertType(types, type) {
38011             var index = ts.binarySearch(types, type, getTypeId, ts.compareValues);
38012             if (index < 0) {
38013                 types.splice(~index, 0, type);
38014                 return true;
38015             }
38016             return false;
38017         }
38018         function addTypeToUnion(typeSet, includes, type) {
38019             var flags = type.flags;
38020             if (flags & 1048576) {
38021                 return addTypesToUnion(typeSet, includes, type.types);
38022             }
38023             if (!(flags & 131072)) {
38024                 includes |= flags & 71041023;
38025                 if (flags & 66846720)
38026                     includes |= 262144;
38027                 if (type === wildcardType)
38028                     includes |= 8388608;
38029                 if (!strictNullChecks && flags & 98304) {
38030                     if (!(ts.getObjectFlags(type) & 524288))
38031                         includes |= 4194304;
38032                 }
38033                 else {
38034                     var len = typeSet.length;
38035                     var index = len && type.id > typeSet[len - 1].id ? ~len : ts.binarySearch(typeSet, type, getTypeId, ts.compareValues);
38036                     if (index < 0) {
38037                         typeSet.splice(~index, 0, type);
38038                     }
38039                 }
38040             }
38041             return includes;
38042         }
38043         function addTypesToUnion(typeSet, includes, types) {
38044             for (var _i = 0, types_9 = types; _i < types_9.length; _i++) {
38045                 var type = types_9[_i];
38046                 includes = addTypeToUnion(typeSet, includes, type);
38047             }
38048             return includes;
38049         }
38050         function isSetOfLiteralsFromSameEnum(types) {
38051             var first = types[0];
38052             if (first.flags & 1024) {
38053                 var firstEnum = getParentOfSymbol(first.symbol);
38054                 for (var i = 1; i < types.length; i++) {
38055                     var other = types[i];
38056                     if (!(other.flags & 1024) || (firstEnum !== getParentOfSymbol(other.symbol))) {
38057                         return false;
38058                     }
38059                 }
38060                 return true;
38061             }
38062             return false;
38063         }
38064         function removeSubtypes(types, primitivesOnly) {
38065             var len = types.length;
38066             if (len === 0 || isSetOfLiteralsFromSameEnum(types)) {
38067                 return true;
38068             }
38069             var i = len;
38070             var count = 0;
38071             while (i > 0) {
38072                 i--;
38073                 var source = types[i];
38074                 for (var _i = 0, types_10 = types; _i < types_10.length; _i++) {
38075                     var target = types_10[_i];
38076                     if (source !== target) {
38077                         if (count === 100000) {
38078                             var estimatedCount = (count / (len - i)) * len;
38079                             if (estimatedCount > (primitivesOnly ? 25000000 : 1000000)) {
38080                                 error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
38081                                 return false;
38082                             }
38083                         }
38084                         count++;
38085                         if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1) ||
38086                             !(ts.getObjectFlags(getTargetType(target)) & 1) ||
38087                             isTypeDerivedFrom(source, target))) {
38088                             ts.orderedRemoveItemAt(types, i);
38089                             break;
38090                         }
38091                     }
38092                 }
38093             }
38094             return true;
38095         }
38096         function removeRedundantLiteralTypes(types, includes) {
38097             var i = types.length;
38098             while (i > 0) {
38099                 i--;
38100                 var t = types[i];
38101                 var remove = t.flags & 128 && includes & 4 ||
38102                     t.flags & 256 && includes & 8 ||
38103                     t.flags & 2048 && includes & 64 ||
38104                     t.flags & 8192 && includes & 4096 ||
38105                     isFreshLiteralType(t) && containsType(types, t.regularType);
38106                 if (remove) {
38107                     ts.orderedRemoveItemAt(types, i);
38108                 }
38109             }
38110         }
38111         function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments) {
38112             if (unionReduction === void 0) { unionReduction = 1; }
38113             if (types.length === 0) {
38114                 return neverType;
38115             }
38116             if (types.length === 1) {
38117                 return types[0];
38118             }
38119             var typeSet = [];
38120             var includes = addTypesToUnion(typeSet, 0, types);
38121             if (unionReduction !== 0) {
38122                 if (includes & 3) {
38123                     return includes & 1 ? includes & 8388608 ? wildcardType : anyType : unknownType;
38124                 }
38125                 switch (unionReduction) {
38126                     case 1:
38127                         if (includes & (2944 | 8192)) {
38128                             removeRedundantLiteralTypes(typeSet, includes);
38129                         }
38130                         break;
38131                     case 2:
38132                         if (!removeSubtypes(typeSet, !(includes & 262144))) {
38133                             return errorType;
38134                         }
38135                         break;
38136                 }
38137                 if (typeSet.length === 0) {
38138                     return includes & 65536 ? includes & 4194304 ? nullType : nullWideningType :
38139                         includes & 32768 ? includes & 4194304 ? undefinedType : undefinedWideningType :
38140                             neverType;
38141                 }
38142             }
38143             var objectFlags = (includes & 66994211 ? 0 : 262144) |
38144                 (includes & 2097152 ? 268435456 : 0);
38145             return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments);
38146         }
38147         function getUnionTypePredicate(signatures) {
38148             var first;
38149             var types = [];
38150             for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) {
38151                 var sig = signatures_6[_i];
38152                 var pred = getTypePredicateOfSignature(sig);
38153                 if (!pred || pred.kind === 2 || pred.kind === 3) {
38154                     continue;
38155                 }
38156                 if (first) {
38157                     if (!typePredicateKindsMatch(first, pred)) {
38158                         return undefined;
38159                     }
38160                 }
38161                 else {
38162                     first = pred;
38163                 }
38164                 types.push(pred.type);
38165             }
38166             if (!first) {
38167                 return undefined;
38168             }
38169             var unionType = getUnionType(types);
38170             return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType);
38171         }
38172         function typePredicateKindsMatch(a, b) {
38173             return a.kind === b.kind && a.parameterIndex === b.parameterIndex;
38174         }
38175         function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments) {
38176             if (types.length === 0) {
38177                 return neverType;
38178             }
38179             if (types.length === 1) {
38180                 return types[0];
38181             }
38182             var id = getTypeListId(types);
38183             var type = unionTypes.get(id);
38184             if (!type) {
38185                 type = createType(1048576);
38186                 unionTypes.set(id, type);
38187                 type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, 98304);
38188                 type.types = types;
38189                 type.aliasSymbol = aliasSymbol;
38190                 type.aliasTypeArguments = aliasTypeArguments;
38191             }
38192             return type;
38193         }
38194         function getTypeFromUnionTypeNode(node) {
38195             var links = getNodeLinks(node);
38196             if (!links.resolvedType) {
38197                 var aliasSymbol = getAliasSymbolForTypeNode(node);
38198                 links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
38199             }
38200             return links.resolvedType;
38201         }
38202         function addTypeToIntersection(typeSet, includes, type) {
38203             var flags = type.flags;
38204             if (flags & 2097152) {
38205                 return addTypesToIntersection(typeSet, includes, type.types);
38206             }
38207             if (isEmptyAnonymousObjectType(type)) {
38208                 if (!(includes & 16777216)) {
38209                     includes |= 16777216;
38210                     typeSet.set(type.id.toString(), type);
38211                 }
38212             }
38213             else {
38214                 if (flags & 3) {
38215                     if (type === wildcardType)
38216                         includes |= 8388608;
38217                 }
38218                 else if ((strictNullChecks || !(flags & 98304)) && !typeSet.has(type.id.toString())) {
38219                     if (type.flags & 109440 && includes & 109440) {
38220                         includes |= 67108864;
38221                     }
38222                     typeSet.set(type.id.toString(), type);
38223                 }
38224                 includes |= flags & 71041023;
38225             }
38226             return includes;
38227         }
38228         function addTypesToIntersection(typeSet, includes, types) {
38229             for (var _i = 0, types_11 = types; _i < types_11.length; _i++) {
38230                 var type = types_11[_i];
38231                 includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type));
38232             }
38233             return includes;
38234         }
38235         function removeRedundantPrimitiveTypes(types, includes) {
38236             var i = types.length;
38237             while (i > 0) {
38238                 i--;
38239                 var t = types[i];
38240                 var remove = t.flags & 4 && includes & 128 ||
38241                     t.flags & 8 && includes & 256 ||
38242                     t.flags & 64 && includes & 2048 ||
38243                     t.flags & 4096 && includes & 8192;
38244                 if (remove) {
38245                     ts.orderedRemoveItemAt(types, i);
38246                 }
38247             }
38248         }
38249         function eachUnionContains(unionTypes, type) {
38250             for (var _i = 0, unionTypes_1 = unionTypes; _i < unionTypes_1.length; _i++) {
38251                 var u = unionTypes_1[_i];
38252                 if (!containsType(u.types, type)) {
38253                     var primitive = type.flags & 128 ? stringType :
38254                         type.flags & 256 ? numberType :
38255                             type.flags & 2048 ? bigintType :
38256                                 type.flags & 8192 ? esSymbolType :
38257                                     undefined;
38258                     if (!primitive || !containsType(u.types, primitive)) {
38259                         return false;
38260                     }
38261                 }
38262             }
38263             return true;
38264         }
38265         function extractIrreducible(types, flag) {
38266             if (ts.every(types, function (t) { return !!(t.flags & 1048576) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); })) {
38267                 for (var i = 0; i < types.length; i++) {
38268                     types[i] = filterType(types[i], function (t) { return !(t.flags & flag); });
38269                 }
38270                 return true;
38271             }
38272             return false;
38273         }
38274         function intersectUnionsOfPrimitiveTypes(types) {
38275             var unionTypes;
38276             var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 262144); });
38277             if (index < 0) {
38278                 return false;
38279             }
38280             var i = index + 1;
38281             while (i < types.length) {
38282                 var t = types[i];
38283                 if (ts.getObjectFlags(t) & 262144) {
38284                     (unionTypes || (unionTypes = [types[index]])).push(t);
38285                     ts.orderedRemoveItemAt(types, i);
38286                 }
38287                 else {
38288                     i++;
38289                 }
38290             }
38291             if (!unionTypes) {
38292                 return false;
38293             }
38294             var checked = [];
38295             var result = [];
38296             for (var _i = 0, unionTypes_2 = unionTypes; _i < unionTypes_2.length; _i++) {
38297                 var u = unionTypes_2[_i];
38298                 for (var _a = 0, _b = u.types; _a < _b.length; _a++) {
38299                     var t = _b[_a];
38300                     if (insertType(checked, t)) {
38301                         if (eachUnionContains(unionTypes, t)) {
38302                             insertType(result, t);
38303                         }
38304                     }
38305                 }
38306             }
38307             types[index] = getUnionTypeFromSortedList(result, 262144);
38308             return true;
38309         }
38310         function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
38311             var result = createType(2097152);
38312             result.objectFlags = getPropagatingFlagsOfTypes(types, 98304);
38313             result.types = types;
38314             result.aliasSymbol = aliasSymbol;
38315             result.aliasTypeArguments = aliasTypeArguments;
38316             return result;
38317         }
38318         function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
38319             var typeMembershipMap = ts.createMap();
38320             var includes = addTypesToIntersection(typeMembershipMap, 0, types);
38321             var typeSet = ts.arrayFrom(typeMembershipMap.values());
38322             if (includes & 131072 ||
38323                 strictNullChecks && includes & 98304 && includes & (524288 | 67108864 | 16777216) ||
38324                 includes & 67108864 && includes & (67238908 & ~67108864) ||
38325                 includes & 132 && includes & (67238908 & ~132) ||
38326                 includes & 296 && includes & (67238908 & ~296) ||
38327                 includes & 2112 && includes & (67238908 & ~2112) ||
38328                 includes & 12288 && includes & (67238908 & ~12288) ||
38329                 includes & 49152 && includes & (67238908 & ~49152)) {
38330                 return neverType;
38331             }
38332             if (includes & 1) {
38333                 return includes & 8388608 ? wildcardType : anyType;
38334             }
38335             if (!strictNullChecks && includes & 98304) {
38336                 return includes & 32768 ? undefinedType : nullType;
38337             }
38338             if (includes & 4 && includes & 128 ||
38339                 includes & 8 && includes & 256 ||
38340                 includes & 64 && includes & 2048 ||
38341                 includes & 4096 && includes & 8192) {
38342                 removeRedundantPrimitiveTypes(typeSet, includes);
38343             }
38344             if (includes & 16777216 && includes & 524288) {
38345                 ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType));
38346             }
38347             if (typeSet.length === 0) {
38348                 return unknownType;
38349             }
38350             if (typeSet.length === 1) {
38351                 return typeSet[0];
38352             }
38353             var id = getTypeListId(typeSet);
38354             var result = intersectionTypes.get(id);
38355             if (!result) {
38356                 if (includes & 1048576) {
38357                     if (intersectUnionsOfPrimitiveTypes(typeSet)) {
38358                         result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
38359                     }
38360                     else if (extractIrreducible(typeSet, 32768)) {
38361                         result = getUnionType([getIntersectionType(typeSet), undefinedType], 1, aliasSymbol, aliasTypeArguments);
38362                     }
38363                     else if (extractIrreducible(typeSet, 65536)) {
38364                         result = getUnionType([getIntersectionType(typeSet), nullType], 1, aliasSymbol, aliasTypeArguments);
38365                     }
38366                     else {
38367                         var size = ts.reduceLeft(typeSet, function (n, t) { return n * (t.flags & 1048576 ? t.types.length : 1); }, 1);
38368                         if (size >= 100000) {
38369                             error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
38370                             return errorType;
38371                         }
38372                         var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576) !== 0; });
38373                         var unionType = typeSet[unionIndex_1];
38374                         result = getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1, aliasSymbol, aliasTypeArguments);
38375                     }
38376                 }
38377                 else {
38378                     result = createIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
38379                 }
38380                 intersectionTypes.set(id, result);
38381             }
38382             return result;
38383         }
38384         function getTypeFromIntersectionTypeNode(node) {
38385             var links = getNodeLinks(node);
38386             if (!links.resolvedType) {
38387                 var aliasSymbol = getAliasSymbolForTypeNode(node);
38388                 links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
38389             }
38390             return links.resolvedType;
38391         }
38392         function createIndexType(type, stringsOnly) {
38393             var result = createType(4194304);
38394             result.type = type;
38395             result.stringsOnly = stringsOnly;
38396             return result;
38397         }
38398         function getIndexTypeForGenericType(type, stringsOnly) {
38399             return stringsOnly ?
38400                 type.resolvedStringIndexType || (type.resolvedStringIndexType = createIndexType(type, true)) :
38401                 type.resolvedIndexType || (type.resolvedIndexType = createIndexType(type, false));
38402         }
38403         function getLiteralTypeFromPropertyName(name) {
38404             if (ts.isPrivateIdentifier(name)) {
38405                 return neverType;
38406             }
38407             return ts.isIdentifier(name) ? getLiteralType(ts.unescapeLeadingUnderscores(name.escapedText)) :
38408                 getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name));
38409         }
38410         function getBigIntLiteralType(node) {
38411             return getLiteralType({
38412                 negative: false,
38413                 base10Value: ts.parsePseudoBigInt(node.text)
38414             });
38415         }
38416         function getLiteralTypeFromProperty(prop, include) {
38417             if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24)) {
38418                 var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType;
38419                 if (!type && !ts.isKnownSymbol(prop)) {
38420                     if (prop.escapedName === "default") {
38421                         type = getLiteralType("default");
38422                     }
38423                     else {
38424                         var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration);
38425                         type = name && getLiteralTypeFromPropertyName(name) || getLiteralType(ts.symbolName(prop));
38426                     }
38427                 }
38428                 if (type && type.flags & include) {
38429                     return type;
38430                 }
38431             }
38432             return neverType;
38433         }
38434         function getLiteralTypeFromProperties(type, include) {
38435             return getUnionType(ts.map(getPropertiesOfType(type), function (p) { return getLiteralTypeFromProperty(p, include); }));
38436         }
38437         function getNonEnumNumberIndexInfo(type) {
38438             var numberIndexInfo = getIndexInfoOfType(type, 1);
38439             return numberIndexInfo !== enumNumberIndexInfo ? numberIndexInfo : undefined;
38440         }
38441         function getIndexType(type, stringsOnly, noIndexSignatures) {
38442             if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; }
38443             type = getReducedType(type);
38444             return type.flags & 1048576 ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
38445                 type.flags & 2097152 ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
38446                     maybeTypeOfKind(type, 58982400) ? getIndexTypeForGenericType(type, stringsOnly) :
38447                         ts.getObjectFlags(type) & 32 ? filterType(getConstraintTypeFromMappedType(type), function (t) { return !(noIndexSignatures && t.flags & (1 | 4)); }) :
38448                             type === wildcardType ? wildcardType :
38449                                 type.flags & 2 ? neverType :
38450                                     type.flags & (1 | 131072) ? keyofConstraintType :
38451                                         stringsOnly ? !noIndexSignatures && getIndexInfoOfType(type, 0) ? stringType : getLiteralTypeFromProperties(type, 128) :
38452                                             !noIndexSignatures && getIndexInfoOfType(type, 0) ? getUnionType([stringType, numberType, getLiteralTypeFromProperties(type, 8192)]) :
38453                                                 getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromProperties(type, 128 | 8192)]) :
38454                                                     getLiteralTypeFromProperties(type, 8576);
38455         }
38456         function getExtractStringType(type) {
38457             if (keyofStringsOnly) {
38458                 return type;
38459             }
38460             var extractTypeAlias = getGlobalExtractSymbol();
38461             return extractTypeAlias ? getTypeAliasInstantiation(extractTypeAlias, [type, stringType]) : stringType;
38462         }
38463         function getIndexTypeOrString(type) {
38464             var indexType = getExtractStringType(getIndexType(type));
38465             return indexType.flags & 131072 ? stringType : indexType;
38466         }
38467         function getTypeFromTypeOperatorNode(node) {
38468             var links = getNodeLinks(node);
38469             if (!links.resolvedType) {
38470                 switch (node.operator) {
38471                     case 134:
38472                         links.resolvedType = getIndexType(getTypeFromTypeNode(node.type));
38473                         break;
38474                     case 147:
38475                         links.resolvedType = node.type.kind === 144
38476                             ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent))
38477                             : errorType;
38478                         break;
38479                     case 138:
38480                         links.resolvedType = getTypeFromTypeNode(node.type);
38481                         break;
38482                     default:
38483                         throw ts.Debug.assertNever(node.operator);
38484                 }
38485             }
38486             return links.resolvedType;
38487         }
38488         function createIndexedAccessType(objectType, indexType) {
38489             var type = createType(8388608);
38490             type.objectType = objectType;
38491             type.indexType = indexType;
38492             return type;
38493         }
38494         function isJSLiteralType(type) {
38495             if (noImplicitAny) {
38496                 return false;
38497             }
38498             if (ts.getObjectFlags(type) & 16384) {
38499                 return true;
38500             }
38501             if (type.flags & 1048576) {
38502                 return ts.every(type.types, isJSLiteralType);
38503             }
38504             if (type.flags & 2097152) {
38505                 return ts.some(type.types, isJSLiteralType);
38506             }
38507             if (type.flags & 63176704) {
38508                 return isJSLiteralType(getResolvedBaseConstraint(type));
38509             }
38510             return false;
38511         }
38512         function getPropertyNameFromIndex(indexType, accessNode) {
38513             var accessExpression = accessNode && accessNode.kind === 195 ? accessNode : undefined;
38514             return isTypeUsableAsPropertyName(indexType) ?
38515                 getPropertyNameFromType(indexType) :
38516                 accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ?
38517                     ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) :
38518                     accessNode && ts.isPropertyName(accessNode) ?
38519                         ts.getPropertyNameForPropertyNameNode(accessNode) :
38520                         undefined;
38521         }
38522         function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) {
38523             var accessExpression = accessNode && accessNode.kind === 195 ? accessNode : undefined;
38524             var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode);
38525             if (propName !== undefined) {
38526                 var prop = getPropertyOfType(objectType, propName);
38527                 if (prop) {
38528                     if (accessExpression) {
38529                         markPropertyAsReferenced(prop, accessExpression, accessExpression.expression.kind === 104);
38530                         if (isAssignmentToReadonlyEntity(accessExpression, prop, ts.getAssignmentTargetKind(accessExpression))) {
38531                             error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop));
38532                             return undefined;
38533                         }
38534                         if (accessFlags & 4) {
38535                             getNodeLinks(accessNode).resolvedSymbol = prop;
38536                         }
38537                     }
38538                     var propType = getTypeOfSymbol(prop);
38539                     return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 ?
38540                         getFlowTypeOfReference(accessExpression, propType) :
38541                         propType;
38542                 }
38543                 if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) {
38544                     if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 8)) {
38545                         var indexNode = getIndexNodeForAccessExpression(accessNode);
38546                         if (isTupleType(objectType)) {
38547                             error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName));
38548                         }
38549                         else {
38550                             error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
38551                         }
38552                     }
38553                     errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, 1));
38554                     return mapType(objectType, function (t) { return getRestTypeOfTupleType(t) || undefinedType; });
38555                 }
38556             }
38557             if (!(indexType.flags & 98304) && isTypeAssignableToKind(indexType, 132 | 296 | 12288)) {
38558                 if (objectType.flags & (1 | 131072)) {
38559                     return objectType;
38560                 }
38561                 var stringIndexInfo = getIndexInfoOfType(objectType, 0);
38562                 var indexInfo = isTypeAssignableToKind(indexType, 296) && getIndexInfoOfType(objectType, 1) || stringIndexInfo;
38563                 if (indexInfo) {
38564                     if (accessFlags & 1 && indexInfo === stringIndexInfo) {
38565                         if (accessExpression) {
38566                             error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType));
38567                         }
38568                         return undefined;
38569                     }
38570                     if (accessNode && !isTypeAssignableToKind(indexType, 4 | 8)) {
38571                         var indexNode = getIndexNodeForAccessExpression(accessNode);
38572                         error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
38573                         return indexInfo.type;
38574                     }
38575                     errorIfWritingToReadonlyIndex(indexInfo);
38576                     return indexInfo.type;
38577                 }
38578                 if (indexType.flags & 131072) {
38579                     return neverType;
38580                 }
38581                 if (isJSLiteralType(objectType)) {
38582                     return anyType;
38583                 }
38584                 if (accessExpression && !isConstEnumObjectType(objectType)) {
38585                     if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418)) {
38586                         error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
38587                     }
38588                     else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !suppressNoImplicitAnyError) {
38589                         if (propName !== undefined && typeHasStaticProperty(propName, objectType)) {
38590                             error(accessExpression, ts.Diagnostics.Property_0_is_a_static_member_of_type_1, propName, typeToString(objectType));
38591                         }
38592                         else if (getIndexTypeOfType(objectType, 1)) {
38593                             error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number);
38594                         }
38595                         else {
38596                             var suggestion = void 0;
38597                             if (propName !== undefined && (suggestion = getSuggestionForNonexistentProperty(propName, objectType))) {
38598                                 if (suggestion !== undefined) {
38599                                     error(accessExpression.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, propName, typeToString(objectType), suggestion);
38600                                 }
38601                             }
38602                             else {
38603                                 var suggestion_1 = getSuggestionForNonexistentIndexSignature(objectType, accessExpression, indexType);
38604                                 if (suggestion_1 !== undefined) {
38605                                     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);
38606                                 }
38607                                 else {
38608                                     var errorInfo = void 0;
38609                                     if (indexType.flags & 1024) {
38610                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType));
38611                                     }
38612                                     else if (indexType.flags & 8192) {
38613                                         var symbolName_2 = getFullyQualifiedName(indexType.symbol, accessExpression);
38614                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName_2 + "]", typeToString(objectType));
38615                                     }
38616                                     else if (indexType.flags & 128) {
38617                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
38618                                     }
38619                                     else if (indexType.flags & 256) {
38620                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
38621                                     }
38622                                     else if (indexType.flags & (8 | 4)) {
38623                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType));
38624                                     }
38625                                     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));
38626                                     diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(accessExpression, errorInfo));
38627                                 }
38628                             }
38629                         }
38630                     }
38631                     return undefined;
38632                 }
38633             }
38634             if (isJSLiteralType(objectType)) {
38635                 return anyType;
38636             }
38637             if (accessNode) {
38638                 var indexNode = getIndexNodeForAccessExpression(accessNode);
38639                 if (indexType.flags & (128 | 256)) {
38640                     error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType));
38641                 }
38642                 else if (indexType.flags & (4 | 8)) {
38643                     error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType));
38644                 }
38645                 else {
38646                     error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
38647                 }
38648             }
38649             if (isTypeAny(indexType)) {
38650                 return indexType;
38651             }
38652             return undefined;
38653             function errorIfWritingToReadonlyIndex(indexInfo) {
38654                 if (indexInfo && indexInfo.isReadonly && accessExpression && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) {
38655                     error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
38656                 }
38657             }
38658         }
38659         function getIndexNodeForAccessExpression(accessNode) {
38660             return accessNode.kind === 195 ? accessNode.argumentExpression :
38661                 accessNode.kind === 185 ? accessNode.indexType :
38662                     accessNode.kind === 154 ? accessNode.expression :
38663                         accessNode;
38664         }
38665         function isGenericObjectType(type) {
38666             if (type.flags & 3145728) {
38667                 if (!(type.objectFlags & 4194304)) {
38668                     type.objectFlags |= 4194304 |
38669                         (ts.some(type.types, isGenericObjectType) ? 8388608 : 0);
38670                 }
38671                 return !!(type.objectFlags & 8388608);
38672             }
38673             return !!(type.flags & 58982400) || isGenericMappedType(type);
38674         }
38675         function isGenericIndexType(type) {
38676             if (type.flags & 3145728) {
38677                 if (!(type.objectFlags & 16777216)) {
38678                     type.objectFlags |= 16777216 |
38679                         (ts.some(type.types, isGenericIndexType) ? 33554432 : 0);
38680                 }
38681                 return !!(type.objectFlags & 33554432);
38682             }
38683             return !!(type.flags & (58982400 | 4194304));
38684         }
38685         function isThisTypeParameter(type) {
38686             return !!(type.flags & 262144 && type.isThisType);
38687         }
38688         function getSimplifiedType(type, writing) {
38689             return type.flags & 8388608 ? getSimplifiedIndexedAccessType(type, writing) :
38690                 type.flags & 16777216 ? getSimplifiedConditionalType(type, writing) :
38691                     type;
38692         }
38693         function distributeIndexOverObjectType(objectType, indexType, writing) {
38694             if (objectType.flags & 3145728) {
38695                 var types = ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType), writing); });
38696                 return objectType.flags & 2097152 || writing ? getIntersectionType(types) : getUnionType(types);
38697             }
38698         }
38699         function distributeObjectOverIndexType(objectType, indexType, writing) {
38700             if (indexType.flags & 1048576) {
38701                 var types = ts.map(indexType.types, function (t) { return getSimplifiedType(getIndexedAccessType(objectType, t), writing); });
38702                 return writing ? getIntersectionType(types) : getUnionType(types);
38703             }
38704         }
38705         function unwrapSubstitution(type) {
38706             if (type.flags & 33554432) {
38707                 return type.substitute;
38708             }
38709             return type;
38710         }
38711         function getSimplifiedIndexedAccessType(type, writing) {
38712             var cache = writing ? "simplifiedForWriting" : "simplifiedForReading";
38713             if (type[cache]) {
38714                 return type[cache] === circularConstraintType ? type : type[cache];
38715             }
38716             type[cache] = circularConstraintType;
38717             var objectType = unwrapSubstitution(getSimplifiedType(type.objectType, writing));
38718             var indexType = getSimplifiedType(type.indexType, writing);
38719             var distributedOverIndex = distributeObjectOverIndexType(objectType, indexType, writing);
38720             if (distributedOverIndex) {
38721                 return type[cache] = distributedOverIndex;
38722             }
38723             if (!(indexType.flags & 63176704)) {
38724                 var distributedOverObject = distributeIndexOverObjectType(objectType, indexType, writing);
38725                 if (distributedOverObject) {
38726                     return type[cache] = distributedOverObject;
38727                 }
38728             }
38729             if (isGenericMappedType(objectType)) {
38730                 return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); });
38731             }
38732             return type[cache] = type;
38733         }
38734         function getSimplifiedConditionalType(type, writing) {
38735             var checkType = type.checkType;
38736             var extendsType = type.extendsType;
38737             var trueType = getTrueTypeFromConditionalType(type);
38738             var falseType = getFalseTypeFromConditionalType(type);
38739             if (falseType.flags & 131072 && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) {
38740                 if (checkType.flags & 1 || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) {
38741                     return getSimplifiedType(trueType, writing);
38742                 }
38743                 else if (isIntersectionEmpty(checkType, extendsType)) {
38744                     return neverType;
38745                 }
38746             }
38747             else if (trueType.flags & 131072 && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) {
38748                 if (!(checkType.flags & 1) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) {
38749                     return neverType;
38750                 }
38751                 else if (checkType.flags & 1 || isIntersectionEmpty(checkType, extendsType)) {
38752                     return getSimplifiedType(falseType, writing);
38753                 }
38754             }
38755             return type;
38756         }
38757         function isIntersectionEmpty(type1, type2) {
38758             return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072);
38759         }
38760         function substituteIndexedMappedType(objectType, index) {
38761             var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]);
38762             var templateMapper = combineTypeMappers(objectType.mapper, mapper);
38763             return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper);
38764         }
38765         function getIndexedAccessType(objectType, indexType, accessNode) {
38766             return getIndexedAccessTypeOrUndefined(objectType, indexType, accessNode, 0) || (accessNode ? errorType : unknownType);
38767         }
38768         function getIndexedAccessTypeOrUndefined(objectType, indexType, accessNode, accessFlags) {
38769             if (accessFlags === void 0) { accessFlags = 0; }
38770             if (objectType === wildcardType || indexType === wildcardType) {
38771                 return wildcardType;
38772             }
38773             if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304) && isTypeAssignableToKind(indexType, 4 | 8)) {
38774                 indexType = stringType;
38775             }
38776             if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 185) && isGenericObjectType(objectType)) {
38777                 if (objectType.flags & 3) {
38778                     return objectType;
38779                 }
38780                 var id = objectType.id + "," + indexType.id;
38781                 var type = indexedAccessTypes.get(id);
38782                 if (!type) {
38783                     indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType));
38784                 }
38785                 return type;
38786             }
38787             var apparentObjectType = getReducedApparentType(objectType);
38788             if (indexType.flags & 1048576 && !(indexType.flags & 16)) {
38789                 var propTypes = [];
38790                 var wasMissingProp = false;
38791                 for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) {
38792                     var t = _a[_i];
38793                     var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, wasMissingProp, accessNode, accessFlags);
38794                     if (propType) {
38795                         propTypes.push(propType);
38796                     }
38797                     else if (!accessNode) {
38798                         return undefined;
38799                     }
38800                     else {
38801                         wasMissingProp = true;
38802                     }
38803                 }
38804                 if (wasMissingProp) {
38805                     return undefined;
38806                 }
38807                 return accessFlags & 2 ? getIntersectionType(propTypes) : getUnionType(propTypes);
38808             }
38809             return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, false, accessNode, accessFlags | 4);
38810         }
38811         function getTypeFromIndexedAccessTypeNode(node) {
38812             var links = getNodeLinks(node);
38813             if (!links.resolvedType) {
38814                 var objectType = getTypeFromTypeNode(node.objectType);
38815                 var indexType = getTypeFromTypeNode(node.indexType);
38816                 var resolved = getIndexedAccessType(objectType, indexType, node);
38817                 links.resolvedType = resolved.flags & 8388608 &&
38818                     resolved.objectType === objectType &&
38819                     resolved.indexType === indexType ?
38820                     getConditionalFlowTypeOfType(resolved, node) : resolved;
38821             }
38822             return links.resolvedType;
38823         }
38824         function getTypeFromMappedTypeNode(node) {
38825             var links = getNodeLinks(node);
38826             if (!links.resolvedType) {
38827                 var type = createObjectType(32, node.symbol);
38828                 type.declaration = node;
38829                 type.aliasSymbol = getAliasSymbolForTypeNode(node);
38830                 type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(type.aliasSymbol);
38831                 links.resolvedType = type;
38832                 getConstraintTypeFromMappedType(type);
38833             }
38834             return links.resolvedType;
38835         }
38836         function getActualTypeVariable(type) {
38837             if (type.flags & 33554432) {
38838                 return type.baseType;
38839             }
38840             if (type.flags & 8388608 && (type.objectType.flags & 33554432 ||
38841                 type.indexType.flags & 33554432)) {
38842                 return getIndexedAccessType(getActualTypeVariable(type.objectType), getActualTypeVariable(type.indexType));
38843             }
38844             return type;
38845         }
38846         function getConditionalType(root, mapper) {
38847             var result;
38848             var extraTypes;
38849             var _loop_12 = function () {
38850                 var checkType = instantiateType(root.checkType, mapper);
38851                 var checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType);
38852                 var extendsType = instantiateType(root.extendsType, mapper);
38853                 if (checkType === wildcardType || extendsType === wildcardType) {
38854                     return { value: wildcardType };
38855                 }
38856                 var combinedMapper = void 0;
38857                 if (root.inferTypeParameters) {
38858                     var context = createInferenceContext(root.inferTypeParameters, undefined, 0);
38859                     if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) {
38860                         inferTypes(context.inferences, checkType, extendsType, 128 | 256);
38861                     }
38862                     combinedMapper = mergeTypeMappers(mapper, context.mapper);
38863                 }
38864                 var inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
38865                 if (!checkTypeInstantiable && !isGenericObjectType(inferredExtendsType) && !isGenericIndexType(inferredExtendsType)) {
38866                     if (!(inferredExtendsType.flags & 3) && (checkType.flags & 1 || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
38867                         if (checkType.flags & 1) {
38868                             (extraTypes || (extraTypes = [])).push(instantiateTypeWithoutDepthIncrease(root.trueType, combinedMapper || mapper));
38869                         }
38870                         var falseType_1 = root.falseType;
38871                         if (falseType_1.flags & 16777216) {
38872                             var newRoot = falseType_1.root;
38873                             if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
38874                                 root = newRoot;
38875                                 return "continue";
38876                             }
38877                         }
38878                         result = instantiateTypeWithoutDepthIncrease(falseType_1, mapper);
38879                         return "break";
38880                     }
38881                     if (inferredExtendsType.flags & 3 || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) {
38882                         result = instantiateTypeWithoutDepthIncrease(root.trueType, combinedMapper || mapper);
38883                         return "break";
38884                     }
38885                 }
38886                 var erasedCheckType = getActualTypeVariable(checkType);
38887                 result = createType(16777216);
38888                 result.root = root;
38889                 result.checkType = erasedCheckType;
38890                 result.extendsType = extendsType;
38891                 result.mapper = mapper;
38892                 result.combinedMapper = combinedMapper;
38893                 result.aliasSymbol = root.aliasSymbol;
38894                 result.aliasTypeArguments = instantiateTypes(root.aliasTypeArguments, mapper);
38895                 return "break";
38896             };
38897             while (true) {
38898                 var state_4 = _loop_12();
38899                 if (typeof state_4 === "object")
38900                     return state_4.value;
38901                 if (state_4 === "break")
38902                     break;
38903             }
38904             return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
38905         }
38906         function getTrueTypeFromConditionalType(type) {
38907             return type.resolvedTrueType || (type.resolvedTrueType = instantiateType(type.root.trueType, type.mapper));
38908         }
38909         function getFalseTypeFromConditionalType(type) {
38910             return type.resolvedFalseType || (type.resolvedFalseType = instantiateType(type.root.falseType, type.mapper));
38911         }
38912         function getInferredTrueTypeFromConditionalType(type) {
38913             return type.resolvedInferredTrueType || (type.resolvedInferredTrueType = type.combinedMapper ? instantiateType(type.root.trueType, type.combinedMapper) : getTrueTypeFromConditionalType(type));
38914         }
38915         function getInferTypeParameters(node) {
38916             var result;
38917             if (node.locals) {
38918                 node.locals.forEach(function (symbol) {
38919                     if (symbol.flags & 262144) {
38920                         result = ts.append(result, getDeclaredTypeOfSymbol(symbol));
38921                     }
38922                 });
38923             }
38924             return result;
38925         }
38926         function getTypeFromConditionalTypeNode(node) {
38927             var links = getNodeLinks(node);
38928             if (!links.resolvedType) {
38929                 var checkType = getTypeFromTypeNode(node.checkType);
38930                 var aliasSymbol = getAliasSymbolForTypeNode(node);
38931                 var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
38932                 var allOuterTypeParameters = getOuterTypeParameters(node, true);
38933                 var outerTypeParameters = aliasTypeArguments ? allOuterTypeParameters : ts.filter(allOuterTypeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, node); });
38934                 var root = {
38935                     node: node,
38936                     checkType: checkType,
38937                     extendsType: getTypeFromTypeNode(node.extendsType),
38938                     trueType: getTypeFromTypeNode(node.trueType),
38939                     falseType: getTypeFromTypeNode(node.falseType),
38940                     isDistributive: !!(checkType.flags & 262144),
38941                     inferTypeParameters: getInferTypeParameters(node),
38942                     outerTypeParameters: outerTypeParameters,
38943                     instantiations: undefined,
38944                     aliasSymbol: aliasSymbol,
38945                     aliasTypeArguments: aliasTypeArguments
38946                 };
38947                 links.resolvedType = getConditionalType(root, undefined);
38948                 if (outerTypeParameters) {
38949                     root.instantiations = ts.createMap();
38950                     root.instantiations.set(getTypeListId(outerTypeParameters), links.resolvedType);
38951                 }
38952             }
38953             return links.resolvedType;
38954         }
38955         function getTypeFromInferTypeNode(node) {
38956             var links = getNodeLinks(node);
38957             if (!links.resolvedType) {
38958                 links.resolvedType = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter));
38959             }
38960             return links.resolvedType;
38961         }
38962         function getIdentifierChain(node) {
38963             if (ts.isIdentifier(node)) {
38964                 return [node];
38965             }
38966             else {
38967                 return ts.append(getIdentifierChain(node.left), node.right);
38968             }
38969         }
38970         function getTypeFromImportTypeNode(node) {
38971             var links = getNodeLinks(node);
38972             if (!links.resolvedType) {
38973                 if (node.isTypeOf && node.typeArguments) {
38974                     error(node, ts.Diagnostics.Type_arguments_cannot_be_used_here);
38975                     links.resolvedSymbol = unknownSymbol;
38976                     return links.resolvedType = errorType;
38977                 }
38978                 if (!ts.isLiteralImportTypeNode(node)) {
38979                     error(node.argument, ts.Diagnostics.String_literal_expected);
38980                     links.resolvedSymbol = unknownSymbol;
38981                     return links.resolvedType = errorType;
38982                 }
38983                 var targetMeaning = node.isTypeOf ? 111551 : node.flags & 4194304 ? 111551 | 788968 : 788968;
38984                 var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal);
38985                 if (!innerModuleSymbol) {
38986                     links.resolvedSymbol = unknownSymbol;
38987                     return links.resolvedType = errorType;
38988                 }
38989                 var moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, false);
38990                 if (!ts.nodeIsMissing(node.qualifier)) {
38991                     var nameStack = getIdentifierChain(node.qualifier);
38992                     var currentNamespace = moduleSymbol;
38993                     var current = void 0;
38994                     while (current = nameStack.shift()) {
38995                         var meaning = nameStack.length ? 1920 : targetMeaning;
38996                         var next = getSymbol(getExportsOfSymbol(getMergedSymbol(resolveSymbol(currentNamespace))), current.escapedText, meaning);
38997                         if (!next) {
38998                             error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current));
38999                             return links.resolvedType = errorType;
39000                         }
39001                         getNodeLinks(current).resolvedSymbol = next;
39002                         getNodeLinks(current.parent).resolvedSymbol = next;
39003                         currentNamespace = next;
39004                     }
39005                     links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning);
39006                 }
39007                 else {
39008                     if (moduleSymbol.flags & targetMeaning) {
39009                         links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning);
39010                     }
39011                     else {
39012                         var errorMessage = targetMeaning === 111551
39013                             ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here
39014                             : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0;
39015                         error(node, errorMessage, node.argument.literal.text);
39016                         links.resolvedSymbol = unknownSymbol;
39017                         links.resolvedType = errorType;
39018                     }
39019                 }
39020             }
39021             return links.resolvedType;
39022         }
39023         function resolveImportSymbolType(node, links, symbol, meaning) {
39024             var resolvedSymbol = resolveSymbol(symbol);
39025             links.resolvedSymbol = resolvedSymbol;
39026             if (meaning === 111551) {
39027                 return getTypeOfSymbol(symbol);
39028             }
39029             else {
39030                 return getTypeReferenceType(node, resolvedSymbol);
39031             }
39032         }
39033         function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) {
39034             var links = getNodeLinks(node);
39035             if (!links.resolvedType) {
39036                 var aliasSymbol = getAliasSymbolForTypeNode(node);
39037                 if (getMembersOfSymbol(node.symbol).size === 0 && !aliasSymbol) {
39038                     links.resolvedType = emptyTypeLiteralType;
39039                 }
39040                 else {
39041                     var type = createObjectType(16, node.symbol);
39042                     type.aliasSymbol = aliasSymbol;
39043                     type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
39044                     if (ts.isJSDocTypeLiteral(node) && node.isArrayType) {
39045                         type = createArrayType(type);
39046                     }
39047                     links.resolvedType = type;
39048                 }
39049             }
39050             return links.resolvedType;
39051         }
39052         function getAliasSymbolForTypeNode(node) {
39053             var host = node.parent;
39054             while (ts.isParenthesizedTypeNode(host) || ts.isTypeOperatorNode(host) && host.operator === 138) {
39055                 host = host.parent;
39056             }
39057             return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined;
39058         }
39059         function getTypeArgumentsForAliasSymbol(symbol) {
39060             return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined;
39061         }
39062         function isNonGenericObjectType(type) {
39063             return !!(type.flags & 524288) && !isGenericMappedType(type);
39064         }
39065         function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) {
39066             return isEmptyObjectType(type) || !!(type.flags & (65536 | 32768 | 528 | 296 | 2112 | 132 | 1056 | 67108864 | 4194304));
39067         }
39068         function isSinglePropertyAnonymousObjectType(type) {
39069             return !!(type.flags & 524288) &&
39070                 !!(ts.getObjectFlags(type) & 16) &&
39071                 (ts.length(getPropertiesOfType(type)) === 1 || ts.every(getPropertiesOfType(type), function (p) { return !!(p.flags & 16777216); }));
39072         }
39073         function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) {
39074             if (type.types.length === 2) {
39075                 var firstType = type.types[0];
39076                 var secondType = type.types[1];
39077                 if (ts.every(type.types, isEmptyObjectTypeOrSpreadsIntoEmptyObject)) {
39078                     return isEmptyObjectType(firstType) ? firstType : isEmptyObjectType(secondType) ? secondType : emptyObjectType;
39079                 }
39080                 if (isEmptyObjectTypeOrSpreadsIntoEmptyObject(firstType) && isSinglePropertyAnonymousObjectType(secondType)) {
39081                     return getAnonymousPartialType(secondType);
39082                 }
39083                 if (isEmptyObjectTypeOrSpreadsIntoEmptyObject(secondType) && isSinglePropertyAnonymousObjectType(firstType)) {
39084                     return getAnonymousPartialType(firstType);
39085                 }
39086             }
39087             function getAnonymousPartialType(type) {
39088                 var members = ts.createSymbolTable();
39089                 for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
39090                     var prop = _a[_i];
39091                     if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16)) {
39092                     }
39093                     else if (isSpreadableProperty(prop)) {
39094                         var isSetonlyAccessor = prop.flags & 65536 && !(prop.flags & 32768);
39095                         var flags = 4 | 16777216;
39096                         var result = createSymbol(flags, prop.escapedName, readonly ? 8 : 0);
39097                         result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop);
39098                         result.declarations = prop.declarations;
39099                         result.nameType = getSymbolLinks(prop).nameType;
39100                         result.syntheticOrigin = prop;
39101                         members.set(prop.escapedName, result);
39102                     }
39103                 }
39104                 var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoOfType(type, 0), getIndexInfoOfType(type, 1));
39105                 spread.objectFlags |= 128 | 1048576;
39106                 return spread;
39107             }
39108         }
39109         function getSpreadType(left, right, symbol, objectFlags, readonly) {
39110             if (left.flags & 1 || right.flags & 1) {
39111                 return anyType;
39112             }
39113             if (left.flags & 2 || right.flags & 2) {
39114                 return unknownType;
39115             }
39116             if (left.flags & 131072) {
39117                 return right;
39118             }
39119             if (right.flags & 131072) {
39120                 return left;
39121             }
39122             if (left.flags & 1048576) {
39123                 var merged = tryMergeUnionOfObjectTypeAndEmptyObject(left, readonly);
39124                 if (merged) {
39125                     return getSpreadType(merged, right, symbol, objectFlags, readonly);
39126                 }
39127                 return mapType(left, function (t) { return getSpreadType(t, right, symbol, objectFlags, readonly); });
39128             }
39129             if (right.flags & 1048576) {
39130                 var merged = tryMergeUnionOfObjectTypeAndEmptyObject(right, readonly);
39131                 if (merged) {
39132                     return getSpreadType(left, merged, symbol, objectFlags, readonly);
39133                 }
39134                 return mapType(right, function (t) { return getSpreadType(left, t, symbol, objectFlags, readonly); });
39135             }
39136             if (right.flags & (528 | 296 | 2112 | 132 | 1056 | 67108864 | 4194304)) {
39137                 return left;
39138             }
39139             if (isGenericObjectType(left) || isGenericObjectType(right)) {
39140                 if (isEmptyObjectType(left)) {
39141                     return right;
39142                 }
39143                 if (left.flags & 2097152) {
39144                     var types = left.types;
39145                     var lastLeft = types[types.length - 1];
39146                     if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) {
39147                         return getIntersectionType(ts.concatenate(types.slice(0, types.length - 1), [getSpreadType(lastLeft, right, symbol, objectFlags, readonly)]));
39148                     }
39149                 }
39150                 return getIntersectionType([left, right]);
39151             }
39152             var members = ts.createSymbolTable();
39153             var skippedPrivateMembers = ts.createUnderscoreEscapedMap();
39154             var stringIndexInfo;
39155             var numberIndexInfo;
39156             if (left === emptyObjectType) {
39157                 stringIndexInfo = getIndexInfoOfType(right, 0);
39158                 numberIndexInfo = getIndexInfoOfType(right, 1);
39159             }
39160             else {
39161                 stringIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 0), getIndexInfoOfType(right, 0));
39162                 numberIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 1), getIndexInfoOfType(right, 1));
39163             }
39164             for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) {
39165                 var rightProp = _a[_i];
39166                 if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 | 16)) {
39167                     skippedPrivateMembers.set(rightProp.escapedName, true);
39168                 }
39169                 else if (isSpreadableProperty(rightProp)) {
39170                     members.set(rightProp.escapedName, getSpreadSymbol(rightProp, readonly));
39171                 }
39172             }
39173             for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) {
39174                 var leftProp = _c[_b];
39175                 if (skippedPrivateMembers.has(leftProp.escapedName) || !isSpreadableProperty(leftProp)) {
39176                     continue;
39177                 }
39178                 if (members.has(leftProp.escapedName)) {
39179                     var rightProp = members.get(leftProp.escapedName);
39180                     var rightType = getTypeOfSymbol(rightProp);
39181                     if (rightProp.flags & 16777216) {
39182                         var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations);
39183                         var flags = 4 | (leftProp.flags & 16777216);
39184                         var result = createSymbol(flags, leftProp.escapedName);
39185                         result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 524288)]);
39186                         result.leftSpread = leftProp;
39187                         result.rightSpread = rightProp;
39188                         result.declarations = declarations;
39189                         result.nameType = getSymbolLinks(leftProp).nameType;
39190                         members.set(leftProp.escapedName, result);
39191                     }
39192                 }
39193                 else {
39194                     members.set(leftProp.escapedName, getSpreadSymbol(leftProp, readonly));
39195                 }
39196             }
39197             var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoWithReadonly(stringIndexInfo, readonly), getIndexInfoWithReadonly(numberIndexInfo, readonly));
39198             spread.objectFlags |= 128 | 1048576 | 1024 | objectFlags;
39199             return spread;
39200         }
39201         function isSpreadableProperty(prop) {
39202             return !ts.some(prop.declarations, ts.isPrivateIdentifierPropertyDeclaration) &&
39203                 (!(prop.flags & (8192 | 32768 | 65536)) ||
39204                     !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); }));
39205         }
39206         function getSpreadSymbol(prop, readonly) {
39207             var isSetonlyAccessor = prop.flags & 65536 && !(prop.flags & 32768);
39208             if (!isSetonlyAccessor && readonly === isReadonlySymbol(prop)) {
39209                 return prop;
39210             }
39211             var flags = 4 | (prop.flags & 16777216);
39212             var result = createSymbol(flags, prop.escapedName, readonly ? 8 : 0);
39213             result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop);
39214             result.declarations = prop.declarations;
39215             result.nameType = getSymbolLinks(prop).nameType;
39216             result.syntheticOrigin = prop;
39217             return result;
39218         }
39219         function getIndexInfoWithReadonly(info, readonly) {
39220             return info && info.isReadonly !== readonly ? createIndexInfo(info.type, readonly, info.declaration) : info;
39221         }
39222         function createLiteralType(flags, value, symbol) {
39223             var type = createType(flags);
39224             type.symbol = symbol;
39225             type.value = value;
39226             return type;
39227         }
39228         function getFreshTypeOfLiteralType(type) {
39229             if (type.flags & 2944) {
39230                 if (!type.freshType) {
39231                     var freshType = createLiteralType(type.flags, type.value, type.symbol);
39232                     freshType.regularType = type;
39233                     freshType.freshType = freshType;
39234                     type.freshType = freshType;
39235                 }
39236                 return type.freshType;
39237             }
39238             return type;
39239         }
39240         function getRegularTypeOfLiteralType(type) {
39241             return type.flags & 2944 ? type.regularType :
39242                 type.flags & 1048576 ? (type.regularType || (type.regularType = getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)))) :
39243                     type;
39244         }
39245         function isFreshLiteralType(type) {
39246             return !!(type.flags & 2944) && type.freshType === type;
39247         }
39248         function getLiteralType(value, enumId, symbol) {
39249             var qualifier = typeof value === "number" ? "#" : typeof value === "string" ? "@" : "n";
39250             var key = (enumId ? enumId : "") + qualifier + (typeof value === "object" ? ts.pseudoBigIntToString(value) : value);
39251             var type = literalTypes.get(key);
39252             if (!type) {
39253                 var flags = (typeof value === "number" ? 256 :
39254                     typeof value === "string" ? 128 : 2048) |
39255                     (enumId ? 1024 : 0);
39256                 literalTypes.set(key, type = createLiteralType(flags, value, symbol));
39257                 type.regularType = type;
39258             }
39259             return type;
39260         }
39261         function getTypeFromLiteralTypeNode(node) {
39262             var links = getNodeLinks(node);
39263             if (!links.resolvedType) {
39264                 links.resolvedType = getRegularTypeOfLiteralType(checkExpression(node.literal));
39265             }
39266             return links.resolvedType;
39267         }
39268         function createUniqueESSymbolType(symbol) {
39269             var type = createType(8192);
39270             type.symbol = symbol;
39271             type.escapedName = "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol);
39272             return type;
39273         }
39274         function getESSymbolLikeTypeForNode(node) {
39275             if (ts.isValidESSymbolDeclaration(node)) {
39276                 var symbol = getSymbolOfNode(node);
39277                 var links = getSymbolLinks(symbol);
39278                 return links.uniqueESSymbolType || (links.uniqueESSymbolType = createUniqueESSymbolType(symbol));
39279             }
39280             return esSymbolType;
39281         }
39282         function getThisType(node) {
39283             var container = ts.getThisContainer(node, false);
39284             var parent = container && container.parent;
39285             if (parent && (ts.isClassLike(parent) || parent.kind === 246)) {
39286                 if (!ts.hasModifier(container, 32) &&
39287                     (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) {
39288                     return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType;
39289                 }
39290             }
39291             if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6) {
39292                 return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType;
39293             }
39294             var host = node.flags & 4194304 ? ts.getHostSignatureFromJSDoc(node) : undefined;
39295             if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3) {
39296                 return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType;
39297             }
39298             if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) {
39299                 return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType;
39300             }
39301             error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface);
39302             return errorType;
39303         }
39304         function getTypeFromThisTypeNode(node) {
39305             var links = getNodeLinks(node);
39306             if (!links.resolvedType) {
39307                 links.resolvedType = getThisType(node);
39308             }
39309             return links.resolvedType;
39310         }
39311         function getTypeFromTypeNode(node) {
39312             return getConditionalFlowTypeOfType(getTypeFromTypeNodeWorker(node), node);
39313         }
39314         function getTypeFromTypeNodeWorker(node) {
39315             switch (node.kind) {
39316                 case 125:
39317                 case 295:
39318                 case 296:
39319                     return anyType;
39320                 case 148:
39321                     return unknownType;
39322                 case 143:
39323                     return stringType;
39324                 case 140:
39325                     return numberType;
39326                 case 151:
39327                     return bigintType;
39328                 case 128:
39329                     return booleanType;
39330                 case 144:
39331                     return esSymbolType;
39332                 case 110:
39333                     return voidType;
39334                 case 146:
39335                     return undefinedType;
39336                 case 100:
39337                     return nullType;
39338                 case 137:
39339                     return neverType;
39340                 case 141:
39341                     return node.flags & 131072 && !noImplicitAny ? anyType : nonPrimitiveType;
39342                 case 183:
39343                 case 104:
39344                     return getTypeFromThisTypeNode(node);
39345                 case 187:
39346                     return getTypeFromLiteralTypeNode(node);
39347                 case 169:
39348                     return getTypeFromTypeReference(node);
39349                 case 168:
39350                     return node.assertsModifier ? voidType : booleanType;
39351                 case 216:
39352                     return getTypeFromTypeReference(node);
39353                 case 172:
39354                     return getTypeFromTypeQueryNode(node);
39355                 case 174:
39356                 case 175:
39357                     return getTypeFromArrayOrTupleTypeNode(node);
39358                 case 176:
39359                     return getTypeFromOptionalTypeNode(node);
39360                 case 178:
39361                     return getTypeFromUnionTypeNode(node);
39362                 case 179:
39363                     return getTypeFromIntersectionTypeNode(node);
39364                 case 297:
39365                     return getTypeFromJSDocNullableTypeNode(node);
39366                 case 299:
39367                     return addOptionality(getTypeFromTypeNode(node.type));
39368                 case 182:
39369                 case 298:
39370                 case 294:
39371                     return getTypeFromTypeNode(node.type);
39372                 case 177:
39373                     return getElementTypeOfArrayType(getTypeFromTypeNode(node.type)) || errorType;
39374                 case 301:
39375                     return getTypeFromJSDocVariadicType(node);
39376                 case 170:
39377                 case 171:
39378                 case 173:
39379                 case 304:
39380                 case 300:
39381                 case 305:
39382                     return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
39383                 case 184:
39384                     return getTypeFromTypeOperatorNode(node);
39385                 case 185:
39386                     return getTypeFromIndexedAccessTypeNode(node);
39387                 case 186:
39388                     return getTypeFromMappedTypeNode(node);
39389                 case 180:
39390                     return getTypeFromConditionalTypeNode(node);
39391                 case 181:
39392                     return getTypeFromInferTypeNode(node);
39393                 case 188:
39394                     return getTypeFromImportTypeNode(node);
39395                 case 75:
39396                 case 153:
39397                     var symbol = getSymbolAtLocation(node);
39398                     return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType;
39399                 default:
39400                     return errorType;
39401             }
39402         }
39403         function instantiateList(items, mapper, instantiator) {
39404             if (items && items.length) {
39405                 for (var i = 0; i < items.length; i++) {
39406                     var item = items[i];
39407                     var mapped = instantiator(item, mapper);
39408                     if (item !== mapped) {
39409                         var result = i === 0 ? [] : items.slice(0, i);
39410                         result.push(mapped);
39411                         for (i++; i < items.length; i++) {
39412                             result.push(instantiator(items[i], mapper));
39413                         }
39414                         return result;
39415                     }
39416                 }
39417             }
39418             return items;
39419         }
39420         function instantiateTypes(types, mapper) {
39421             return instantiateList(types, mapper, instantiateType);
39422         }
39423         function instantiateSignatures(signatures, mapper) {
39424             return instantiateList(signatures, mapper, instantiateSignature);
39425         }
39426         function createTypeMapper(sources, targets) {
39427             return sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : makeArrayTypeMapper(sources, targets);
39428         }
39429         function getMappedType(type, mapper) {
39430             switch (mapper.kind) {
39431                 case 0:
39432                     return type === mapper.source ? mapper.target : type;
39433                 case 1:
39434                     var sources = mapper.sources;
39435                     var targets = mapper.targets;
39436                     for (var i = 0; i < sources.length; i++) {
39437                         if (type === sources[i]) {
39438                             return targets ? targets[i] : anyType;
39439                         }
39440                     }
39441                     return type;
39442                 case 2:
39443                     return mapper.func(type);
39444                 case 3:
39445                 case 4:
39446                     var t1 = getMappedType(type, mapper.mapper1);
39447                     return t1 !== type && mapper.kind === 3 ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2);
39448             }
39449         }
39450         function makeUnaryTypeMapper(source, target) {
39451             return { kind: 0, source: source, target: target };
39452         }
39453         function makeArrayTypeMapper(sources, targets) {
39454             return { kind: 1, sources: sources, targets: targets };
39455         }
39456         function makeFunctionTypeMapper(func) {
39457             return { kind: 2, func: func };
39458         }
39459         function makeCompositeTypeMapper(kind, mapper1, mapper2) {
39460             return { kind: kind, mapper1: mapper1, mapper2: mapper2 };
39461         }
39462         function createTypeEraser(sources) {
39463             return createTypeMapper(sources, undefined);
39464         }
39465         function createBackreferenceMapper(context, index) {
39466             return makeFunctionTypeMapper(function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; });
39467         }
39468         function combineTypeMappers(mapper1, mapper2) {
39469             return mapper1 ? makeCompositeTypeMapper(3, mapper1, mapper2) : mapper2;
39470         }
39471         function mergeTypeMappers(mapper1, mapper2) {
39472             return mapper1 ? makeCompositeTypeMapper(4, mapper1, mapper2) : mapper2;
39473         }
39474         function prependTypeMapping(source, target, mapper) {
39475             return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4, makeUnaryTypeMapper(source, target), mapper);
39476         }
39477         function appendTypeMapping(mapper, source, target) {
39478             return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4, mapper, makeUnaryTypeMapper(source, target));
39479         }
39480         function getRestrictiveTypeParameter(tp) {
39481             return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol),
39482                 tp.restrictiveInstantiation.constraint = unknownType,
39483                 tp.restrictiveInstantiation);
39484         }
39485         function cloneTypeParameter(typeParameter) {
39486             var result = createTypeParameter(typeParameter.symbol);
39487             result.target = typeParameter;
39488             return result;
39489         }
39490         function instantiateTypePredicate(predicate, mapper) {
39491             return createTypePredicate(predicate.kind, predicate.parameterName, predicate.parameterIndex, instantiateType(predicate.type, mapper));
39492         }
39493         function instantiateSignature(signature, mapper, eraseTypeParameters) {
39494             var freshTypeParameters;
39495             if (signature.typeParameters && !eraseTypeParameters) {
39496                 freshTypeParameters = ts.map(signature.typeParameters, cloneTypeParameter);
39497                 mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper);
39498                 for (var _i = 0, freshTypeParameters_1 = freshTypeParameters; _i < freshTypeParameters_1.length; _i++) {
39499                     var tp = freshTypeParameters_1[_i];
39500                     tp.mapper = mapper;
39501                 }
39502             }
39503             var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), undefined, undefined, signature.minArgumentCount, signature.flags & 3);
39504             result.target = signature;
39505             result.mapper = mapper;
39506             return result;
39507         }
39508         function instantiateSymbol(symbol, mapper) {
39509             var links = getSymbolLinks(symbol);
39510             if (links.type && !couldContainTypeVariables(links.type)) {
39511                 return symbol;
39512             }
39513             if (ts.getCheckFlags(symbol) & 1) {
39514                 symbol = links.target;
39515                 mapper = combineTypeMappers(links.mapper, mapper);
39516             }
39517             var result = createSymbol(symbol.flags, symbol.escapedName, 1 | ts.getCheckFlags(symbol) & (8 | 4096 | 16384 | 32768));
39518             result.declarations = symbol.declarations;
39519             result.parent = symbol.parent;
39520             result.target = symbol;
39521             result.mapper = mapper;
39522             if (symbol.valueDeclaration) {
39523                 result.valueDeclaration = symbol.valueDeclaration;
39524             }
39525             if (links.nameType) {
39526                 result.nameType = links.nameType;
39527             }
39528             return result;
39529         }
39530         function getObjectTypeInstantiation(type, mapper) {
39531             var target = type.objectFlags & 64 ? type.target : type;
39532             var node = type.objectFlags & 4 ? type.node : type.symbol.declarations[0];
39533             var links = getNodeLinks(node);
39534             var typeParameters = links.outerTypeParameters;
39535             if (!typeParameters) {
39536                 var declaration_1 = node;
39537                 if (ts.isInJSFile(declaration_1)) {
39538                     var paramTag = ts.findAncestor(declaration_1, ts.isJSDocParameterTag);
39539                     if (paramTag) {
39540                         var paramSymbol = ts.getParameterSymbolFromJSDoc(paramTag);
39541                         if (paramSymbol) {
39542                             declaration_1 = paramSymbol.valueDeclaration;
39543                         }
39544                     }
39545                 }
39546                 var outerTypeParameters = getOuterTypeParameters(declaration_1, true);
39547                 if (isJSConstructor(declaration_1)) {
39548                     var templateTagParameters = getTypeParametersFromDeclaration(declaration_1);
39549                     outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters);
39550                 }
39551                 typeParameters = outerTypeParameters || ts.emptyArray;
39552                 typeParameters = (target.objectFlags & 4 || target.symbol.flags & 2048) && !target.aliasTypeArguments ?
39553                     ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration_1); }) :
39554                     typeParameters;
39555                 links.outerTypeParameters = typeParameters;
39556                 if (typeParameters.length) {
39557                     links.instantiations = ts.createMap();
39558                     links.instantiations.set(getTypeListId(typeParameters), target);
39559                 }
39560             }
39561             if (typeParameters.length) {
39562                 var combinedMapper_1 = combineTypeMappers(type.mapper, mapper);
39563                 var typeArguments = ts.map(typeParameters, function (t) { return getMappedType(t, combinedMapper_1); });
39564                 var id = getTypeListId(typeArguments);
39565                 var result = links.instantiations.get(id);
39566                 if (!result) {
39567                     var newMapper = createTypeMapper(typeParameters, typeArguments);
39568                     result = target.objectFlags & 4 ? createDeferredTypeReference(type.target, type.node, newMapper) :
39569                         target.objectFlags & 32 ? instantiateMappedType(target, newMapper) :
39570                             instantiateAnonymousType(target, newMapper);
39571                     links.instantiations.set(id, result);
39572                 }
39573                 return result;
39574             }
39575             return type;
39576         }
39577         function maybeTypeParameterReference(node) {
39578             return !(node.kind === 153 ||
39579                 node.parent.kind === 169 && node.parent.typeArguments && node === node.parent.typeName ||
39580                 node.parent.kind === 188 && node.parent.typeArguments && node === node.parent.qualifier);
39581         }
39582         function isTypeParameterPossiblyReferenced(tp, node) {
39583             if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) {
39584                 var container = tp.symbol.declarations[0].parent;
39585                 for (var n = node; n !== container; n = n.parent) {
39586                     if (!n || n.kind === 223 || n.kind === 180 && ts.forEachChild(n.extendsType, containsReference)) {
39587                         return true;
39588                     }
39589                 }
39590                 return !!ts.forEachChild(node, containsReference);
39591             }
39592             return true;
39593             function containsReference(node) {
39594                 switch (node.kind) {
39595                     case 183:
39596                         return !!tp.isThisType;
39597                     case 75:
39598                         return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) &&
39599                             getTypeFromTypeNodeWorker(node) === tp;
39600                     case 172:
39601                         return true;
39602                 }
39603                 return !!ts.forEachChild(node, containsReference);
39604             }
39605         }
39606         function getHomomorphicTypeVariable(type) {
39607             var constraintType = getConstraintTypeFromMappedType(type);
39608             if (constraintType.flags & 4194304) {
39609                 var typeVariable = getActualTypeVariable(constraintType.type);
39610                 if (typeVariable.flags & 262144) {
39611                     return typeVariable;
39612                 }
39613             }
39614             return undefined;
39615         }
39616         function instantiateMappedType(type, mapper) {
39617             var typeVariable = getHomomorphicTypeVariable(type);
39618             if (typeVariable) {
39619                 var mappedTypeVariable = instantiateType(typeVariable, mapper);
39620                 if (typeVariable !== mappedTypeVariable) {
39621                     return mapType(getReducedType(mappedTypeVariable), function (t) {
39622                         if (t.flags & (3 | 58982400 | 524288 | 2097152) && t !== wildcardType && t !== errorType) {
39623                             var replacementMapper = prependTypeMapping(typeVariable, t, mapper);
39624                             return isArrayType(t) ? instantiateMappedArrayType(t, type, replacementMapper) :
39625                                 isTupleType(t) ? instantiateMappedTupleType(t, type, replacementMapper) :
39626                                     instantiateAnonymousType(type, replacementMapper);
39627                         }
39628                         return t;
39629                     });
39630                 }
39631             }
39632             return instantiateAnonymousType(type, mapper);
39633         }
39634         function getModifiedReadonlyState(state, modifiers) {
39635             return modifiers & 1 ? true : modifiers & 2 ? false : state;
39636         }
39637         function instantiateMappedArrayType(arrayType, mappedType, mapper) {
39638             var elementType = instantiateMappedTypeTemplate(mappedType, numberType, true, mapper);
39639             return elementType === errorType ? errorType :
39640                 createArrayType(elementType, getModifiedReadonlyState(isReadonlyArrayType(arrayType), getMappedTypeModifiers(mappedType)));
39641         }
39642         function instantiateMappedTupleType(tupleType, mappedType, mapper) {
39643             var minLength = tupleType.target.minLength;
39644             var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) {
39645                 return instantiateMappedTypeTemplate(mappedType, getLiteralType("" + i), i >= minLength, mapper);
39646             });
39647             var modifiers = getMappedTypeModifiers(mappedType);
39648             var newMinLength = modifiers & 4 ? 0 :
39649                 modifiers & 8 ? getTypeReferenceArity(tupleType) - (tupleType.target.hasRestElement ? 1 : 0) :
39650                     minLength;
39651             var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, modifiers);
39652             return ts.contains(elementTypes, errorType) ? errorType :
39653                 createTupleType(elementTypes, newMinLength, tupleType.target.hasRestElement, newReadonly, tupleType.target.associatedNames);
39654         }
39655         function instantiateMappedTypeTemplate(type, key, isOptional, mapper) {
39656             var templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key);
39657             var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper);
39658             var modifiers = getMappedTypeModifiers(type);
39659             return strictNullChecks && modifiers & 4 && !maybeTypeOfKind(propType, 32768 | 16384) ? getOptionalType(propType) :
39660                 strictNullChecks && modifiers & 8 && isOptional ? getTypeWithFacts(propType, 524288) :
39661                     propType;
39662         }
39663         function instantiateAnonymousType(type, mapper) {
39664             var result = createObjectType(type.objectFlags | 64, type.symbol);
39665             if (type.objectFlags & 32) {
39666                 result.declaration = type.declaration;
39667                 var origTypeParameter = getTypeParameterFromMappedType(type);
39668                 var freshTypeParameter = cloneTypeParameter(origTypeParameter);
39669                 result.typeParameter = freshTypeParameter;
39670                 mapper = combineTypeMappers(makeUnaryTypeMapper(origTypeParameter, freshTypeParameter), mapper);
39671                 freshTypeParameter.mapper = mapper;
39672             }
39673             result.target = type;
39674             result.mapper = mapper;
39675             result.aliasSymbol = type.aliasSymbol;
39676             result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper);
39677             return result;
39678         }
39679         function getConditionalTypeInstantiation(type, mapper) {
39680             var root = type.root;
39681             if (root.outerTypeParameters) {
39682                 var typeArguments = ts.map(root.outerTypeParameters, function (t) { return getMappedType(t, mapper); });
39683                 var id = getTypeListId(typeArguments);
39684                 var result = root.instantiations.get(id);
39685                 if (!result) {
39686                     var newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
39687                     result = instantiateConditionalType(root, newMapper);
39688                     root.instantiations.set(id, result);
39689                 }
39690                 return result;
39691             }
39692             return type;
39693         }
39694         function instantiateConditionalType(root, mapper) {
39695             if (root.isDistributive) {
39696                 var checkType_1 = root.checkType;
39697                 var instantiatedType = getMappedType(checkType_1, mapper);
39698                 if (checkType_1 !== instantiatedType && instantiatedType.flags & (1048576 | 131072)) {
39699                     return mapType(instantiatedType, function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, mapper)); });
39700                 }
39701             }
39702             return getConditionalType(root, mapper);
39703         }
39704         function instantiateType(type, mapper) {
39705             if (!type || !mapper) {
39706                 return type;
39707             }
39708             if (instantiationDepth === 50 || instantiationCount >= 5000000) {
39709                 error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
39710                 return errorType;
39711             }
39712             totalInstantiationCount++;
39713             instantiationCount++;
39714             instantiationDepth++;
39715             var result = instantiateTypeWorker(type, mapper);
39716             instantiationDepth--;
39717             return result;
39718         }
39719         function instantiateTypeWithoutDepthIncrease(type, mapper) {
39720             instantiationDepth--;
39721             var result = instantiateType(type, mapper);
39722             instantiationDepth++;
39723             return result;
39724         }
39725         function instantiateTypeWorker(type, mapper) {
39726             var flags = type.flags;
39727             if (flags & 262144) {
39728                 return getMappedType(type, mapper);
39729             }
39730             if (flags & 524288) {
39731                 var objectFlags = type.objectFlags;
39732                 if (objectFlags & 16) {
39733                     return couldContainTypeVariables(type) ?
39734                         getObjectTypeInstantiation(type, mapper) : type;
39735                 }
39736                 if (objectFlags & 32) {
39737                     return getObjectTypeInstantiation(type, mapper);
39738                 }
39739                 if (objectFlags & 4) {
39740                     if (type.node) {
39741                         return getObjectTypeInstantiation(type, mapper);
39742                     }
39743                     var resolvedTypeArguments = type.resolvedTypeArguments;
39744                     var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper);
39745                     return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type;
39746                 }
39747                 return type;
39748             }
39749             if ((flags & 2097152) || (flags & 1048576 && !(flags & 131068))) {
39750                 if (!couldContainTypeVariables(type)) {
39751                     return type;
39752                 }
39753                 var types = type.types;
39754                 var newTypes = instantiateTypes(types, mapper);
39755                 return newTypes === types
39756                     ? type
39757                     : (flags & 2097152)
39758                         ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper))
39759                         : getUnionType(newTypes, 1, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper));
39760             }
39761             if (flags & 4194304) {
39762                 return getIndexType(instantiateType(type.type, mapper));
39763             }
39764             if (flags & 8388608) {
39765                 return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper));
39766             }
39767             if (flags & 16777216) {
39768                 return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper));
39769             }
39770             if (flags & 33554432) {
39771                 var maybeVariable = instantiateType(type.baseType, mapper);
39772                 if (maybeVariable.flags & 8650752) {
39773                     return getSubstitutionType(maybeVariable, instantiateType(type.substitute, mapper));
39774                 }
39775                 else {
39776                     var sub = instantiateType(type.substitute, mapper);
39777                     if (sub.flags & 3 || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) {
39778                         return maybeVariable;
39779                     }
39780                     return sub;
39781                 }
39782             }
39783             return type;
39784         }
39785         function getPermissiveInstantiation(type) {
39786             return type.flags & (131068 | 3 | 131072) ? type :
39787                 type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper));
39788         }
39789         function getRestrictiveInstantiation(type) {
39790             if (type.flags & (131068 | 3 | 131072)) {
39791                 return type;
39792             }
39793             if (type.restrictiveInstantiation) {
39794                 return type.restrictiveInstantiation;
39795             }
39796             type.restrictiveInstantiation = instantiateType(type, restrictiveMapper);
39797             type.restrictiveInstantiation.restrictiveInstantiation = type.restrictiveInstantiation;
39798             return type.restrictiveInstantiation;
39799         }
39800         function instantiateIndexInfo(info, mapper) {
39801             return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration);
39802         }
39803         function isContextSensitive(node) {
39804             ts.Debug.assert(node.kind !== 161 || ts.isObjectLiteralMethod(node));
39805             switch (node.kind) {
39806                 case 201:
39807                 case 202:
39808                 case 161:
39809                 case 244:
39810                     return isContextSensitiveFunctionLikeDeclaration(node);
39811                 case 193:
39812                     return ts.some(node.properties, isContextSensitive);
39813                 case 192:
39814                     return ts.some(node.elements, isContextSensitive);
39815                 case 210:
39816                     return isContextSensitive(node.whenTrue) ||
39817                         isContextSensitive(node.whenFalse);
39818                 case 209:
39819                     return (node.operatorToken.kind === 56 || node.operatorToken.kind === 60) &&
39820                         (isContextSensitive(node.left) || isContextSensitive(node.right));
39821                 case 281:
39822                     return isContextSensitive(node.initializer);
39823                 case 200:
39824                     return isContextSensitive(node.expression);
39825                 case 274:
39826                     return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive);
39827                 case 273: {
39828                     var initializer = node.initializer;
39829                     return !!initializer && isContextSensitive(initializer);
39830                 }
39831                 case 276: {
39832                     var expression = node.expression;
39833                     return !!expression && isContextSensitive(expression);
39834                 }
39835             }
39836             return false;
39837         }
39838         function isContextSensitiveFunctionLikeDeclaration(node) {
39839             return (!ts.isFunctionDeclaration(node) || ts.isInJSFile(node) && !!getTypeForDeclarationFromJSDocComment(node)) &&
39840                 (hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node));
39841         }
39842         function hasContextSensitiveParameters(node) {
39843             if (!node.typeParameters) {
39844                 if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) {
39845                     return true;
39846                 }
39847                 if (node.kind !== 202) {
39848                     var parameter = ts.firstOrUndefined(node.parameters);
39849                     if (!(parameter && ts.parameterIsThisKeyword(parameter))) {
39850                         return true;
39851                     }
39852                 }
39853             }
39854             return false;
39855         }
39856         function hasContextSensitiveReturnExpression(node) {
39857             return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 223 && isContextSensitive(node.body);
39858         }
39859         function isContextSensitiveFunctionOrObjectLiteralMethod(func) {
39860             return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
39861                 isContextSensitiveFunctionLikeDeclaration(func);
39862         }
39863         function getTypeWithoutSignatures(type) {
39864             if (type.flags & 524288) {
39865                 var resolved = resolveStructuredTypeMembers(type);
39866                 if (resolved.constructSignatures.length || resolved.callSignatures.length) {
39867                     var result = createObjectType(16, type.symbol);
39868                     result.members = resolved.members;
39869                     result.properties = resolved.properties;
39870                     result.callSignatures = ts.emptyArray;
39871                     result.constructSignatures = ts.emptyArray;
39872                     return result;
39873                 }
39874             }
39875             else if (type.flags & 2097152) {
39876                 return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures));
39877             }
39878             return type;
39879         }
39880         function isTypeIdenticalTo(source, target) {
39881             return isTypeRelatedTo(source, target, identityRelation);
39882         }
39883         function compareTypesIdentical(source, target) {
39884             return isTypeRelatedTo(source, target, identityRelation) ? -1 : 0;
39885         }
39886         function compareTypesAssignable(source, target) {
39887             return isTypeRelatedTo(source, target, assignableRelation) ? -1 : 0;
39888         }
39889         function compareTypesSubtypeOf(source, target) {
39890             return isTypeRelatedTo(source, target, subtypeRelation) ? -1 : 0;
39891         }
39892         function isTypeSubtypeOf(source, target) {
39893             return isTypeRelatedTo(source, target, subtypeRelation);
39894         }
39895         function isTypeAssignableTo(source, target) {
39896             return isTypeRelatedTo(source, target, assignableRelation);
39897         }
39898         function isTypeDerivedFrom(source, target) {
39899             return source.flags & 1048576 ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) :
39900                 target.flags & 1048576 ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) :
39901                     source.flags & 58982400 ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) :
39902                         target === globalObjectType ? !!(source.flags & (524288 | 67108864)) :
39903                             target === globalFunctionType ? !!(source.flags & 524288) && isFunctionObjectType(source) :
39904                                 hasBaseType(source, getTargetType(target));
39905         }
39906         function isTypeComparableTo(source, target) {
39907             return isTypeRelatedTo(source, target, comparableRelation);
39908         }
39909         function areTypesComparable(type1, type2) {
39910             return isTypeComparableTo(type1, type2) || isTypeComparableTo(type2, type1);
39911         }
39912         function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain, errorOutputObject) {
39913             return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain, errorOutputObject);
39914         }
39915         function checkTypeAssignableToAndOptionallyElaborate(source, target, errorNode, expr, headMessage, containingMessageChain) {
39916             return checkTypeRelatedToAndOptionallyElaborate(source, target, assignableRelation, errorNode, expr, headMessage, containingMessageChain, undefined);
39917         }
39918         function checkTypeRelatedToAndOptionallyElaborate(source, target, relation, errorNode, expr, headMessage, containingMessageChain, errorOutputContainer) {
39919             if (isTypeRelatedTo(source, target, relation))
39920                 return true;
39921             if (!errorNode || !elaborateError(expr, source, target, relation, headMessage, containingMessageChain, errorOutputContainer)) {
39922                 return checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer);
39923             }
39924             return false;
39925         }
39926         function isOrHasGenericConditional(type) {
39927             return !!(type.flags & 16777216 || (type.flags & 2097152 && ts.some(type.types, isOrHasGenericConditional)));
39928         }
39929         function elaborateError(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) {
39930             if (!node || isOrHasGenericConditional(target))
39931                 return false;
39932             if (!checkTypeRelatedTo(source, target, relation, undefined)
39933                 && elaborateDidYouMeanToCallOrConstruct(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer)) {
39934                 return true;
39935             }
39936             switch (node.kind) {
39937                 case 276:
39938                 case 200:
39939                     return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer);
39940                 case 209:
39941                     switch (node.operatorToken.kind) {
39942                         case 62:
39943                         case 27:
39944                             return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer);
39945                     }
39946                     break;
39947                 case 193:
39948                     return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer);
39949                 case 192:
39950                     return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer);
39951                 case 274:
39952                     return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer);
39953                 case 202:
39954                     return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer);
39955             }
39956             return false;
39957         }
39958         function elaborateDidYouMeanToCallOrConstruct(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) {
39959             var callSignatures = getSignaturesOfType(source, 0);
39960             var constructSignatures = getSignaturesOfType(source, 1);
39961             for (var _i = 0, _a = [constructSignatures, callSignatures]; _i < _a.length; _i++) {
39962                 var signatures = _a[_i];
39963                 if (ts.some(signatures, function (s) {
39964                     var returnType = getReturnTypeOfSignature(s);
39965                     return !(returnType.flags & (1 | 131072)) && checkTypeRelatedTo(returnType, target, relation, undefined);
39966                 })) {
39967                     var resultObj = errorOutputContainer || {};
39968                     checkTypeAssignableTo(source, target, node, headMessage, containingMessageChain, resultObj);
39969                     var diagnostic = resultObj.errors[resultObj.errors.length - 1];
39970                     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));
39971                     return true;
39972                 }
39973             }
39974             return false;
39975         }
39976         function elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer) {
39977             if (ts.isBlock(node.body)) {
39978                 return false;
39979             }
39980             if (ts.some(node.parameters, ts.hasType)) {
39981                 return false;
39982             }
39983             var sourceSig = getSingleCallSignature(source);
39984             if (!sourceSig) {
39985                 return false;
39986             }
39987             var targetSignatures = getSignaturesOfType(target, 0);
39988             if (!ts.length(targetSignatures)) {
39989                 return false;
39990             }
39991             var returnExpression = node.body;
39992             var sourceReturn = getReturnTypeOfSignature(sourceSig);
39993             var targetReturn = getUnionType(ts.map(targetSignatures, getReturnTypeOfSignature));
39994             if (!checkTypeRelatedTo(sourceReturn, targetReturn, relation, undefined)) {
39995                 var elaborated = returnExpression && elaborateError(returnExpression, sourceReturn, targetReturn, relation, undefined, containingMessageChain, errorOutputContainer);
39996                 if (elaborated) {
39997                     return elaborated;
39998                 }
39999                 var resultObj = errorOutputContainer || {};
40000                 checkTypeRelatedTo(sourceReturn, targetReturn, relation, returnExpression, undefined, containingMessageChain, resultObj);
40001                 if (resultObj.errors) {
40002                     if (target.symbol && ts.length(target.symbol.declarations)) {
40003                         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));
40004                     }
40005                     if ((ts.getFunctionFlags(node) & 2) === 0
40006                         && !getTypeOfPropertyOfType(sourceReturn, "then")
40007                         && checkTypeRelatedTo(createPromiseType(sourceReturn), targetReturn, relation, undefined)) {
40008                         ts.addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], ts.createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async));
40009                     }
40010                     return true;
40011                 }
40012             }
40013             return false;
40014         }
40015         function getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType) {
40016             var idx = getIndexedAccessTypeOrUndefined(target, nameType);
40017             if (idx) {
40018                 return idx;
40019             }
40020             if (target.flags & 1048576) {
40021                 var best = getBestMatchingType(source, target);
40022                 if (best) {
40023                     return getIndexedAccessTypeOrUndefined(best, nameType);
40024                 }
40025             }
40026         }
40027         function checkExpressionForMutableLocationWithContextualType(next, sourcePropType) {
40028             next.contextualType = sourcePropType;
40029             try {
40030                 return checkExpressionForMutableLocation(next, 1, sourcePropType);
40031             }
40032             finally {
40033                 next.contextualType = undefined;
40034             }
40035         }
40036         function elaborateElementwise(iterator, source, target, relation, containingMessageChain, errorOutputContainer) {
40037             var reportedError = false;
40038             for (var status = iterator.next(); !status.done; status = iterator.next()) {
40039                 var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage;
40040                 var targetPropType = getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType);
40041                 if (!targetPropType || targetPropType.flags & 8388608)
40042                     continue;
40043                 var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType);
40044                 if (sourcePropType && !checkTypeRelatedTo(sourcePropType, targetPropType, relation, undefined)) {
40045                     var elaborated = next && elaborateError(next, sourcePropType, targetPropType, relation, undefined, containingMessageChain, errorOutputContainer);
40046                     if (elaborated) {
40047                         reportedError = true;
40048                     }
40049                     else {
40050                         var resultObj = errorOutputContainer || {};
40051                         var specificSource = next ? checkExpressionForMutableLocationWithContextualType(next, sourcePropType) : sourcePropType;
40052                         var result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj);
40053                         if (result && specificSource !== sourcePropType) {
40054                             checkTypeRelatedTo(sourcePropType, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj);
40055                         }
40056                         if (resultObj.errors) {
40057                             var reportedDiag = resultObj.errors[resultObj.errors.length - 1];
40058                             var propertyName = isTypeUsableAsPropertyName(nameType) ? getPropertyNameFromType(nameType) : undefined;
40059                             var targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined;
40060                             var issuedElaboration = false;
40061                             if (!targetProp) {
40062                                 var indexInfo = isTypeAssignableToKind(nameType, 296) && getIndexInfoOfType(target, 1) ||
40063                                     getIndexInfoOfType(target, 0) ||
40064                                     undefined;
40065                                 if (indexInfo && indexInfo.declaration && !ts.getSourceFileOfNode(indexInfo.declaration).hasNoDefaultLib) {
40066                                     issuedElaboration = true;
40067                                     ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(indexInfo.declaration, ts.Diagnostics.The_expected_type_comes_from_this_index_signature));
40068                                 }
40069                             }
40070                             if (!issuedElaboration && (targetProp && ts.length(targetProp.declarations) || target.symbol && ts.length(target.symbol.declarations))) {
40071                                 var targetNode = targetProp && ts.length(targetProp.declarations) ? targetProp.declarations[0] : target.symbol.declarations[0];
40072                                 if (!ts.getSourceFileOfNode(targetNode).hasNoDefaultLib) {
40073                                     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)));
40074                                 }
40075                             }
40076                         }
40077                         reportedError = true;
40078                     }
40079                 }
40080             }
40081             return reportedError;
40082         }
40083         function generateJsxAttributes(node) {
40084             var _i, _a, prop;
40085             return __generator(this, function (_b) {
40086                 switch (_b.label) {
40087                     case 0:
40088                         if (!ts.length(node.properties))
40089                             return [2];
40090                         _i = 0, _a = node.properties;
40091                         _b.label = 1;
40092                     case 1:
40093                         if (!(_i < _a.length)) return [3, 4];
40094                         prop = _a[_i];
40095                         if (ts.isJsxSpreadAttribute(prop))
40096                             return [3, 3];
40097                         return [4, { errorNode: prop.name, innerExpression: prop.initializer, nameType: getLiteralType(ts.idText(prop.name)) }];
40098                     case 2:
40099                         _b.sent();
40100                         _b.label = 3;
40101                     case 3:
40102                         _i++;
40103                         return [3, 1];
40104                     case 4: return [2];
40105                 }
40106             });
40107         }
40108         function generateJsxChildren(node, getInvalidTextDiagnostic) {
40109             var memberOffset, i, child, nameType, elem;
40110             return __generator(this, function (_a) {
40111                 switch (_a.label) {
40112                     case 0:
40113                         if (!ts.length(node.children))
40114                             return [2];
40115                         memberOffset = 0;
40116                         i = 0;
40117                         _a.label = 1;
40118                     case 1:
40119                         if (!(i < node.children.length)) return [3, 5];
40120                         child = node.children[i];
40121                         nameType = getLiteralType(i - memberOffset);
40122                         elem = getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic);
40123                         if (!elem) return [3, 3];
40124                         return [4, elem];
40125                     case 2:
40126                         _a.sent();
40127                         return [3, 4];
40128                     case 3:
40129                         memberOffset++;
40130                         _a.label = 4;
40131                     case 4:
40132                         i++;
40133                         return [3, 1];
40134                     case 5: return [2];
40135                 }
40136             });
40137         }
40138         function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) {
40139             switch (child.kind) {
40140                 case 276:
40141                     return { errorNode: child, innerExpression: child.expression, nameType: nameType };
40142                 case 11:
40143                     if (child.containsOnlyTriviaWhiteSpaces) {
40144                         break;
40145                     }
40146                     return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() };
40147                 case 266:
40148                 case 267:
40149                 case 270:
40150                     return { errorNode: child, innerExpression: child, nameType: nameType };
40151                 default:
40152                     return ts.Debug.assertNever(child, "Found invalid jsx child");
40153             }
40154         }
40155         function getSemanticJsxChildren(children) {
40156             return ts.filter(children, function (i) { return !ts.isJsxText(i) || !i.containsOnlyTriviaWhiteSpaces; });
40157         }
40158         function elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer) {
40159             var result = elaborateElementwise(generateJsxAttributes(node), source, target, relation, containingMessageChain, errorOutputContainer);
40160             var invalidTextDiagnostic;
40161             if (ts.isJsxOpeningElement(node.parent) && ts.isJsxElement(node.parent.parent)) {
40162                 var containingElement = node.parent.parent;
40163                 var childPropName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
40164                 var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName);
40165                 var childrenNameType = getLiteralType(childrenPropName);
40166                 var childrenTargetType = getIndexedAccessType(target, childrenNameType);
40167                 var validChildren = getSemanticJsxChildren(containingElement.children);
40168                 if (!ts.length(validChildren)) {
40169                     return result;
40170                 }
40171                 var moreThanOneRealChildren = ts.length(validChildren) > 1;
40172                 var arrayLikeTargetParts = filterType(childrenTargetType, isArrayOrTupleLikeType);
40173                 var nonArrayLikeTargetParts = filterType(childrenTargetType, function (t) { return !isArrayOrTupleLikeType(t); });
40174                 if (moreThanOneRealChildren) {
40175                     if (arrayLikeTargetParts !== neverType) {
40176                         var realSource = createTupleType(checkJsxChildren(containingElement, 0));
40177                         var children = generateJsxChildren(containingElement, getInvalidTextualChildDiagnostic);
40178                         result = elaborateElementwise(children, realSource, arrayLikeTargetParts, relation, containingMessageChain, errorOutputContainer) || result;
40179                     }
40180                     else if (!isTypeRelatedTo(getIndexedAccessType(source, childrenNameType), childrenTargetType, relation)) {
40181                         result = true;
40182                         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));
40183                         if (errorOutputContainer && errorOutputContainer.skipLogging) {
40184                             (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
40185                         }
40186                     }
40187                 }
40188                 else {
40189                     if (nonArrayLikeTargetParts !== neverType) {
40190                         var child = validChildren[0];
40191                         var elem_1 = getElaborationElementForJsxChild(child, childrenNameType, getInvalidTextualChildDiagnostic);
40192                         if (elem_1) {
40193                             result = elaborateElementwise((function () { return __generator(this, function (_a) {
40194                                 switch (_a.label) {
40195                                     case 0: return [4, elem_1];
40196                                     case 1:
40197                                         _a.sent();
40198                                         return [2];
40199                                 }
40200                             }); })(), source, target, relation, containingMessageChain, errorOutputContainer) || result;
40201                         }
40202                     }
40203                     else if (!isTypeRelatedTo(getIndexedAccessType(source, childrenNameType), childrenTargetType, relation)) {
40204                         result = true;
40205                         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));
40206                         if (errorOutputContainer && errorOutputContainer.skipLogging) {
40207                             (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
40208                         }
40209                     }
40210                 }
40211             }
40212             return result;
40213             function getInvalidTextualChildDiagnostic() {
40214                 if (!invalidTextDiagnostic) {
40215                     var tagNameText = ts.getTextOfNode(node.parent.tagName);
40216                     var childPropName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
40217                     var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName);
40218                     var childrenTargetType = getIndexedAccessType(target, getLiteralType(childrenPropName));
40219                     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;
40220                     invalidTextDiagnostic = __assign(__assign({}, diagnostic), { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) });
40221                 }
40222                 return invalidTextDiagnostic;
40223             }
40224         }
40225         function generateLimitedTupleElements(node, target) {
40226             var len, i, elem, nameType;
40227             return __generator(this, function (_a) {
40228                 switch (_a.label) {
40229                     case 0:
40230                         len = ts.length(node.elements);
40231                         if (!len)
40232                             return [2];
40233                         i = 0;
40234                         _a.label = 1;
40235                     case 1:
40236                         if (!(i < len)) return [3, 4];
40237                         if (isTupleLikeType(target) && !getPropertyOfType(target, ("" + i)))
40238                             return [3, 3];
40239                         elem = node.elements[i];
40240                         if (ts.isOmittedExpression(elem))
40241                             return [3, 3];
40242                         nameType = getLiteralType(i);
40243                         return [4, { errorNode: elem, innerExpression: elem, nameType: nameType }];
40244                     case 2:
40245                         _a.sent();
40246                         _a.label = 3;
40247                     case 3:
40248                         i++;
40249                         return [3, 1];
40250                     case 4: return [2];
40251                 }
40252             });
40253         }
40254         function elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) {
40255             if (target.flags & 131068)
40256                 return false;
40257             if (isTupleLikeType(source)) {
40258                 return elaborateElementwise(generateLimitedTupleElements(node, target), source, target, relation, containingMessageChain, errorOutputContainer);
40259             }
40260             var oldContext = node.contextualType;
40261             node.contextualType = target;
40262             try {
40263                 var tupleizedType = checkArrayLiteral(node, 1, true);
40264                 node.contextualType = oldContext;
40265                 if (isTupleLikeType(tupleizedType)) {
40266                     return elaborateElementwise(generateLimitedTupleElements(node, target), tupleizedType, target, relation, containingMessageChain, errorOutputContainer);
40267                 }
40268                 return false;
40269             }
40270             finally {
40271                 node.contextualType = oldContext;
40272             }
40273         }
40274         function generateObjectLiteralElements(node) {
40275             var _i, _a, prop, type, _b;
40276             return __generator(this, function (_c) {
40277                 switch (_c.label) {
40278                     case 0:
40279                         if (!ts.length(node.properties))
40280                             return [2];
40281                         _i = 0, _a = node.properties;
40282                         _c.label = 1;
40283                     case 1:
40284                         if (!(_i < _a.length)) return [3, 8];
40285                         prop = _a[_i];
40286                         if (ts.isSpreadAssignment(prop))
40287                             return [3, 7];
40288                         type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576);
40289                         if (!type || (type.flags & 131072)) {
40290                             return [3, 7];
40291                         }
40292                         _b = prop.kind;
40293                         switch (_b) {
40294                             case 164: return [3, 2];
40295                             case 163: return [3, 2];
40296                             case 161: return [3, 2];
40297                             case 282: return [3, 2];
40298                             case 281: return [3, 4];
40299                         }
40300                         return [3, 6];
40301                     case 2: return [4, { errorNode: prop.name, innerExpression: undefined, nameType: type }];
40302                     case 3:
40303                         _c.sent();
40304                         return [3, 7];
40305                     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 }];
40306                     case 5:
40307                         _c.sent();
40308                         return [3, 7];
40309                     case 6:
40310                         ts.Debug.assertNever(prop);
40311                         _c.label = 7;
40312                     case 7:
40313                         _i++;
40314                         return [3, 1];
40315                     case 8: return [2];
40316                 }
40317             });
40318         }
40319         function elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) {
40320             if (target.flags & 131068)
40321                 return false;
40322             return elaborateElementwise(generateObjectLiteralElements(node), source, target, relation, containingMessageChain, errorOutputContainer);
40323         }
40324         function checkTypeComparableTo(source, target, errorNode, headMessage, containingMessageChain) {
40325             return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain);
40326         }
40327         function isSignatureAssignableTo(source, target, ignoreReturnTypes) {
40328             return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 : 0, false, undefined, undefined, compareTypesAssignable, undefined) !== 0;
40329         }
40330         function isAnySignature(s) {
40331             return !s.typeParameters && (!s.thisParameter || isTypeAny(getTypeOfParameter(s.thisParameter))) && s.parameters.length === 1 &&
40332                 signatureHasRestParameter(s) && (getTypeOfParameter(s.parameters[0]) === anyArrayType || isTypeAny(getTypeOfParameter(s.parameters[0]))) &&
40333                 isTypeAny(getReturnTypeOfSignature(s));
40334         }
40335         function compareSignaturesRelated(source, target, checkMode, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) {
40336             if (source === target) {
40337                 return -1;
40338             }
40339             if (isAnySignature(target)) {
40340                 return -1;
40341             }
40342             var targetCount = getParameterCount(target);
40343             var sourceHasMoreParameters = !hasEffectiveRestParameter(target) &&
40344                 (checkMode & 8 ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount);
40345             if (sourceHasMoreParameters) {
40346                 return 0;
40347             }
40348             if (source.typeParameters && source.typeParameters !== target.typeParameters) {
40349                 target = getCanonicalSignature(target);
40350                 source = instantiateSignatureInContextOf(source, target, undefined, compareTypes);
40351             }
40352             var sourceCount = getParameterCount(source);
40353             var sourceRestType = getNonArrayRestType(source);
40354             var targetRestType = getNonArrayRestType(target);
40355             if (sourceRestType || targetRestType) {
40356                 void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers);
40357             }
40358             if (sourceRestType && targetRestType && sourceCount !== targetCount) {
40359                 return 0;
40360             }
40361             var kind = target.declaration ? target.declaration.kind : 0;
40362             var strictVariance = !(checkMode & 3) && strictFunctionTypes && kind !== 161 &&
40363                 kind !== 160 && kind !== 162;
40364             var result = -1;
40365             var sourceThisType = getThisTypeOfSignature(source);
40366             if (sourceThisType && sourceThisType !== voidType) {
40367                 var targetThisType = getThisTypeOfSignature(target);
40368                 if (targetThisType) {
40369                     var related = !strictVariance && compareTypes(sourceThisType, targetThisType, false)
40370                         || compareTypes(targetThisType, sourceThisType, reportErrors);
40371                     if (!related) {
40372                         if (reportErrors) {
40373                             errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible);
40374                         }
40375                         return 0;
40376                     }
40377                     result &= related;
40378                 }
40379             }
40380             var paramCount = sourceRestType || targetRestType ? Math.min(sourceCount, targetCount) : Math.max(sourceCount, targetCount);
40381             var restIndex = sourceRestType || targetRestType ? paramCount - 1 : -1;
40382             for (var i = 0; i < paramCount; i++) {
40383                 var sourceType = i === restIndex ? getRestTypeAtPosition(source, i) : getTypeAtPosition(source, i);
40384                 var targetType = i === restIndex ? getRestTypeAtPosition(target, i) : getTypeAtPosition(target, i);
40385                 var sourceSig = checkMode & 3 ? undefined : getSingleCallSignature(getNonNullableType(sourceType));
40386                 var targetSig = checkMode & 3 ? undefined : getSingleCallSignature(getNonNullableType(targetType));
40387                 var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) &&
40388                     (getFalsyFlags(sourceType) & 98304) === (getFalsyFlags(targetType) & 98304);
40389                 var related = callbacks ?
40390                     compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8) | (strictVariance ? 2 : 1), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) :
40391                     !(checkMode & 3) && !strictVariance && compareTypes(sourceType, targetType, false) || compareTypes(targetType, sourceType, reportErrors);
40392                 if (related && checkMode & 8 && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, false)) {
40393                     related = 0;
40394                 }
40395                 if (!related) {
40396                     if (reportErrors) {
40397                         errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i)));
40398                     }
40399                     return 0;
40400                 }
40401                 result &= related;
40402             }
40403             if (!(checkMode & 4)) {
40404                 var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType
40405                     : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(target.declaration.symbol))
40406                         : getReturnTypeOfSignature(target);
40407                 if (targetReturnType === voidType) {
40408                     return result;
40409                 }
40410                 var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType
40411                     : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(source.declaration.symbol))
40412                         : getReturnTypeOfSignature(source);
40413                 var targetTypePredicate = getTypePredicateOfSignature(target);
40414                 if (targetTypePredicate) {
40415                     var sourceTypePredicate = getTypePredicateOfSignature(source);
40416                     if (sourceTypePredicate) {
40417                         result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, reportErrors, errorReporter, compareTypes);
40418                     }
40419                     else if (ts.isIdentifierTypePredicate(targetTypePredicate)) {
40420                         if (reportErrors) {
40421                             errorReporter(ts.Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source));
40422                         }
40423                         return 0;
40424                     }
40425                 }
40426                 else {
40427                     result &= checkMode & 1 && compareTypes(targetReturnType, sourceReturnType, false) ||
40428                         compareTypes(sourceReturnType, targetReturnType, reportErrors);
40429                     if (!result && reportErrors && incompatibleErrorReporter) {
40430                         incompatibleErrorReporter(sourceReturnType, targetReturnType);
40431                     }
40432                 }
40433             }
40434             return result;
40435         }
40436         function compareTypePredicateRelatedTo(source, target, reportErrors, errorReporter, compareTypes) {
40437             if (source.kind !== target.kind) {
40438                 if (reportErrors) {
40439                     errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard);
40440                     errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
40441                 }
40442                 return 0;
40443             }
40444             if (source.kind === 1 || source.kind === 3) {
40445                 if (source.parameterIndex !== target.parameterIndex) {
40446                     if (reportErrors) {
40447                         errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName);
40448                         errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
40449                     }
40450                     return 0;
40451                 }
40452             }
40453             var related = source.type === target.type ? -1 :
40454                 source.type && target.type ? compareTypes(source.type, target.type, reportErrors) :
40455                     0;
40456             if (related === 0 && reportErrors) {
40457                 errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
40458             }
40459             return related;
40460         }
40461         function isImplementationCompatibleWithOverload(implementation, overload) {
40462             var erasedSource = getErasedSignature(implementation);
40463             var erasedTarget = getErasedSignature(overload);
40464             var sourceReturnType = getReturnTypeOfSignature(erasedSource);
40465             var targetReturnType = getReturnTypeOfSignature(erasedTarget);
40466             if (targetReturnType === voidType
40467                 || isTypeRelatedTo(targetReturnType, sourceReturnType, assignableRelation)
40468                 || isTypeRelatedTo(sourceReturnType, targetReturnType, assignableRelation)) {
40469                 return isSignatureAssignableTo(erasedSource, erasedTarget, true);
40470             }
40471             return false;
40472         }
40473         function isEmptyResolvedType(t) {
40474             return t !== anyFunctionType &&
40475                 t.properties.length === 0 &&
40476                 t.callSignatures.length === 0 &&
40477                 t.constructSignatures.length === 0 &&
40478                 !t.stringIndexInfo &&
40479                 !t.numberIndexInfo;
40480         }
40481         function isEmptyObjectType(type) {
40482             return type.flags & 524288 ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) :
40483                 type.flags & 67108864 ? true :
40484                     type.flags & 1048576 ? ts.some(type.types, isEmptyObjectType) :
40485                         type.flags & 2097152 ? ts.every(type.types, isEmptyObjectType) :
40486                             false;
40487         }
40488         function isEmptyAnonymousObjectType(type) {
40489             return !!(ts.getObjectFlags(type) & 16) && isEmptyObjectType(type);
40490         }
40491         function isStringIndexSignatureOnlyType(type) {
40492             return type.flags & 524288 && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfoOfType(type, 0) && !getIndexInfoOfType(type, 1) ||
40493                 type.flags & 3145728 && ts.every(type.types, isStringIndexSignatureOnlyType) ||
40494                 false;
40495         }
40496         function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) {
40497             if (sourceSymbol === targetSymbol) {
40498                 return true;
40499             }
40500             var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol);
40501             var entry = enumRelation.get(id);
40502             if (entry !== undefined && !(!(entry & 4) && entry & 2 && errorReporter)) {
40503                 return !!(entry & 1);
40504             }
40505             if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256) || !(targetSymbol.flags & 256)) {
40506                 enumRelation.set(id, 2 | 4);
40507                 return false;
40508             }
40509             var targetEnumType = getTypeOfSymbol(targetSymbol);
40510             for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(sourceSymbol)); _i < _a.length; _i++) {
40511                 var property = _a[_i];
40512                 if (property.flags & 8) {
40513                     var targetProperty = getPropertyOfType(targetEnumType, property.escapedName);
40514                     if (!targetProperty || !(targetProperty.flags & 8)) {
40515                         if (errorReporter) {
40516                             errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), undefined, 64));
40517                             enumRelation.set(id, 2 | 4);
40518                         }
40519                         else {
40520                             enumRelation.set(id, 2);
40521                         }
40522                         return false;
40523                     }
40524                 }
40525             }
40526             enumRelation.set(id, 1);
40527             return true;
40528         }
40529         function isSimpleTypeRelatedTo(source, target, relation, errorReporter) {
40530             var s = source.flags;
40531             var t = target.flags;
40532             if (t & 3 || s & 131072 || source === wildcardType)
40533                 return true;
40534             if (t & 131072)
40535                 return false;
40536             if (s & 132 && t & 4)
40537                 return true;
40538             if (s & 128 && s & 1024 &&
40539                 t & 128 && !(t & 1024) &&
40540                 source.value === target.value)
40541                 return true;
40542             if (s & 296 && t & 8)
40543                 return true;
40544             if (s & 256 && s & 1024 &&
40545                 t & 256 && !(t & 1024) &&
40546                 source.value === target.value)
40547                 return true;
40548             if (s & 2112 && t & 64)
40549                 return true;
40550             if (s & 528 && t & 16)
40551                 return true;
40552             if (s & 12288 && t & 4096)
40553                 return true;
40554             if (s & 32 && t & 32 && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter))
40555                 return true;
40556             if (s & 1024 && t & 1024) {
40557                 if (s & 1048576 && t & 1048576 && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter))
40558                     return true;
40559                 if (s & 2944 && t & 2944 &&
40560                     source.value === target.value &&
40561                     isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter))
40562                     return true;
40563             }
40564             if (s & 32768 && (!strictNullChecks || t & (32768 | 16384)))
40565                 return true;
40566             if (s & 65536 && (!strictNullChecks || t & 65536))
40567                 return true;
40568             if (s & 524288 && t & 67108864)
40569                 return true;
40570             if (relation === assignableRelation || relation === comparableRelation) {
40571                 if (s & 1)
40572                     return true;
40573                 if (s & (8 | 256) && !(s & 1024) && (t & 32 || t & 256 && t & 1024))
40574                     return true;
40575             }
40576             return false;
40577         }
40578         function isTypeRelatedTo(source, target, relation) {
40579             if (isFreshLiteralType(source)) {
40580                 source = source.regularType;
40581             }
40582             if (isFreshLiteralType(target)) {
40583                 target = target.regularType;
40584             }
40585             if (source === target) {
40586                 return true;
40587             }
40588             if (relation !== identityRelation) {
40589                 if (relation === comparableRelation && !(target.flags & 131072) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) {
40590                     return true;
40591                 }
40592             }
40593             else {
40594                 if (!(source.flags & 3145728) && !(target.flags & 3145728) &&
40595                     source.flags !== target.flags && !(source.flags & 66584576))
40596                     return false;
40597             }
40598             if (source.flags & 524288 && target.flags & 524288) {
40599                 var related = relation.get(getRelationKey(source, target, 0, relation));
40600                 if (related !== undefined) {
40601                     return !!(related & 1);
40602                 }
40603             }
40604             if (source.flags & 66846720 || target.flags & 66846720) {
40605                 return checkTypeRelatedTo(source, target, relation, undefined);
40606             }
40607             return false;
40608         }
40609         function isIgnoredJsxProperty(source, sourceProp) {
40610             return ts.getObjectFlags(source) & 4096 && !isUnhyphenatedJsxName(sourceProp.escapedName);
40611         }
40612         function getNormalizedType(type, writing) {
40613             while (true) {
40614                 var t = isFreshLiteralType(type) ? type.regularType :
40615                     ts.getObjectFlags(type) & 4 && type.node ? createTypeReference(type.target, getTypeArguments(type)) :
40616                         type.flags & 3145728 ? getReducedType(type) :
40617                             type.flags & 33554432 ? writing ? type.baseType : type.substitute :
40618                                 type.flags & 25165824 ? getSimplifiedType(type, writing) :
40619                                     type;
40620                 if (t === type)
40621                     break;
40622                 type = t;
40623             }
40624             return type;
40625         }
40626         function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) {
40627             var errorInfo;
40628             var relatedInfo;
40629             var maybeKeys;
40630             var sourceStack;
40631             var targetStack;
40632             var maybeCount = 0;
40633             var depth = 0;
40634             var expandingFlags = 0;
40635             var overflow = false;
40636             var overrideNextErrorInfo = 0;
40637             var lastSkippedInfo;
40638             var incompatibleStack = [];
40639             var inPropertyCheck = false;
40640             ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
40641             var result = isRelatedTo(source, target, !!errorNode, headMessage);
40642             if (incompatibleStack.length) {
40643                 reportIncompatibleStack();
40644             }
40645             if (overflow) {
40646                 var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target));
40647                 if (errorOutputContainer) {
40648                     (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
40649                 }
40650             }
40651             else if (errorInfo) {
40652                 if (containingMessageChain) {
40653                     var chain = containingMessageChain();
40654                     if (chain) {
40655                         ts.concatenateDiagnosticMessageChains(chain, errorInfo);
40656                         errorInfo = chain;
40657                     }
40658                 }
40659                 var relatedInformation = void 0;
40660                 if (headMessage && errorNode && !result && source.symbol) {
40661                     var links = getSymbolLinks(source.symbol);
40662                     if (links.originatingImport && !ts.isImportCall(links.originatingImport)) {
40663                         var helpfulRetry = checkTypeRelatedTo(getTypeOfSymbol(links.target), target, relation, undefined);
40664                         if (helpfulRetry) {
40665                             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);
40666                             relatedInformation = ts.append(relatedInformation, diag_1);
40667                         }
40668                     }
40669                 }
40670                 var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation);
40671                 if (relatedInfo) {
40672                     ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInfo));
40673                 }
40674                 if (errorOutputContainer) {
40675                     (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
40676                 }
40677                 if (!errorOutputContainer || !errorOutputContainer.skipLogging) {
40678                     diagnostics.add(diag);
40679                 }
40680             }
40681             if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0) {
40682                 ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error.");
40683             }
40684             return result !== 0;
40685             function resetErrorInfo(saved) {
40686                 errorInfo = saved.errorInfo;
40687                 lastSkippedInfo = saved.lastSkippedInfo;
40688                 incompatibleStack = saved.incompatibleStack;
40689                 overrideNextErrorInfo = saved.overrideNextErrorInfo;
40690                 relatedInfo = saved.relatedInfo;
40691             }
40692             function captureErrorCalculationState() {
40693                 return {
40694                     errorInfo: errorInfo,
40695                     lastSkippedInfo: lastSkippedInfo,
40696                     incompatibleStack: incompatibleStack.slice(),
40697                     overrideNextErrorInfo: overrideNextErrorInfo,
40698                     relatedInfo: !relatedInfo ? undefined : relatedInfo.slice()
40699                 };
40700             }
40701             function reportIncompatibleError(message, arg0, arg1, arg2, arg3) {
40702                 overrideNextErrorInfo++;
40703                 lastSkippedInfo = undefined;
40704                 incompatibleStack.push([message, arg0, arg1, arg2, arg3]);
40705             }
40706             function reportIncompatibleStack() {
40707                 var stack = incompatibleStack;
40708                 incompatibleStack = [];
40709                 var info = lastSkippedInfo;
40710                 lastSkippedInfo = undefined;
40711                 if (stack.length === 1) {
40712                     reportError.apply(void 0, stack[0]);
40713                     if (info) {
40714                         reportRelationError.apply(void 0, __spreadArrays([undefined], info));
40715                     }
40716                     return;
40717                 }
40718                 var path = "";
40719                 var secondaryRootErrors = [];
40720                 while (stack.length) {
40721                     var _a = stack.pop(), msg = _a[0], args = _a.slice(1);
40722                     switch (msg.code) {
40723                         case ts.Diagnostics.Types_of_property_0_are_incompatible.code: {
40724                             if (path.indexOf("new ") === 0) {
40725                                 path = "(" + path + ")";
40726                             }
40727                             var str = "" + args[0];
40728                             if (path.length === 0) {
40729                                 path = "" + str;
40730                             }
40731                             else if (ts.isIdentifierText(str, compilerOptions.target)) {
40732                                 path = path + "." + str;
40733                             }
40734                             else if (str[0] === "[" && str[str.length - 1] === "]") {
40735                                 path = "" + path + str;
40736                             }
40737                             else {
40738                                 path = path + "[" + str + "]";
40739                             }
40740                             break;
40741                         }
40742                         case ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible.code:
40743                         case ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code:
40744                         case ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code:
40745                         case ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: {
40746                             if (path.length === 0) {
40747                                 var mappedMsg = msg;
40748                                 if (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) {
40749                                     mappedMsg = ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible;
40750                                 }
40751                                 else if (msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) {
40752                                     mappedMsg = ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible;
40753                                 }
40754                                 secondaryRootErrors.unshift([mappedMsg, args[0], args[1]]);
40755                             }
40756                             else {
40757                                 var prefix = (msg.code === ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code ||
40758                                     msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code)
40759                                     ? "new "
40760                                     : "";
40761                                 var params = (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code ||
40762                                     msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code)
40763                                     ? ""
40764                                     : "...";
40765                                 path = "" + prefix + path + "(" + params + ")";
40766                             }
40767                             break;
40768                         }
40769                         default:
40770                             return ts.Debug.fail("Unhandled Diagnostic: " + msg.code);
40771                     }
40772                 }
40773                 if (path) {
40774                     reportError(path[path.length - 1] === ")"
40775                         ? ts.Diagnostics.The_types_returned_by_0_are_incompatible_between_these_types
40776                         : ts.Diagnostics.The_types_of_0_are_incompatible_between_these_types, path);
40777                 }
40778                 else {
40779                     secondaryRootErrors.shift();
40780                 }
40781                 for (var _i = 0, secondaryRootErrors_1 = secondaryRootErrors; _i < secondaryRootErrors_1.length; _i++) {
40782                     var _b = secondaryRootErrors_1[_i], msg = _b[0], args = _b.slice(1);
40783                     var originalValue = msg.elidedInCompatabilityPyramid;
40784                     msg.elidedInCompatabilityPyramid = false;
40785                     reportError.apply(void 0, __spreadArrays([msg], args));
40786                     msg.elidedInCompatabilityPyramid = originalValue;
40787                 }
40788                 if (info) {
40789                     reportRelationError.apply(void 0, __spreadArrays([undefined], info));
40790                 }
40791             }
40792             function reportError(message, arg0, arg1, arg2, arg3) {
40793                 ts.Debug.assert(!!errorNode);
40794                 if (incompatibleStack.length)
40795                     reportIncompatibleStack();
40796                 if (message.elidedInCompatabilityPyramid)
40797                     return;
40798                 errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3);
40799             }
40800             function associateRelatedInfo(info) {
40801                 ts.Debug.assert(!!errorInfo);
40802                 if (!relatedInfo) {
40803                     relatedInfo = [info];
40804                 }
40805                 else {
40806                     relatedInfo.push(info);
40807                 }
40808             }
40809             function reportRelationError(message, source, target) {
40810                 if (incompatibleStack.length)
40811                     reportIncompatibleStack();
40812                 var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1];
40813                 if (target.flags & 262144) {
40814                     var constraint = getBaseConstraintOfType(target);
40815                     var constraintElab = constraint && isTypeAssignableTo(source, constraint);
40816                     if (constraintElab) {
40817                         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));
40818                     }
40819                     else {
40820                         reportError(ts.Diagnostics._0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1, targetType, sourceType);
40821                     }
40822                 }
40823                 if (!message) {
40824                     if (relation === comparableRelation) {
40825                         message = ts.Diagnostics.Type_0_is_not_comparable_to_type_1;
40826                     }
40827                     else if (sourceType === targetType) {
40828                         message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated;
40829                     }
40830                     else {
40831                         message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1;
40832                     }
40833                 }
40834                 reportError(message, sourceType, targetType);
40835             }
40836             function tryElaborateErrorsForPrimitivesAndObjects(source, target) {
40837                 var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source);
40838                 var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target);
40839                 if ((globalStringType === source && stringType === target) ||
40840                     (globalNumberType === source && numberType === target) ||
40841                     (globalBooleanType === source && booleanType === target) ||
40842                     (getGlobalESSymbolType(false) === source && esSymbolType === target)) {
40843                     reportError(ts.Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType);
40844                 }
40845             }
40846             function tryElaborateArrayLikeErrors(source, target, reportErrors) {
40847                 if (isTupleType(source)) {
40848                     if (source.target.readonly && isMutableArrayOrTuple(target)) {
40849                         if (reportErrors) {
40850                             reportError(ts.Diagnostics.The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1, typeToString(source), typeToString(target));
40851                         }
40852                         return false;
40853                     }
40854                     return isTupleType(target) || isArrayType(target);
40855                 }
40856                 if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) {
40857                     if (reportErrors) {
40858                         reportError(ts.Diagnostics.The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1, typeToString(source), typeToString(target));
40859                     }
40860                     return false;
40861                 }
40862                 if (isTupleType(target)) {
40863                     return isArrayType(source);
40864                 }
40865                 return true;
40866             }
40867             function isRelatedTo(originalSource, originalTarget, reportErrors, headMessage, intersectionState) {
40868                 if (reportErrors === void 0) { reportErrors = false; }
40869                 if (intersectionState === void 0) { intersectionState = 0; }
40870                 if (originalSource.flags & 524288 && originalTarget.flags & 131068) {
40871                     if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) {
40872                         return -1;
40873                     }
40874                     reportErrorResults(originalSource, originalTarget, 0, !!(ts.getObjectFlags(originalSource) & 4096));
40875                     return 0;
40876                 }
40877                 var source = getNormalizedType(originalSource, false);
40878                 var target = getNormalizedType(originalTarget, true);
40879                 if (source === target)
40880                     return -1;
40881                 if (relation === identityRelation) {
40882                     return isIdenticalTo(source, target);
40883                 }
40884                 if (source.flags & 262144 && getConstraintOfType(source) === target) {
40885                     return -1;
40886                 }
40887                 if (target.flags & 1048576 && source.flags & 524288 &&
40888                     target.types.length <= 3 && maybeTypeOfKind(target, 98304)) {
40889                     var nullStrippedTarget = extractTypesOfKind(target, ~98304);
40890                     if (!(nullStrippedTarget.flags & (1048576 | 131072))) {
40891                         if (source === nullStrippedTarget)
40892                             return -1;
40893                         target = nullStrippedTarget;
40894                     }
40895                 }
40896                 if (relation === comparableRelation && !(target.flags & 131072) && isSimpleTypeRelatedTo(target, source, relation) ||
40897                     isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined))
40898                     return -1;
40899                 var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096);
40900                 var isPerformingExcessPropertyChecks = !(intersectionState & 2) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768);
40901                 if (isPerformingExcessPropertyChecks) {
40902                     if (hasExcessProperties(source, target, reportErrors)) {
40903                         if (reportErrors) {
40904                             reportRelationError(headMessage, source, target);
40905                         }
40906                         return 0;
40907                     }
40908                 }
40909                 var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2) &&
40910                     source.flags & (131068 | 524288 | 2097152) && source !== globalObjectType &&
40911                     target.flags & (524288 | 2097152) && isWeakType(target) &&
40912                     (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
40913                 if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) {
40914                     if (reportErrors) {
40915                         var calls = getSignaturesOfType(source, 0);
40916                         var constructs = getSignaturesOfType(source, 1);
40917                         if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, false) ||
40918                             constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, false)) {
40919                             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));
40920                         }
40921                         else {
40922                             reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, typeToString(source), typeToString(target));
40923                         }
40924                     }
40925                     return 0;
40926                 }
40927                 var result = 0;
40928                 var saveErrorInfo = captureErrorCalculationState();
40929                 if (source.flags & 1048576) {
40930                     result = relation === comparableRelation ?
40931                         someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068), intersectionState) :
40932                         eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068), intersectionState);
40933                 }
40934                 else {
40935                     if (target.flags & 1048576) {
40936                         result = typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068) && !(target.flags & 131068));
40937                     }
40938                     else if (target.flags & 2097152) {
40939                         result = typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2);
40940                     }
40941                     else if (source.flags & 2097152) {
40942                         result = someTypeRelatedToType(source, target, false, 1);
40943                     }
40944                     if (!result && (source.flags & 66846720 || target.flags & 66846720)) {
40945                         if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState)) {
40946                             resetErrorInfo(saveErrorInfo);
40947                         }
40948                     }
40949                 }
40950                 if (!result && source.flags & (2097152 | 262144)) {
40951                     var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 ? source.types : [source], !!(target.flags & 1048576));
40952                     if (constraint && (source.flags & 2097152 || target.flags & 1048576)) {
40953                         if (everyType(constraint, function (c) { return c !== source; })) {
40954                             if (result = isRelatedTo(constraint, target, false, undefined, intersectionState)) {
40955                                 resetErrorInfo(saveErrorInfo);
40956                             }
40957                         }
40958                     }
40959                 }
40960                 if (result && !inPropertyCheck && (target.flags & 2097152 && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
40961                     isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 && getApparentType(source).flags & 3670016 && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152); }))) {
40962                     inPropertyCheck = true;
40963                     result &= recursiveTypeRelatedTo(source, target, reportErrors, 4);
40964                     inPropertyCheck = false;
40965                 }
40966                 reportErrorResults(source, target, result, isComparingJsxAttributes);
40967                 return result;
40968                 function reportErrorResults(source, target, result, isComparingJsxAttributes) {
40969                     if (!result && reportErrors) {
40970                         source = originalSource.aliasSymbol ? originalSource : source;
40971                         target = originalTarget.aliasSymbol ? originalTarget : target;
40972                         var maybeSuppress = overrideNextErrorInfo > 0;
40973                         if (maybeSuppress) {
40974                             overrideNextErrorInfo--;
40975                         }
40976                         if (source.flags & 524288 && target.flags & 524288) {
40977                             var currentError = errorInfo;
40978                             tryElaborateArrayLikeErrors(source, target, reportErrors);
40979                             if (errorInfo !== currentError) {
40980                                 maybeSuppress = !!errorInfo;
40981                             }
40982                         }
40983                         if (source.flags & 524288 && target.flags & 131068) {
40984                             tryElaborateErrorsForPrimitivesAndObjects(source, target);
40985                         }
40986                         else if (source.symbol && source.flags & 524288 && globalObjectType === source) {
40987                             reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
40988                         }
40989                         else if (isComparingJsxAttributes && target.flags & 2097152) {
40990                             var targetTypes = target.types;
40991                             var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
40992                             var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
40993                             if (intrinsicAttributes !== errorType && intrinsicClassAttributes !== errorType &&
40994                                 (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
40995                                 return result;
40996                             }
40997                         }
40998                         else {
40999                             errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
41000                         }
41001                         if (!headMessage && maybeSuppress) {
41002                             lastSkippedInfo = [source, target];
41003                             return result;
41004                         }
41005                         reportRelationError(headMessage, source, target);
41006                     }
41007                 }
41008             }
41009             function isIdenticalTo(source, target) {
41010                 var flags = source.flags & target.flags;
41011                 if (!(flags & 66584576)) {
41012                     return 0;
41013                 }
41014                 if (flags & 3145728) {
41015                     var result_5 = eachTypeRelatedToSomeType(source, target);
41016                     if (result_5) {
41017                         result_5 &= eachTypeRelatedToSomeType(target, source);
41018                     }
41019                     return result_5;
41020                 }
41021                 return recursiveTypeRelatedTo(source, target, false, 0);
41022             }
41023             function getTypeOfPropertyInTypes(types, name) {
41024                 var appendPropType = function (propTypes, type) {
41025                     type = getApparentType(type);
41026                     var prop = type.flags & 3145728 ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name);
41027                     var propType = prop && getTypeOfSymbol(prop) || isNumericLiteralName(name) && getIndexTypeOfType(type, 1) || getIndexTypeOfType(type, 0) || undefinedType;
41028                     return ts.append(propTypes, propType);
41029                 };
41030                 return getUnionType(ts.reduceLeft(types, appendPropType, undefined) || ts.emptyArray);
41031             }
41032             function hasExcessProperties(source, target, reportErrors) {
41033                 if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 16384) {
41034                     return false;
41035                 }
41036                 var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096);
41037                 if ((relation === assignableRelation || relation === comparableRelation) &&
41038                     (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) {
41039                     return false;
41040                 }
41041                 var reducedTarget = target;
41042                 var checkTypes;
41043                 if (target.flags & 1048576) {
41044                     reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
41045                     checkTypes = reducedTarget.flags & 1048576 ? reducedTarget.types : [reducedTarget];
41046                 }
41047                 var _loop_13 = function (prop) {
41048                     if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
41049                         if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
41050                             if (reportErrors) {
41051                                 var errorTarget = filterType(reducedTarget, isExcessPropertyCheckTarget);
41052                                 if (!errorNode)
41053                                     return { value: ts.Debug.fail() };
41054                                 if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode) || ts.isJsxOpeningLikeElement(errorNode.parent)) {
41055                                     if (prop.valueDeclaration && ts.isJsxAttribute(prop.valueDeclaration) && ts.getSourceFileOfNode(errorNode) === ts.getSourceFileOfNode(prop.valueDeclaration.name)) {
41056                                         errorNode = prop.valueDeclaration.name;
41057                                     }
41058                                     reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(errorTarget));
41059                                 }
41060                                 else {
41061                                     var objectLiteralDeclaration_1 = source.symbol && ts.firstOrUndefined(source.symbol.declarations);
41062                                     var suggestion = void 0;
41063                                     if (prop.valueDeclaration && ts.findAncestor(prop.valueDeclaration, function (d) { return d === objectLiteralDeclaration_1; }) && ts.getSourceFileOfNode(objectLiteralDeclaration_1) === ts.getSourceFileOfNode(errorNode)) {
41064                                         var propDeclaration = prop.valueDeclaration;
41065                                         ts.Debug.assertNode(propDeclaration, ts.isObjectLiteralElementLike);
41066                                         errorNode = propDeclaration;
41067                                         var name = propDeclaration.name;
41068                                         if (ts.isIdentifier(name)) {
41069                                             suggestion = getSuggestionForNonexistentProperty(name, errorTarget);
41070                                         }
41071                                     }
41072                                     if (suggestion !== undefined) {
41073                                         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);
41074                                     }
41075                                     else {
41076                                         reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(errorTarget));
41077                                     }
41078                                 }
41079                             }
41080                             return { value: true };
41081                         }
41082                         if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), reportErrors)) {
41083                             if (reportErrors) {
41084                                 reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(prop));
41085                             }
41086                             return { value: true };
41087                         }
41088                     }
41089                 };
41090                 for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
41091                     var prop = _a[_i];
41092                     var state_5 = _loop_13(prop);
41093                     if (typeof state_5 === "object")
41094                         return state_5.value;
41095                 }
41096                 return false;
41097             }
41098             function shouldCheckAsExcessProperty(prop, container) {
41099                 return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration;
41100             }
41101             function eachTypeRelatedToSomeType(source, target) {
41102                 var result = -1;
41103                 var sourceTypes = source.types;
41104                 for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) {
41105                     var sourceType = sourceTypes_1[_i];
41106                     var related = typeRelatedToSomeType(sourceType, target, false);
41107                     if (!related) {
41108                         return 0;
41109                     }
41110                     result &= related;
41111                 }
41112                 return result;
41113             }
41114             function typeRelatedToSomeType(source, target, reportErrors) {
41115                 var targetTypes = target.types;
41116                 if (target.flags & 1048576 && containsType(targetTypes, source)) {
41117                     return -1;
41118                 }
41119                 for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) {
41120                     var type = targetTypes_1[_i];
41121                     var related = isRelatedTo(source, type, false);
41122                     if (related) {
41123                         return related;
41124                     }
41125                 }
41126                 if (reportErrors) {
41127                     var bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
41128                     isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], true);
41129                 }
41130                 return 0;
41131             }
41132             function typeRelatedToEachType(source, target, reportErrors, intersectionState) {
41133                 var result = -1;
41134                 var targetTypes = target.types;
41135                 for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) {
41136                     var targetType = targetTypes_2[_i];
41137                     var related = isRelatedTo(source, targetType, reportErrors, undefined, intersectionState);
41138                     if (!related) {
41139                         return 0;
41140                     }
41141                     result &= related;
41142                 }
41143                 return result;
41144             }
41145             function someTypeRelatedToType(source, target, reportErrors, intersectionState) {
41146                 var sourceTypes = source.types;
41147                 if (source.flags & 1048576 && containsType(sourceTypes, target)) {
41148                     return -1;
41149                 }
41150                 var len = sourceTypes.length;
41151                 for (var i = 0; i < len; i++) {
41152                     var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, undefined, intersectionState);
41153                     if (related) {
41154                         return related;
41155                     }
41156                 }
41157                 return 0;
41158             }
41159             function eachTypeRelatedToType(source, target, reportErrors, intersectionState) {
41160                 var result = -1;
41161                 var sourceTypes = source.types;
41162                 for (var i = 0; i < sourceTypes.length; i++) {
41163                     var sourceType = sourceTypes[i];
41164                     if (target.flags & 1048576 && target.types.length === sourceTypes.length) {
41165                         var related_1 = isRelatedTo(sourceType, target.types[i], false, undefined, intersectionState);
41166                         if (related_1) {
41167                             result &= related_1;
41168                             continue;
41169                         }
41170                     }
41171                     var related = isRelatedTo(sourceType, target, reportErrors, undefined, intersectionState);
41172                     if (!related) {
41173                         return 0;
41174                     }
41175                     result &= related;
41176                 }
41177                 return result;
41178             }
41179             function typeArgumentsRelatedTo(sources, targets, variances, reportErrors, intersectionState) {
41180                 if (sources === void 0) { sources = ts.emptyArray; }
41181                 if (targets === void 0) { targets = ts.emptyArray; }
41182                 if (variances === void 0) { variances = ts.emptyArray; }
41183                 if (sources.length !== targets.length && relation === identityRelation) {
41184                     return 0;
41185                 }
41186                 var length = sources.length <= targets.length ? sources.length : targets.length;
41187                 var result = -1;
41188                 for (var i = 0; i < length; i++) {
41189                     var varianceFlags = i < variances.length ? variances[i] : 1;
41190                     var variance = varianceFlags & 7;
41191                     if (variance !== 4) {
41192                         var s = sources[i];
41193                         var t = targets[i];
41194                         var related = -1;
41195                         if (varianceFlags & 8) {
41196                             related = relation === identityRelation ? isRelatedTo(s, t, false) : compareTypesIdentical(s, t);
41197                         }
41198                         else if (variance === 1) {
41199                             related = isRelatedTo(s, t, reportErrors, undefined, intersectionState);
41200                         }
41201                         else if (variance === 2) {
41202                             related = isRelatedTo(t, s, reportErrors, undefined, intersectionState);
41203                         }
41204                         else if (variance === 3) {
41205                             related = isRelatedTo(t, s, false);
41206                             if (!related) {
41207                                 related = isRelatedTo(s, t, reportErrors, undefined, intersectionState);
41208                             }
41209                         }
41210                         else {
41211                             related = isRelatedTo(s, t, reportErrors, undefined, intersectionState);
41212                             if (related) {
41213                                 related &= isRelatedTo(t, s, reportErrors, undefined, intersectionState);
41214                             }
41215                         }
41216                         if (!related) {
41217                             return 0;
41218                         }
41219                         result &= related;
41220                     }
41221                 }
41222                 return result;
41223             }
41224             function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState) {
41225                 if (overflow) {
41226                     return 0;
41227                 }
41228                 var id = getRelationKey(source, target, intersectionState | (inPropertyCheck ? 8 : 0), relation);
41229                 var entry = relation.get(id);
41230                 if (entry !== undefined) {
41231                     if (reportErrors && entry & 2 && !(entry & 4)) {
41232                     }
41233                     else {
41234                         if (outofbandVarianceMarkerHandler) {
41235                             var saved = entry & 24;
41236                             if (saved & 8) {
41237                                 instantiateType(source, makeFunctionTypeMapper(reportUnmeasurableMarkers));
41238                             }
41239                             if (saved & 16) {
41240                                 instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
41241                             }
41242                         }
41243                         return entry & 1 ? -1 : 0;
41244                     }
41245                 }
41246                 if (!maybeKeys) {
41247                     maybeKeys = [];
41248                     sourceStack = [];
41249                     targetStack = [];
41250                 }
41251                 else {
41252                     for (var i = 0; i < maybeCount; i++) {
41253                         if (id === maybeKeys[i]) {
41254                             return 1;
41255                         }
41256                     }
41257                     if (depth === 100) {
41258                         overflow = true;
41259                         return 0;
41260                     }
41261                 }
41262                 var maybeStart = maybeCount;
41263                 maybeKeys[maybeCount] = id;
41264                 maybeCount++;
41265                 sourceStack[depth] = source;
41266                 targetStack[depth] = target;
41267                 depth++;
41268                 var saveExpandingFlags = expandingFlags;
41269                 if (!(expandingFlags & 1) && isDeeplyNestedType(source, sourceStack, depth))
41270                     expandingFlags |= 1;
41271                 if (!(expandingFlags & 2) && isDeeplyNestedType(target, targetStack, depth))
41272                     expandingFlags |= 2;
41273                 var originalHandler;
41274                 var propagatingVarianceFlags = 0;
41275                 if (outofbandVarianceMarkerHandler) {
41276                     originalHandler = outofbandVarianceMarkerHandler;
41277                     outofbandVarianceMarkerHandler = function (onlyUnreliable) {
41278                         propagatingVarianceFlags |= onlyUnreliable ? 16 : 8;
41279                         return originalHandler(onlyUnreliable);
41280                     };
41281                 }
41282                 var result = expandingFlags !== 3 ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 1;
41283                 if (outofbandVarianceMarkerHandler) {
41284                     outofbandVarianceMarkerHandler = originalHandler;
41285                 }
41286                 expandingFlags = saveExpandingFlags;
41287                 depth--;
41288                 if (result) {
41289                     if (result === -1 || depth === 0) {
41290                         for (var i = maybeStart; i < maybeCount; i++) {
41291                             relation.set(maybeKeys[i], 1 | propagatingVarianceFlags);
41292                         }
41293                         maybeCount = maybeStart;
41294                     }
41295                 }
41296                 else {
41297                     relation.set(id, (reportErrors ? 4 : 0) | 2 | propagatingVarianceFlags);
41298                     maybeCount = maybeStart;
41299                 }
41300                 return result;
41301             }
41302             function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
41303                 if (intersectionState & 4) {
41304                     return propertiesRelatedTo(source, target, reportErrors, undefined, 0);
41305                 }
41306                 var flags = source.flags & target.flags;
41307                 if (relation === identityRelation && !(flags & 524288)) {
41308                     if (flags & 4194304) {
41309                         return isRelatedTo(source.type, target.type, false);
41310                     }
41311                     var result_6 = 0;
41312                     if (flags & 8388608) {
41313                         if (result_6 = isRelatedTo(source.objectType, target.objectType, false)) {
41314                             if (result_6 &= isRelatedTo(source.indexType, target.indexType, false)) {
41315                                 return result_6;
41316                             }
41317                         }
41318                     }
41319                     if (flags & 16777216) {
41320                         if (source.root.isDistributive === target.root.isDistributive) {
41321                             if (result_6 = isRelatedTo(source.checkType, target.checkType, false)) {
41322                                 if (result_6 &= isRelatedTo(source.extendsType, target.extendsType, false)) {
41323                                     if (result_6 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), false)) {
41324                                         if (result_6 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), false)) {
41325                                             return result_6;
41326                                         }
41327                                     }
41328                                 }
41329                             }
41330                         }
41331                     }
41332                     if (flags & 33554432) {
41333                         return isRelatedTo(source.substitute, target.substitute, false);
41334                     }
41335                     return 0;
41336                 }
41337                 var result;
41338                 var originalErrorInfo;
41339                 var varianceCheckFailed = false;
41340                 var saveErrorInfo = captureErrorCalculationState();
41341                 if (source.flags & (524288 | 16777216) && source.aliasSymbol &&
41342                     source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol &&
41343                     !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) {
41344                     var variances = getAliasVariances(source.aliasSymbol);
41345                     if (variances === ts.emptyArray) {
41346                         return 1;
41347                     }
41348                     var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState);
41349                     if (varianceResult !== undefined) {
41350                         return varianceResult;
41351                     }
41352                 }
41353                 if (target.flags & 262144) {
41354                     if (ts.getObjectFlags(source) & 32 && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source))) {
41355                         if (!(getMappedTypeModifiers(source) & 4)) {
41356                             var templateType = getTemplateTypeFromMappedType(source);
41357                             var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source));
41358                             if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) {
41359                                 return result;
41360                             }
41361                         }
41362                     }
41363                 }
41364                 else if (target.flags & 4194304) {
41365                     if (source.flags & 4194304) {
41366                         if (result = isRelatedTo(target.type, source.type, false)) {
41367                             return result;
41368                         }
41369                     }
41370                     var constraint = getSimplifiedTypeOrConstraint(target.type);
41371                     if (constraint) {
41372                         if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), reportErrors) === -1) {
41373                             return -1;
41374                         }
41375                     }
41376                 }
41377                 else if (target.flags & 8388608) {
41378                     if (relation !== identityRelation) {
41379                         var objectType = target.objectType;
41380                         var indexType = target.indexType;
41381                         var baseObjectType = getBaseConstraintOfType(objectType) || objectType;
41382                         var baseIndexType = getBaseConstraintOfType(indexType) || indexType;
41383                         if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) {
41384                             var accessFlags = 2 | (baseObjectType !== objectType ? 1 : 0);
41385                             var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, undefined, accessFlags);
41386                             if (constraint && (result = isRelatedTo(source, constraint, reportErrors))) {
41387                                 return result;
41388                             }
41389                         }
41390                     }
41391                 }
41392                 else if (isGenericMappedType(target)) {
41393                     var template = getTemplateTypeFromMappedType(target);
41394                     var modifiers = getMappedTypeModifiers(target);
41395                     if (!(modifiers & 8)) {
41396                         if (template.flags & 8388608 && template.objectType === source &&
41397                             template.indexType === getTypeParameterFromMappedType(target)) {
41398                             return -1;
41399                         }
41400                         if (!isGenericMappedType(source)) {
41401                             var targetConstraint = getConstraintTypeFromMappedType(target);
41402                             var sourceKeys = getIndexType(source, undefined, true);
41403                             var includeOptional = modifiers & 4;
41404                             var filteredByApplicability = includeOptional ? intersectTypes(targetConstraint, sourceKeys) : undefined;
41405                             if (includeOptional
41406                                 ? !(filteredByApplicability.flags & 131072)
41407                                 : isRelatedTo(targetConstraint, sourceKeys)) {
41408                                 var typeParameter = getTypeParameterFromMappedType(target);
41409                                 var indexingType = filteredByApplicability ? getIntersectionType([filteredByApplicability, typeParameter]) : typeParameter;
41410                                 var indexedAccessType = getIndexedAccessType(source, indexingType);
41411                                 var templateType = getTemplateTypeFromMappedType(target);
41412                                 if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) {
41413                                     return result;
41414                                 }
41415                             }
41416                             originalErrorInfo = errorInfo;
41417                             resetErrorInfo(saveErrorInfo);
41418                         }
41419                     }
41420                 }
41421                 if (source.flags & 8650752) {
41422                     if (source.flags & 8388608 && target.flags & 8388608) {
41423                         if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) {
41424                             result &= isRelatedTo(source.indexType, target.indexType, reportErrors);
41425                         }
41426                         if (result) {
41427                             resetErrorInfo(saveErrorInfo);
41428                             return result;
41429                         }
41430                     }
41431                     else {
41432                         var constraint = getConstraintOfType(source);
41433                         if (!constraint || (source.flags & 262144 && constraint.flags & 1)) {
41434                             if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864))) {
41435                                 resetErrorInfo(saveErrorInfo);
41436                                 return result;
41437                             }
41438                         }
41439                         else if (result = isRelatedTo(constraint, target, false, undefined, intersectionState)) {
41440                             resetErrorInfo(saveErrorInfo);
41441                             return result;
41442                         }
41443                         else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors, undefined, intersectionState)) {
41444                             resetErrorInfo(saveErrorInfo);
41445                             return result;
41446                         }
41447                     }
41448                 }
41449                 else if (source.flags & 4194304) {
41450                     if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) {
41451                         resetErrorInfo(saveErrorInfo);
41452                         return result;
41453                     }
41454                 }
41455                 else if (source.flags & 16777216) {
41456                     if (target.flags & 16777216) {
41457                         var sourceParams = source.root.inferTypeParameters;
41458                         var sourceExtends = source.extendsType;
41459                         var mapper = void 0;
41460                         if (sourceParams) {
41461                             var ctx = createInferenceContext(sourceParams, undefined, 0, isRelatedTo);
41462                             inferTypes(ctx.inferences, target.extendsType, sourceExtends, 128 | 256);
41463                             sourceExtends = instantiateType(sourceExtends, ctx.mapper);
41464                             mapper = ctx.mapper;
41465                         }
41466                         if (isTypeIdenticalTo(sourceExtends, target.extendsType) &&
41467                             (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) {
41468                             if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) {
41469                                 result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors);
41470                             }
41471                             if (result) {
41472                                 resetErrorInfo(saveErrorInfo);
41473                                 return result;
41474                             }
41475                         }
41476                     }
41477                     else {
41478                         var distributiveConstraint = getConstraintOfDistributiveConditionalType(source);
41479                         if (distributiveConstraint) {
41480                             if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) {
41481                                 resetErrorInfo(saveErrorInfo);
41482                                 return result;
41483                             }
41484                         }
41485                     }
41486                     var defaultConstraint = getDefaultConstraintOfConditionalType(source);
41487                     if (defaultConstraint) {
41488                         if (result = isRelatedTo(defaultConstraint, target, reportErrors)) {
41489                             resetErrorInfo(saveErrorInfo);
41490                             return result;
41491                         }
41492                     }
41493                 }
41494                 else {
41495                     if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target) && isEmptyObjectType(source)) {
41496                         return -1;
41497                     }
41498                     if (isGenericMappedType(target)) {
41499                         if (isGenericMappedType(source)) {
41500                             if (result = mappedTypeRelatedTo(source, target, reportErrors)) {
41501                                 resetErrorInfo(saveErrorInfo);
41502                                 return result;
41503                             }
41504                         }
41505                         return 0;
41506                     }
41507                     var sourceIsPrimitive = !!(source.flags & 131068);
41508                     if (relation !== identityRelation) {
41509                         source = getApparentType(source);
41510                     }
41511                     else if (isGenericMappedType(source)) {
41512                         return 0;
41513                     }
41514                     if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && source.target === target.target &&
41515                         !(ts.getObjectFlags(source) & 8192 || ts.getObjectFlags(target) & 8192)) {
41516                         var variances = getVariances(source.target);
41517                         if (variances === ts.emptyArray) {
41518                             return 1;
41519                         }
41520                         var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, intersectionState);
41521                         if (varianceResult !== undefined) {
41522                             return varianceResult;
41523                         }
41524                     }
41525                     else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
41526                         if (relation !== identityRelation) {
41527                             return isRelatedTo(getIndexTypeOfType(source, 1) || anyType, getIndexTypeOfType(target, 1) || anyType, reportErrors);
41528                         }
41529                         else {
41530                             return 0;
41531                         }
41532                     }
41533                     else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 32768 && !isEmptyObjectType(source)) {
41534                         return 0;
41535                     }
41536                     if (source.flags & (524288 | 2097152) && target.flags & 524288) {
41537                         var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive;
41538                         result = propertiesRelatedTo(source, target, reportStructuralErrors, undefined, intersectionState);
41539                         if (result) {
41540                             result &= signaturesRelatedTo(source, target, 0, reportStructuralErrors);
41541                             if (result) {
41542                                 result &= signaturesRelatedTo(source, target, 1, reportStructuralErrors);
41543                                 if (result) {
41544                                     result &= indexTypesRelatedTo(source, target, 0, sourceIsPrimitive, reportStructuralErrors, intersectionState);
41545                                     if (result) {
41546                                         result &= indexTypesRelatedTo(source, target, 1, sourceIsPrimitive, reportStructuralErrors, intersectionState);
41547                                     }
41548                                 }
41549                             }
41550                         }
41551                         if (varianceCheckFailed && result) {
41552                             errorInfo = originalErrorInfo || errorInfo || saveErrorInfo.errorInfo;
41553                         }
41554                         else if (result) {
41555                             return result;
41556                         }
41557                     }
41558                     if (source.flags & (524288 | 2097152) && target.flags & 1048576) {
41559                         var objectOnlyTarget = extractTypesOfKind(target, 524288 | 2097152 | 33554432);
41560                         if (objectOnlyTarget.flags & 1048576) {
41561                             var result_7 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
41562                             if (result_7) {
41563                                 return result_7;
41564                             }
41565                         }
41566                     }
41567                 }
41568                 return 0;
41569                 function relateVariances(sourceTypeArguments, targetTypeArguments, variances, intersectionState) {
41570                     if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) {
41571                         return result;
41572                     }
41573                     if (ts.some(variances, function (v) { return !!(v & 24); })) {
41574                         originalErrorInfo = undefined;
41575                         resetErrorInfo(saveErrorInfo);
41576                         return undefined;
41577                     }
41578                     var allowStructuralFallback = targetTypeArguments && hasCovariantVoidArgument(targetTypeArguments, variances);
41579                     varianceCheckFailed = !allowStructuralFallback;
41580                     if (variances !== ts.emptyArray && !allowStructuralFallback) {
41581                         if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7) === 0; }))) {
41582                             return 0;
41583                         }
41584                         originalErrorInfo = errorInfo;
41585                         resetErrorInfo(saveErrorInfo);
41586                     }
41587                 }
41588             }
41589             function reportUnmeasurableMarkers(p) {
41590                 if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) {
41591                     outofbandVarianceMarkerHandler(false);
41592                 }
41593                 return p;
41594             }
41595             function reportUnreliableMarkers(p) {
41596                 if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) {
41597                     outofbandVarianceMarkerHandler(true);
41598                 }
41599                 return p;
41600             }
41601             function mappedTypeRelatedTo(source, target, reportErrors) {
41602                 var modifiersRelated = relation === comparableRelation || (relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) :
41603                     getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target));
41604                 if (modifiersRelated) {
41605                     var result_8;
41606                     var targetConstraint = getConstraintTypeFromMappedType(target);
41607                     var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers));
41608                     if (result_8 = isRelatedTo(targetConstraint, sourceConstraint, reportErrors)) {
41609                         var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]);
41610                         return result_8 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors);
41611                     }
41612                 }
41613                 return 0;
41614             }
41615             function typeRelatedToDiscriminatedType(source, target) {
41616                 var sourceProperties = getPropertiesOfType(source);
41617                 var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
41618                 if (!sourcePropertiesFiltered)
41619                     return 0;
41620                 var numCombinations = 1;
41621                 for (var _i = 0, sourcePropertiesFiltered_1 = sourcePropertiesFiltered; _i < sourcePropertiesFiltered_1.length; _i++) {
41622                     var sourceProperty = sourcePropertiesFiltered_1[_i];
41623                     numCombinations *= countTypes(getTypeOfSymbol(sourceProperty));
41624                     if (numCombinations > 25) {
41625                         return 0;
41626                     }
41627                 }
41628                 var sourceDiscriminantTypes = new Array(sourcePropertiesFiltered.length);
41629                 var excludedProperties = ts.createUnderscoreEscapedMap();
41630                 for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
41631                     var sourceProperty = sourcePropertiesFiltered[i];
41632                     var sourcePropertyType = getTypeOfSymbol(sourceProperty);
41633                     sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576
41634                         ? sourcePropertyType.types
41635                         : [sourcePropertyType];
41636                     excludedProperties.set(sourceProperty.escapedName, true);
41637                 }
41638                 var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
41639                 var matchingTypes = [];
41640                 var _loop_14 = function (combination) {
41641                     var hasMatch = false;
41642                     outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) {
41643                         var type = _a[_i];
41644                         var _loop_15 = function (i) {
41645                             var sourceProperty = sourcePropertiesFiltered[i];
41646                             var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
41647                             if (!targetProperty)
41648                                 return "continue-outer";
41649                             if (sourceProperty === targetProperty)
41650                                 return "continue";
41651                             var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, false, 0, strictNullChecks || relation === comparableRelation);
41652                             if (!related) {
41653                                 return "continue-outer";
41654                             }
41655                         };
41656                         for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
41657                             var state_7 = _loop_15(i);
41658                             switch (state_7) {
41659                                 case "continue-outer": continue outer;
41660                             }
41661                         }
41662                         ts.pushIfUnique(matchingTypes, type, ts.equateValues);
41663                         hasMatch = true;
41664                     }
41665                     if (!hasMatch) {
41666                         return { value: 0 };
41667                     }
41668                 };
41669                 for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
41670                     var combination = discriminantCombinations_1[_a];
41671                     var state_6 = _loop_14(combination);
41672                     if (typeof state_6 === "object")
41673                         return state_6.value;
41674                 }
41675                 var result = -1;
41676                 for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) {
41677                     var type = matchingTypes_1[_b];
41678                     result &= propertiesRelatedTo(source, type, false, excludedProperties, 0);
41679                     if (result) {
41680                         result &= signaturesRelatedTo(source, type, 0, false);
41681                         if (result) {
41682                             result &= signaturesRelatedTo(source, type, 1, false);
41683                             if (result) {
41684                                 result &= indexTypesRelatedTo(source, type, 0, false, false, 0);
41685                                 if (result) {
41686                                     result &= indexTypesRelatedTo(source, type, 1, false, false, 0);
41687                                 }
41688                             }
41689                         }
41690                     }
41691                     if (!result) {
41692                         return result;
41693                     }
41694                 }
41695                 return result;
41696             }
41697             function excludeProperties(properties, excludedProperties) {
41698                 if (!excludedProperties || properties.length === 0)
41699                     return properties;
41700                 var result;
41701                 for (var i = 0; i < properties.length; i++) {
41702                     if (!excludedProperties.has(properties[i].escapedName)) {
41703                         if (result) {
41704                             result.push(properties[i]);
41705                         }
41706                     }
41707                     else if (!result) {
41708                         result = properties.slice(0, i);
41709                     }
41710                 }
41711                 return result || properties;
41712             }
41713             function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) {
41714                 var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48);
41715                 var source = getTypeOfSourceProperty(sourceProp);
41716                 if (ts.getCheckFlags(targetProp) & 65536 && !getSymbolLinks(targetProp).type) {
41717                     var links = getSymbolLinks(targetProp);
41718                     ts.Debug.assertIsDefined(links.deferralParent);
41719                     ts.Debug.assertIsDefined(links.deferralConstituents);
41720                     var unionParent = !!(links.deferralParent.flags & 1048576);
41721                     var result_9 = unionParent ? 0 : -1;
41722                     var targetTypes = links.deferralConstituents;
41723                     for (var _i = 0, targetTypes_3 = targetTypes; _i < targetTypes_3.length; _i++) {
41724                         var targetType = targetTypes_3[_i];
41725                         var related = isRelatedTo(source, targetType, false, undefined, unionParent ? 0 : 2);
41726                         if (!unionParent) {
41727                             if (!related) {
41728                                 return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors);
41729                             }
41730                             result_9 &= related;
41731                         }
41732                         else {
41733                             if (related) {
41734                                 return related;
41735                             }
41736                         }
41737                     }
41738                     if (unionParent && !result_9 && targetIsOptional) {
41739                         result_9 = isRelatedTo(source, undefinedType);
41740                     }
41741                     if (unionParent && !result_9 && reportErrors) {
41742                         return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors);
41743                     }
41744                     return result_9;
41745                 }
41746                 else {
41747                     return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, undefined, intersectionState);
41748                 }
41749             }
41750             function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) {
41751                 var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp);
41752                 var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp);
41753                 if (sourcePropFlags & 8 || targetPropFlags & 8) {
41754                     if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) {
41755                         if (reportErrors) {
41756                             if (sourcePropFlags & 8 && targetPropFlags & 8) {
41757                                 reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp));
41758                             }
41759                             else {
41760                                 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));
41761                             }
41762                         }
41763                         return 0;
41764                     }
41765                 }
41766                 else if (targetPropFlags & 16) {
41767                     if (!isValidOverrideOf(sourceProp, targetProp)) {
41768                         if (reportErrors) {
41769                             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));
41770                         }
41771                         return 0;
41772                     }
41773                 }
41774                 else if (sourcePropFlags & 16) {
41775                     if (reportErrors) {
41776                         reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target));
41777                     }
41778                     return 0;
41779                 }
41780                 var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState);
41781                 if (!related) {
41782                     if (reportErrors) {
41783                         reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp));
41784                     }
41785                     return 0;
41786                 }
41787                 if (!skipOptional && sourceProp.flags & 16777216 && !(targetProp.flags & 16777216)) {
41788                     if (reportErrors) {
41789                         reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target));
41790                     }
41791                     return 0;
41792                 }
41793                 return related;
41794             }
41795             function reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties) {
41796                 var shouldSkipElaboration = false;
41797                 if (unmatchedProperty.valueDeclaration
41798                     && ts.isNamedDeclaration(unmatchedProperty.valueDeclaration)
41799                     && ts.isPrivateIdentifier(unmatchedProperty.valueDeclaration.name)
41800                     && source.symbol
41801                     && source.symbol.flags & 32) {
41802                     var privateIdentifierDescription = unmatchedProperty.valueDeclaration.name.escapedText;
41803                     var symbolTableKey = ts.getSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription);
41804                     if (symbolTableKey && getPropertyOfType(source, symbolTableKey)) {
41805                         var sourceName = ts.getDeclarationName(source.symbol.valueDeclaration);
41806                         var targetName = ts.getDeclarationName(target.symbol.valueDeclaration);
41807                         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));
41808                         return;
41809                     }
41810                 }
41811                 var props = ts.arrayFrom(getUnmatchedProperties(source, target, requireOptionalProperties, false));
41812                 if (!headMessage || (headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code &&
41813                     headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code)) {
41814                     shouldSkipElaboration = true;
41815                 }
41816                 if (props.length === 1) {
41817                     var propName = symbolToString(unmatchedProperty);
41818                     reportError.apply(void 0, __spreadArrays([ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName], getTypeNamesForErrorDisplay(source, target)));
41819                     if (ts.length(unmatchedProperty.declarations)) {
41820                         associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName));
41821                     }
41822                     if (shouldSkipElaboration && errorInfo) {
41823                         overrideNextErrorInfo++;
41824                     }
41825                 }
41826                 else if (tryElaborateArrayLikeErrors(source, target, false)) {
41827                     if (props.length > 5) {
41828                         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);
41829                     }
41830                     else {
41831                         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(", "));
41832                     }
41833                     if (shouldSkipElaboration && errorInfo) {
41834                         overrideNextErrorInfo++;
41835                     }
41836                 }
41837             }
41838             function propertiesRelatedTo(source, target, reportErrors, excludedProperties, intersectionState) {
41839                 if (relation === identityRelation) {
41840                     return propertiesIdenticalTo(source, target, excludedProperties);
41841                 }
41842                 var requireOptionalProperties = (relation === subtypeRelation || relation === strictSubtypeRelation) && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source);
41843                 var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties, false);
41844                 if (unmatchedProperty) {
41845                     if (reportErrors) {
41846                         reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties);
41847                     }
41848                     return 0;
41849                 }
41850                 if (isObjectLiteralType(target)) {
41851                     for (var _i = 0, _a = excludeProperties(getPropertiesOfType(source), excludedProperties); _i < _a.length; _i++) {
41852                         var sourceProp = _a[_i];
41853                         if (!getPropertyOfObjectType(target, sourceProp.escapedName)) {
41854                             var sourceType = getTypeOfSymbol(sourceProp);
41855                             if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) {
41856                                 if (reportErrors) {
41857                                     reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target));
41858                                 }
41859                                 return 0;
41860                             }
41861                         }
41862                     }
41863                 }
41864                 var result = -1;
41865                 if (isTupleType(target)) {
41866                     var targetRestType = getRestTypeOfTupleType(target);
41867                     if (targetRestType) {
41868                         if (!isTupleType(source)) {
41869                             return 0;
41870                         }
41871                         var sourceRestType = getRestTypeOfTupleType(source);
41872                         if (sourceRestType && !isRelatedTo(sourceRestType, targetRestType, reportErrors)) {
41873                             if (reportErrors) {
41874                                 reportError(ts.Diagnostics.Rest_signatures_are_incompatible);
41875                             }
41876                             return 0;
41877                         }
41878                         var targetCount = getTypeReferenceArity(target) - 1;
41879                         var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0);
41880                         var sourceTypeArguments = getTypeArguments(source);
41881                         for (var i = targetCount; i < sourceCount; i++) {
41882                             var related = isRelatedTo(sourceTypeArguments[i], targetRestType, reportErrors);
41883                             if (!related) {
41884                                 if (reportErrors) {
41885                                     reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i);
41886                                 }
41887                                 return 0;
41888                             }
41889                             result &= related;
41890                         }
41891                     }
41892                 }
41893                 var properties = getPropertiesOfType(target);
41894                 var numericNamesOnly = isTupleType(source) && isTupleType(target);
41895                 for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) {
41896                     var targetProp = _c[_b];
41897                     var name = targetProp.escapedName;
41898                     if (!(targetProp.flags & 4194304) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) {
41899                         var sourceProp = getPropertyOfType(source, name);
41900                         if (sourceProp && sourceProp !== targetProp) {
41901                             var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation);
41902                             if (!related) {
41903                                 return 0;
41904                             }
41905                             result &= related;
41906                         }
41907                     }
41908                 }
41909                 return result;
41910             }
41911             function propertiesIdenticalTo(source, target, excludedProperties) {
41912                 if (!(source.flags & 524288 && target.flags & 524288)) {
41913                     return 0;
41914                 }
41915                 var sourceProperties = excludeProperties(getPropertiesOfObjectType(source), excludedProperties);
41916                 var targetProperties = excludeProperties(getPropertiesOfObjectType(target), excludedProperties);
41917                 if (sourceProperties.length !== targetProperties.length) {
41918                     return 0;
41919                 }
41920                 var result = -1;
41921                 for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) {
41922                     var sourceProp = sourceProperties_1[_i];
41923                     var targetProp = getPropertyOfObjectType(target, sourceProp.escapedName);
41924                     if (!targetProp) {
41925                         return 0;
41926                     }
41927                     var related = compareProperties(sourceProp, targetProp, isRelatedTo);
41928                     if (!related) {
41929                         return 0;
41930                     }
41931                     result &= related;
41932                 }
41933                 return result;
41934             }
41935             function signaturesRelatedTo(source, target, kind, reportErrors) {
41936                 if (relation === identityRelation) {
41937                     return signaturesIdenticalTo(source, target, kind);
41938                 }
41939                 if (target === anyFunctionType || source === anyFunctionType) {
41940                     return -1;
41941                 }
41942                 var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration);
41943                 var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration);
41944                 var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1) ?
41945                     0 : kind);
41946                 var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1) ?
41947                     0 : kind);
41948                 if (kind === 1 && sourceSignatures.length && targetSignatures.length) {
41949                     if (ts.isAbstractConstructorType(source) && !ts.isAbstractConstructorType(target)) {
41950                         if (reportErrors) {
41951                             reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type);
41952                         }
41953                         return 0;
41954                     }
41955                     if (!constructorVisibilitiesAreCompatible(sourceSignatures[0], targetSignatures[0], reportErrors)) {
41956                         return 0;
41957                     }
41958                 }
41959                 var result = -1;
41960                 var saveErrorInfo = captureErrorCalculationState();
41961                 var incompatibleReporter = kind === 1 ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
41962                 if (ts.getObjectFlags(source) & 64 && ts.getObjectFlags(target) & 64 && source.symbol === target.symbol) {
41963                     for (var i = 0; i < targetSignatures.length; i++) {
41964                         var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i]));
41965                         if (!related) {
41966                             return 0;
41967                         }
41968                         result &= related;
41969                     }
41970                 }
41971                 else if (sourceSignatures.length === 1 && targetSignatures.length === 1) {
41972                     var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks;
41973                     result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors, incompatibleReporter(sourceSignatures[0], targetSignatures[0]));
41974                 }
41975                 else {
41976                     outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) {
41977                         var t = targetSignatures_1[_i];
41978                         var shouldElaborateErrors = reportErrors;
41979                         for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) {
41980                             var s = sourceSignatures_1[_a];
41981                             var related = signatureRelatedTo(s, t, true, shouldElaborateErrors, incompatibleReporter(s, t));
41982                             if (related) {
41983                                 result &= related;
41984                                 resetErrorInfo(saveErrorInfo);
41985                                 continue outer;
41986                             }
41987                             shouldElaborateErrors = false;
41988                         }
41989                         if (shouldElaborateErrors) {
41990                             reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, undefined, undefined, kind));
41991                         }
41992                         return 0;
41993                     }
41994                 }
41995                 return result;
41996             }
41997             function reportIncompatibleCallSignatureReturn(siga, sigb) {
41998                 if (siga.parameters.length === 0 && sigb.parameters.length === 0) {
41999                     return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); };
42000                 }
42001                 return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); };
42002             }
42003             function reportIncompatibleConstructSignatureReturn(siga, sigb) {
42004                 if (siga.parameters.length === 0 && sigb.parameters.length === 0) {
42005                     return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); };
42006                 }
42007                 return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); };
42008             }
42009             function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) {
42010                 return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 : 0, reportErrors, reportError, incompatibleReporter, isRelatedTo, makeFunctionTypeMapper(reportUnreliableMarkers));
42011             }
42012             function signaturesIdenticalTo(source, target, kind) {
42013                 var sourceSignatures = getSignaturesOfType(source, kind);
42014                 var targetSignatures = getSignaturesOfType(target, kind);
42015                 if (sourceSignatures.length !== targetSignatures.length) {
42016                     return 0;
42017                 }
42018                 var result = -1;
42019                 for (var i = 0; i < sourceSignatures.length; i++) {
42020                     var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], false, false, false, isRelatedTo);
42021                     if (!related) {
42022                         return 0;
42023                     }
42024                     result &= related;
42025                 }
42026                 return result;
42027             }
42028             function eachPropertyRelatedTo(source, target, kind, reportErrors) {
42029                 var result = -1;
42030                 var props = source.flags & 2097152 ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source);
42031                 for (var _i = 0, props_2 = props; _i < props_2.length; _i++) {
42032                     var prop = props_2[_i];
42033                     if (isIgnoredJsxProperty(source, prop)) {
42034                         continue;
42035                     }
42036                     var nameType = getSymbolLinks(prop).nameType;
42037                     if (nameType && nameType.flags & 8192) {
42038                         continue;
42039                     }
42040                     if (kind === 0 || isNumericLiteralName(prop.escapedName)) {
42041                         var related = isRelatedTo(getTypeOfSymbol(prop), target, reportErrors);
42042                         if (!related) {
42043                             if (reportErrors) {
42044                                 reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop));
42045                             }
42046                             return 0;
42047                         }
42048                         result &= related;
42049                     }
42050                 }
42051                 return result;
42052             }
42053             function indexTypeRelatedTo(sourceType, targetType, reportErrors) {
42054                 var related = isRelatedTo(sourceType, targetType, reportErrors);
42055                 if (!related && reportErrors) {
42056                     reportError(ts.Diagnostics.Index_signatures_are_incompatible);
42057                 }
42058                 return related;
42059             }
42060             function indexTypesRelatedTo(source, target, kind, sourceIsPrimitive, reportErrors, intersectionState) {
42061                 if (relation === identityRelation) {
42062                     return indexTypesIdenticalTo(source, target, kind);
42063                 }
42064                 var targetType = getIndexTypeOfType(target, kind);
42065                 if (!targetType || targetType.flags & 1 && !sourceIsPrimitive) {
42066                     return -1;
42067                 }
42068                 if (isGenericMappedType(source)) {
42069                     return kind === 0 ? isRelatedTo(getTemplateTypeFromMappedType(source), targetType, reportErrors) : 0;
42070                 }
42071                 var indexType = getIndexTypeOfType(source, kind) || kind === 1 && getIndexTypeOfType(source, 0);
42072                 if (indexType) {
42073                     return indexTypeRelatedTo(indexType, targetType, reportErrors);
42074                 }
42075                 if (!(intersectionState & 1) && isObjectTypeWithInferableIndex(source)) {
42076                     var related = eachPropertyRelatedTo(source, targetType, kind, reportErrors);
42077                     if (related && kind === 0) {
42078                         var numberIndexType = getIndexTypeOfType(source, 1);
42079                         if (numberIndexType) {
42080                             related &= indexTypeRelatedTo(numberIndexType, targetType, reportErrors);
42081                         }
42082                     }
42083                     return related;
42084                 }
42085                 if (reportErrors) {
42086                     reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source));
42087                 }
42088                 return 0;
42089             }
42090             function indexTypesIdenticalTo(source, target, indexKind) {
42091                 var targetInfo = getIndexInfoOfType(target, indexKind);
42092                 var sourceInfo = getIndexInfoOfType(source, indexKind);
42093                 if (!sourceInfo && !targetInfo) {
42094                     return -1;
42095                 }
42096                 if (sourceInfo && targetInfo && sourceInfo.isReadonly === targetInfo.isReadonly) {
42097                     return isRelatedTo(sourceInfo.type, targetInfo.type);
42098                 }
42099                 return 0;
42100             }
42101             function constructorVisibilitiesAreCompatible(sourceSignature, targetSignature, reportErrors) {
42102                 if (!sourceSignature.declaration || !targetSignature.declaration) {
42103                     return true;
42104                 }
42105                 var sourceAccessibility = ts.getSelectedModifierFlags(sourceSignature.declaration, 24);
42106                 var targetAccessibility = ts.getSelectedModifierFlags(targetSignature.declaration, 24);
42107                 if (targetAccessibility === 8) {
42108                     return true;
42109                 }
42110                 if (targetAccessibility === 16 && sourceAccessibility !== 8) {
42111                     return true;
42112                 }
42113                 if (targetAccessibility !== 16 && !sourceAccessibility) {
42114                     return true;
42115                 }
42116                 if (reportErrors) {
42117                     reportError(ts.Diagnostics.Cannot_assign_a_0_constructor_type_to_a_1_constructor_type, visibilityToString(sourceAccessibility), visibilityToString(targetAccessibility));
42118                 }
42119                 return false;
42120             }
42121         }
42122         function getBestMatchingType(source, target, isRelatedTo) {
42123             if (isRelatedTo === void 0) { isRelatedTo = compareTypesAssignable; }
42124             return findMatchingDiscriminantType(source, target, isRelatedTo, true) ||
42125                 findMatchingTypeReferenceOrTypeAliasReference(source, target) ||
42126                 findBestTypeForObjectLiteral(source, target) ||
42127                 findBestTypeForInvokable(source, target) ||
42128                 findMostOverlappyType(source, target);
42129         }
42130         function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue, skipPartial) {
42131             var discriminable = target.types.map(function (_) { return undefined; });
42132             for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) {
42133                 var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1];
42134                 var targetProp = getUnionOrIntersectionProperty(target, propertyName);
42135                 if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16) {
42136                     continue;
42137                 }
42138                 var i = 0;
42139                 for (var _b = 0, _c = target.types; _b < _c.length; _b++) {
42140                     var type = _c[_b];
42141                     var targetType = getTypeOfPropertyOfType(type, propertyName);
42142                     if (targetType && related(getDiscriminatingType(), targetType)) {
42143                         discriminable[i] = discriminable[i] === undefined ? true : discriminable[i];
42144                     }
42145                     else {
42146                         discriminable[i] = false;
42147                     }
42148                     i++;
42149                 }
42150             }
42151             var match = discriminable.indexOf(true);
42152             return match === -1 || discriminable.indexOf(true, match + 1) !== -1 ? defaultValue : target.types[match];
42153         }
42154         function isWeakType(type) {
42155             if (type.flags & 524288) {
42156                 var resolved = resolveStructuredTypeMembers(type);
42157                 return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 &&
42158                     !resolved.stringIndexInfo && !resolved.numberIndexInfo &&
42159                     resolved.properties.length > 0 &&
42160                     ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216); });
42161             }
42162             if (type.flags & 2097152) {
42163                 return ts.every(type.types, isWeakType);
42164             }
42165             return false;
42166         }
42167         function hasCommonProperties(source, target, isComparingJsxAttributes) {
42168             for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
42169                 var prop = _a[_i];
42170                 if (isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) {
42171                     return true;
42172                 }
42173             }
42174             return false;
42175         }
42176         function getMarkerTypeReference(type, source, target) {
42177             var result = createTypeReference(type, ts.map(type.typeParameters, function (t) { return t === source ? target : t; }));
42178             result.objectFlags |= 8192;
42179             return result;
42180         }
42181         function getAliasVariances(symbol) {
42182             var links = getSymbolLinks(symbol);
42183             return getVariancesWorker(links.typeParameters, links, function (_links, param, marker) {
42184                 var type = getTypeAliasInstantiation(symbol, instantiateTypes(links.typeParameters, makeUnaryTypeMapper(param, marker)));
42185                 type.aliasTypeArgumentsContainsMarker = true;
42186                 return type;
42187             });
42188         }
42189         function getVariancesWorker(typeParameters, cache, createMarkerType) {
42190             if (typeParameters === void 0) { typeParameters = ts.emptyArray; }
42191             var variances = cache.variances;
42192             if (!variances) {
42193                 cache.variances = ts.emptyArray;
42194                 variances = [];
42195                 var _loop_16 = function (tp) {
42196                     var unmeasurable = false;
42197                     var unreliable = false;
42198                     var oldHandler = outofbandVarianceMarkerHandler;
42199                     outofbandVarianceMarkerHandler = function (onlyUnreliable) { return onlyUnreliable ? unreliable = true : unmeasurable = true; };
42200                     var typeWithSuper = createMarkerType(cache, tp, markerSuperType);
42201                     var typeWithSub = createMarkerType(cache, tp, markerSubType);
42202                     var variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 : 0) |
42203                         (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 : 0);
42204                     if (variance === 3 && isTypeAssignableTo(createMarkerType(cache, tp, markerOtherType), typeWithSuper)) {
42205                         variance = 4;
42206                     }
42207                     outofbandVarianceMarkerHandler = oldHandler;
42208                     if (unmeasurable || unreliable) {
42209                         if (unmeasurable) {
42210                             variance |= 8;
42211                         }
42212                         if (unreliable) {
42213                             variance |= 16;
42214                         }
42215                     }
42216                     variances.push(variance);
42217                 };
42218                 for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) {
42219                     var tp = typeParameters_1[_i];
42220                     _loop_16(tp);
42221                 }
42222                 cache.variances = variances;
42223             }
42224             return variances;
42225         }
42226         function getVariances(type) {
42227             if (type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8) {
42228                 return arrayVariances;
42229             }
42230             return getVariancesWorker(type.typeParameters, type, getMarkerTypeReference);
42231         }
42232         function hasCovariantVoidArgument(typeArguments, variances) {
42233             for (var i = 0; i < variances.length; i++) {
42234                 if ((variances[i] & 7) === 1 && typeArguments[i].flags & 16384) {
42235                     return true;
42236                 }
42237             }
42238             return false;
42239         }
42240         function isUnconstrainedTypeParameter(type) {
42241             return type.flags & 262144 && !getConstraintOfTypeParameter(type);
42242         }
42243         function isNonDeferredTypeReference(type) {
42244             return !!(ts.getObjectFlags(type) & 4) && !type.node;
42245         }
42246         function isTypeReferenceWithGenericArguments(type) {
42247             return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); });
42248         }
42249         function getTypeReferenceId(type, typeParameters, depth) {
42250             if (depth === void 0) { depth = 0; }
42251             var result = "" + type.target.id;
42252             for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) {
42253                 var t = _a[_i];
42254                 if (isUnconstrainedTypeParameter(t)) {
42255                     var index = typeParameters.indexOf(t);
42256                     if (index < 0) {
42257                         index = typeParameters.length;
42258                         typeParameters.push(t);
42259                     }
42260                     result += "=" + index;
42261                 }
42262                 else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) {
42263                     result += "<" + getTypeReferenceId(t, typeParameters, depth + 1) + ">";
42264                 }
42265                 else {
42266                     result += "-" + t.id;
42267                 }
42268             }
42269             return result;
42270         }
42271         function getRelationKey(source, target, intersectionState, relation) {
42272             if (relation === identityRelation && source.id > target.id) {
42273                 var temp = source;
42274                 source = target;
42275                 target = temp;
42276             }
42277             var postFix = intersectionState ? ":" + intersectionState : "";
42278             if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) {
42279                 var typeParameters = [];
42280                 return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters) + postFix;
42281             }
42282             return source.id + "," + target.id + postFix;
42283         }
42284         function forEachProperty(prop, callback) {
42285             if (ts.getCheckFlags(prop) & 6) {
42286                 for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) {
42287                     var t = _a[_i];
42288                     var p = getPropertyOfType(t, prop.escapedName);
42289                     var result = p && forEachProperty(p, callback);
42290                     if (result) {
42291                         return result;
42292                     }
42293                 }
42294                 return undefined;
42295             }
42296             return callback(prop);
42297         }
42298         function getDeclaringClass(prop) {
42299             return prop.parent && prop.parent.flags & 32 ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined;
42300         }
42301         function isPropertyInClassDerivedFrom(prop, baseClass) {
42302             return forEachProperty(prop, function (sp) {
42303                 var sourceClass = getDeclaringClass(sp);
42304                 return sourceClass ? hasBaseType(sourceClass, baseClass) : false;
42305             });
42306         }
42307         function isValidOverrideOf(sourceProp, targetProp) {
42308             return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 ?
42309                 !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; });
42310         }
42311         function isClassDerivedFromDeclaringClasses(checkClass, prop) {
42312             return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p) & 16 ?
42313                 !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass;
42314         }
42315         function isDeeplyNestedType(type, stack, depth) {
42316             if (depth >= 5 && type.flags & 524288 && !isObjectOrArrayLiteralType(type)) {
42317                 var symbol = type.symbol;
42318                 if (symbol) {
42319                     var count = 0;
42320                     for (var i = 0; i < depth; i++) {
42321                         var t = stack[i];
42322                         if (t.flags & 524288 && t.symbol === symbol) {
42323                             count++;
42324                             if (count >= 5)
42325                                 return true;
42326                         }
42327                     }
42328                 }
42329             }
42330             if (depth >= 5 && type.flags & 8388608) {
42331                 var root = getRootObjectTypeFromIndexedAccessChain(type);
42332                 var count = 0;
42333                 for (var i = 0; i < depth; i++) {
42334                     var t = stack[i];
42335                     if (getRootObjectTypeFromIndexedAccessChain(t) === root) {
42336                         count++;
42337                         if (count >= 5)
42338                             return true;
42339                     }
42340                 }
42341             }
42342             return false;
42343         }
42344         function getRootObjectTypeFromIndexedAccessChain(type) {
42345             var t = type;
42346             while (t.flags & 8388608) {
42347                 t = t.objectType;
42348             }
42349             return t;
42350         }
42351         function isPropertyIdenticalTo(sourceProp, targetProp) {
42352             return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0;
42353         }
42354         function compareProperties(sourceProp, targetProp, compareTypes) {
42355             if (sourceProp === targetProp) {
42356                 return -1;
42357             }
42358             var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24;
42359             var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24;
42360             if (sourcePropAccessibility !== targetPropAccessibility) {
42361                 return 0;
42362             }
42363             if (sourcePropAccessibility) {
42364                 if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) {
42365                     return 0;
42366                 }
42367             }
42368             else {
42369                 if ((sourceProp.flags & 16777216) !== (targetProp.flags & 16777216)) {
42370                     return 0;
42371                 }
42372             }
42373             if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) {
42374                 return 0;
42375             }
42376             return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
42377         }
42378         function isMatchingSignature(source, target, partialMatch) {
42379             var sourceParameterCount = getParameterCount(source);
42380             var targetParameterCount = getParameterCount(target);
42381             var sourceMinArgumentCount = getMinArgumentCount(source);
42382             var targetMinArgumentCount = getMinArgumentCount(target);
42383             var sourceHasRestParameter = hasEffectiveRestParameter(source);
42384             var targetHasRestParameter = hasEffectiveRestParameter(target);
42385             if (sourceParameterCount === targetParameterCount &&
42386                 sourceMinArgumentCount === targetMinArgumentCount &&
42387                 sourceHasRestParameter === targetHasRestParameter) {
42388                 return true;
42389             }
42390             if (partialMatch && sourceMinArgumentCount <= targetMinArgumentCount) {
42391                 return true;
42392             }
42393             return false;
42394         }
42395         function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes) {
42396             if (source === target) {
42397                 return -1;
42398             }
42399             if (!(isMatchingSignature(source, target, partialMatch))) {
42400                 return 0;
42401             }
42402             if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) {
42403                 return 0;
42404             }
42405             if (target.typeParameters) {
42406                 var mapper = createTypeMapper(source.typeParameters, target.typeParameters);
42407                 for (var i = 0; i < target.typeParameters.length; i++) {
42408                     var s = source.typeParameters[i];
42409                     var t = target.typeParameters[i];
42410                     if (!(s === t || compareTypes(instantiateType(getConstraintFromTypeParameter(s), mapper) || unknownType, getConstraintFromTypeParameter(t) || unknownType) &&
42411                         compareTypes(instantiateType(getDefaultFromTypeParameter(s), mapper) || unknownType, getDefaultFromTypeParameter(t) || unknownType))) {
42412                         return 0;
42413                     }
42414                 }
42415                 source = instantiateSignature(source, mapper, true);
42416             }
42417             var result = -1;
42418             if (!ignoreThisTypes) {
42419                 var sourceThisType = getThisTypeOfSignature(source);
42420                 if (sourceThisType) {
42421                     var targetThisType = getThisTypeOfSignature(target);
42422                     if (targetThisType) {
42423                         var related = compareTypes(sourceThisType, targetThisType);
42424                         if (!related) {
42425                             return 0;
42426                         }
42427                         result &= related;
42428                     }
42429                 }
42430             }
42431             var targetLen = getParameterCount(target);
42432             for (var i = 0; i < targetLen; i++) {
42433                 var s = getTypeAtPosition(source, i);
42434                 var t = getTypeAtPosition(target, i);
42435                 var related = compareTypes(t, s);
42436                 if (!related) {
42437                     return 0;
42438                 }
42439                 result &= related;
42440             }
42441             if (!ignoreReturnTypes) {
42442                 var sourceTypePredicate = getTypePredicateOfSignature(source);
42443                 var targetTypePredicate = getTypePredicateOfSignature(target);
42444                 result &= sourceTypePredicate || targetTypePredicate ?
42445                     compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) :
42446                     compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
42447             }
42448             return result;
42449         }
42450         function compareTypePredicatesIdentical(source, target, compareTypes) {
42451             return !(source && target && typePredicateKindsMatch(source, target)) ? 0 :
42452                 source.type === target.type ? -1 :
42453                     source.type && target.type ? compareTypes(source.type, target.type) :
42454                         0;
42455         }
42456         function literalTypesWithSameBaseType(types) {
42457             var commonBaseType;
42458             for (var _i = 0, types_12 = types; _i < types_12.length; _i++) {
42459                 var t = types_12[_i];
42460                 var baseType = getBaseTypeOfLiteralType(t);
42461                 if (!commonBaseType) {
42462                     commonBaseType = baseType;
42463                 }
42464                 if (baseType === t || baseType !== commonBaseType) {
42465                     return false;
42466                 }
42467             }
42468             return true;
42469         }
42470         function getSupertypeOrUnion(types) {
42471             return literalTypesWithSameBaseType(types) ?
42472                 getUnionType(types) :
42473                 ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; });
42474         }
42475         function getCommonSupertype(types) {
42476             if (!strictNullChecks) {
42477                 return getSupertypeOrUnion(types);
42478             }
42479             var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304); });
42480             return primaryTypes.length ?
42481                 getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304) :
42482                 getUnionType(types, 2);
42483         }
42484         function getCommonSubtype(types) {
42485             return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; });
42486         }
42487         function isArrayType(type) {
42488             return !!(ts.getObjectFlags(type) & 4) && (type.target === globalArrayType || type.target === globalReadonlyArrayType);
42489         }
42490         function isReadonlyArrayType(type) {
42491             return !!(ts.getObjectFlags(type) & 4) && type.target === globalReadonlyArrayType;
42492         }
42493         function isMutableArrayOrTuple(type) {
42494             return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly;
42495         }
42496         function getElementTypeOfArrayType(type) {
42497             return isArrayType(type) ? getTypeArguments(type)[0] : undefined;
42498         }
42499         function isArrayLikeType(type) {
42500             return isArrayType(type) || !(type.flags & 98304) && isTypeAssignableTo(type, anyReadonlyArrayType);
42501         }
42502         function isEmptyArrayLiteralType(type) {
42503             var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined;
42504             return elementType === undefinedWideningType || elementType === implicitNeverType;
42505         }
42506         function isTupleLikeType(type) {
42507             return isTupleType(type) || !!getPropertyOfType(type, "0");
42508         }
42509         function isArrayOrTupleLikeType(type) {
42510             return isArrayLikeType(type) || isTupleLikeType(type);
42511         }
42512         function getTupleElementType(type, index) {
42513             var propType = getTypeOfPropertyOfType(type, "" + index);
42514             if (propType) {
42515                 return propType;
42516             }
42517             if (everyType(type, isTupleType)) {
42518                 return mapType(type, function (t) { return getRestTypeOfTupleType(t) || undefinedType; });
42519             }
42520             return undefined;
42521         }
42522         function isNeitherUnitTypeNorNever(type) {
42523             return !(type.flags & (109440 | 131072));
42524         }
42525         function isUnitType(type) {
42526             return !!(type.flags & 109440);
42527         }
42528         function isLiteralType(type) {
42529             return type.flags & 16 ? true :
42530                 type.flags & 1048576 ? type.flags & 1024 ? true : ts.every(type.types, isUnitType) :
42531                     isUnitType(type);
42532         }
42533         function getBaseTypeOfLiteralType(type) {
42534             return type.flags & 1024 ? getBaseTypeOfEnumLiteralType(type) :
42535                 type.flags & 128 ? stringType :
42536                     type.flags & 256 ? numberType :
42537                         type.flags & 2048 ? bigintType :
42538                             type.flags & 512 ? booleanType :
42539                                 type.flags & 1048576 ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) :
42540                                     type;
42541         }
42542         function getWidenedLiteralType(type) {
42543             return type.flags & 1024 && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) :
42544                 type.flags & 128 && isFreshLiteralType(type) ? stringType :
42545                     type.flags & 256 && isFreshLiteralType(type) ? numberType :
42546                         type.flags & 2048 && isFreshLiteralType(type) ? bigintType :
42547                             type.flags & 512 && isFreshLiteralType(type) ? booleanType :
42548                                 type.flags & 1048576 ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) :
42549                                     type;
42550         }
42551         function getWidenedUniqueESSymbolType(type) {
42552             return type.flags & 8192 ? esSymbolType :
42553                 type.flags & 1048576 ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) :
42554                     type;
42555         }
42556         function getWidenedLiteralLikeTypeForContextualType(type, contextualType) {
42557             if (!isLiteralOfContextualType(type, contextualType)) {
42558                 type = getWidenedUniqueESSymbolType(getWidenedLiteralType(type));
42559             }
42560             return type;
42561         }
42562         function getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(type, contextualSignatureReturnType, isAsync) {
42563             if (type && isUnitType(type)) {
42564                 var contextualType = !contextualSignatureReturnType ? undefined :
42565                     isAsync ? getPromisedTypeOfPromise(contextualSignatureReturnType) :
42566                         contextualSignatureReturnType;
42567                 type = getWidenedLiteralLikeTypeForContextualType(type, contextualType);
42568             }
42569             return type;
42570         }
42571         function getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(type, contextualSignatureReturnType, kind, isAsyncGenerator) {
42572             if (type && isUnitType(type)) {
42573                 var contextualType = !contextualSignatureReturnType ? undefined :
42574                     getIterationTypeOfGeneratorFunctionReturnType(kind, contextualSignatureReturnType, isAsyncGenerator);
42575                 type = getWidenedLiteralLikeTypeForContextualType(type, contextualType);
42576             }
42577             return type;
42578         }
42579         function isTupleType(type) {
42580             return !!(ts.getObjectFlags(type) & 4 && type.target.objectFlags & 8);
42581         }
42582         function getRestTypeOfTupleType(type) {
42583             return type.target.hasRestElement ? getTypeArguments(type)[type.target.typeParameters.length - 1] : undefined;
42584         }
42585         function getRestArrayTypeOfTupleType(type) {
42586             var restType = getRestTypeOfTupleType(type);
42587             return restType && createArrayType(restType);
42588         }
42589         function getLengthOfTupleType(type) {
42590             return getTypeReferenceArity(type) - (type.target.hasRestElement ? 1 : 0);
42591         }
42592         function isZeroBigInt(_a) {
42593             var value = _a.value;
42594             return value.base10Value === "0";
42595         }
42596         function getFalsyFlagsOfTypes(types) {
42597             var result = 0;
42598             for (var _i = 0, types_13 = types; _i < types_13.length; _i++) {
42599                 var t = types_13[_i];
42600                 result |= getFalsyFlags(t);
42601             }
42602             return result;
42603         }
42604         function getFalsyFlags(type) {
42605             return type.flags & 1048576 ? getFalsyFlagsOfTypes(type.types) :
42606                 type.flags & 128 ? type.value === "" ? 128 : 0 :
42607                     type.flags & 256 ? type.value === 0 ? 256 : 0 :
42608                         type.flags & 2048 ? isZeroBigInt(type) ? 2048 : 0 :
42609                             type.flags & 512 ? (type === falseType || type === regularFalseType) ? 512 : 0 :
42610                                 type.flags & 117724;
42611         }
42612         function removeDefinitelyFalsyTypes(type) {
42613             return getFalsyFlags(type) & 117632 ?
42614                 filterType(type, function (t) { return !(getFalsyFlags(t) & 117632); }) :
42615                 type;
42616         }
42617         function extractDefinitelyFalsyTypes(type) {
42618             return mapType(type, getDefinitelyFalsyPartOfType);
42619         }
42620         function getDefinitelyFalsyPartOfType(type) {
42621             return type.flags & 4 ? emptyStringType :
42622                 type.flags & 8 ? zeroType :
42623                     type.flags & 64 ? zeroBigIntType :
42624                         type === regularFalseType ||
42625                             type === falseType ||
42626                             type.flags & (16384 | 32768 | 65536) ||
42627                             type.flags & 128 && type.value === "" ||
42628                             type.flags & 256 && type.value === 0 ||
42629                             type.flags & 2048 && isZeroBigInt(type) ? type :
42630                             neverType;
42631         }
42632         function getNullableType(type, flags) {
42633             var missing = (flags & ~type.flags) & (32768 | 65536);
42634             return missing === 0 ? type :
42635                 missing === 32768 ? getUnionType([type, undefinedType]) :
42636                     missing === 65536 ? getUnionType([type, nullType]) :
42637                         getUnionType([type, undefinedType, nullType]);
42638         }
42639         function getOptionalType(type) {
42640             ts.Debug.assert(strictNullChecks);
42641             return type.flags & 32768 ? type : getUnionType([type, undefinedType]);
42642         }
42643         function getGlobalNonNullableTypeInstantiation(type) {
42644             if (!deferredGlobalNonNullableTypeAlias) {
42645                 deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288, undefined) || unknownSymbol;
42646             }
42647             if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) {
42648                 return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]);
42649             }
42650             return getTypeWithFacts(type, 2097152);
42651         }
42652         function getNonNullableType(type) {
42653             return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type;
42654         }
42655         function addOptionalTypeMarker(type) {
42656             return strictNullChecks ? getUnionType([type, optionalType]) : type;
42657         }
42658         function isNotOptionalTypeMarker(type) {
42659             return type !== optionalType;
42660         }
42661         function removeOptionalTypeMarker(type) {
42662             return strictNullChecks ? filterType(type, isNotOptionalTypeMarker) : type;
42663         }
42664         function propagateOptionalTypeMarker(type, node, wasOptional) {
42665             return wasOptional ? ts.isOutermostOptionalChain(node) ? getOptionalType(type) : addOptionalTypeMarker(type) : type;
42666         }
42667         function getOptionalExpressionType(exprType, expression) {
42668             return ts.isExpressionOfOptionalChainRoot(expression) ? getNonNullableType(exprType) :
42669                 ts.isOptionalChain(expression) ? removeOptionalTypeMarker(exprType) :
42670                     exprType;
42671         }
42672         function isCoercibleUnderDoubleEquals(source, target) {
42673             return ((source.flags & (8 | 4 | 512)) !== 0)
42674                 && ((target.flags & (8 | 4 | 16)) !== 0);
42675         }
42676         function isObjectTypeWithInferableIndex(type) {
42677             return type.flags & 2097152 ? ts.every(type.types, isObjectTypeWithInferableIndex) :
42678                 !!(type.symbol && (type.symbol.flags & (4096 | 2048 | 384 | 512)) !== 0 &&
42679                     !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 && isObjectTypeWithInferableIndex(type.source));
42680         }
42681         function createSymbolWithType(source, type) {
42682             var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8);
42683             symbol.declarations = source.declarations;
42684             symbol.parent = source.parent;
42685             symbol.type = type;
42686             symbol.target = source;
42687             if (source.valueDeclaration) {
42688                 symbol.valueDeclaration = source.valueDeclaration;
42689             }
42690             var nameType = getSymbolLinks(source).nameType;
42691             if (nameType) {
42692                 symbol.nameType = nameType;
42693             }
42694             return symbol;
42695         }
42696         function transformTypeOfMembers(type, f) {
42697             var members = ts.createSymbolTable();
42698             for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) {
42699                 var property = _a[_i];
42700                 var original = getTypeOfSymbol(property);
42701                 var updated = f(original);
42702                 members.set(property.escapedName, updated === original ? property : createSymbolWithType(property, updated));
42703             }
42704             return members;
42705         }
42706         function getRegularTypeOfObjectLiteral(type) {
42707             if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 32768)) {
42708                 return type;
42709             }
42710             var regularType = type.regularType;
42711             if (regularType) {
42712                 return regularType;
42713             }
42714             var resolved = type;
42715             var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral);
42716             var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo);
42717             regularNew.flags = resolved.flags;
42718             regularNew.objectFlags |= resolved.objectFlags & ~32768;
42719             type.regularType = regularNew;
42720             return regularNew;
42721         }
42722         function createWideningContext(parent, propertyName, siblings) {
42723             return { parent: parent, propertyName: propertyName, siblings: siblings, resolvedProperties: undefined };
42724         }
42725         function getSiblingsOfContext(context) {
42726             if (!context.siblings) {
42727                 var siblings_1 = [];
42728                 for (var _i = 0, _a = getSiblingsOfContext(context.parent); _i < _a.length; _i++) {
42729                     var type = _a[_i];
42730                     if (isObjectLiteralType(type)) {
42731                         var prop = getPropertyOfObjectType(type, context.propertyName);
42732                         if (prop) {
42733                             forEachType(getTypeOfSymbol(prop), function (t) {
42734                                 siblings_1.push(t);
42735                             });
42736                         }
42737                     }
42738                 }
42739                 context.siblings = siblings_1;
42740             }
42741             return context.siblings;
42742         }
42743         function getPropertiesOfContext(context) {
42744             if (!context.resolvedProperties) {
42745                 var names = ts.createMap();
42746                 for (var _i = 0, _a = getSiblingsOfContext(context); _i < _a.length; _i++) {
42747                     var t = _a[_i];
42748                     if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 1024)) {
42749                         for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) {
42750                             var prop = _c[_b];
42751                             names.set(prop.escapedName, prop);
42752                         }
42753                     }
42754                 }
42755                 context.resolvedProperties = ts.arrayFrom(names.values());
42756             }
42757             return context.resolvedProperties;
42758         }
42759         function getWidenedProperty(prop, context) {
42760             if (!(prop.flags & 4)) {
42761                 return prop;
42762             }
42763             var original = getTypeOfSymbol(prop);
42764             var propContext = context && createWideningContext(context, prop.escapedName, undefined);
42765             var widened = getWidenedTypeWithContext(original, propContext);
42766             return widened === original ? prop : createSymbolWithType(prop, widened);
42767         }
42768         function getUndefinedProperty(prop) {
42769             var cached = undefinedProperties.get(prop.escapedName);
42770             if (cached) {
42771                 return cached;
42772             }
42773             var result = createSymbolWithType(prop, undefinedType);
42774             result.flags |= 16777216;
42775             undefinedProperties.set(prop.escapedName, result);
42776             return result;
42777         }
42778         function getWidenedTypeOfObjectLiteral(type, context) {
42779             var members = ts.createSymbolTable();
42780             for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) {
42781                 var prop = _a[_i];
42782                 members.set(prop.escapedName, getWidenedProperty(prop, context));
42783             }
42784             if (context) {
42785                 for (var _b = 0, _c = getPropertiesOfContext(context); _b < _c.length; _b++) {
42786                     var prop = _c[_b];
42787                     if (!members.has(prop.escapedName)) {
42788                         members.set(prop.escapedName, getUndefinedProperty(prop));
42789                     }
42790                 }
42791             }
42792             var stringIndexInfo = getIndexInfoOfType(type, 0);
42793             var numberIndexInfo = getIndexInfoOfType(type, 1);
42794             var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo && createIndexInfo(getWidenedType(stringIndexInfo.type), stringIndexInfo.isReadonly), numberIndexInfo && createIndexInfo(getWidenedType(numberIndexInfo.type), numberIndexInfo.isReadonly));
42795             result.objectFlags |= (ts.getObjectFlags(type) & (16384 | 2097152));
42796             return result;
42797         }
42798         function getWidenedType(type) {
42799             return getWidenedTypeWithContext(type, undefined);
42800         }
42801         function getWidenedTypeWithContext(type, context) {
42802             if (ts.getObjectFlags(type) & 1572864) {
42803                 if (context === undefined && type.widened) {
42804                     return type.widened;
42805                 }
42806                 var result = void 0;
42807                 if (type.flags & (1 | 98304)) {
42808                     result = anyType;
42809                 }
42810                 else if (isObjectLiteralType(type)) {
42811                     result = getWidenedTypeOfObjectLiteral(type, context);
42812                 }
42813                 else if (type.flags & 1048576) {
42814                     var unionContext_1 = context || createWideningContext(undefined, undefined, type.types);
42815                     var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 ? t : getWidenedTypeWithContext(t, unionContext_1); });
42816                     result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 : 1);
42817                 }
42818                 else if (type.flags & 2097152) {
42819                     result = getIntersectionType(ts.sameMap(type.types, getWidenedType));
42820                 }
42821                 else if (isArrayType(type) || isTupleType(type)) {
42822                     result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType));
42823                 }
42824                 if (result && context === undefined) {
42825                     type.widened = result;
42826                 }
42827                 return result || type;
42828             }
42829             return type;
42830         }
42831         function reportWideningErrorsInType(type) {
42832             var errorReported = false;
42833             if (ts.getObjectFlags(type) & 524288) {
42834                 if (type.flags & 1048576) {
42835                     if (ts.some(type.types, isEmptyObjectType)) {
42836                         errorReported = true;
42837                     }
42838                     else {
42839                         for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
42840                             var t = _a[_i];
42841                             if (reportWideningErrorsInType(t)) {
42842                                 errorReported = true;
42843                             }
42844                         }
42845                     }
42846                 }
42847                 if (isArrayType(type) || isTupleType(type)) {
42848                     for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) {
42849                         var t = _c[_b];
42850                         if (reportWideningErrorsInType(t)) {
42851                             errorReported = true;
42852                         }
42853                     }
42854                 }
42855                 if (isObjectLiteralType(type)) {
42856                     for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) {
42857                         var p = _e[_d];
42858                         var t = getTypeOfSymbol(p);
42859                         if (ts.getObjectFlags(t) & 524288) {
42860                             if (!reportWideningErrorsInType(t)) {
42861                                 error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t)));
42862                             }
42863                             errorReported = true;
42864                         }
42865                     }
42866                 }
42867             }
42868             return errorReported;
42869         }
42870         function reportImplicitAny(declaration, type, wideningKind) {
42871             var typeAsString = typeToString(getWidenedType(type));
42872             if (ts.isInJSFile(declaration) && !ts.isCheckJsEnabledForFile(ts.getSourceFileOfNode(declaration), compilerOptions)) {
42873                 return;
42874             }
42875             var diagnostic;
42876             switch (declaration.kind) {
42877                 case 209:
42878                 case 159:
42879                 case 158:
42880                     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;
42881                     break;
42882                 case 156:
42883                     var param = declaration;
42884                     if (ts.isIdentifier(param.name) &&
42885                         (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) &&
42886                         param.parent.parameters.indexOf(param) > -1 &&
42887                         (resolveName(param, param.name.escapedText, 788968, undefined, param.name.escapedText, true) ||
42888                             param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) {
42889                         var newName = "arg" + param.parent.parameters.indexOf(param);
42890                         errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, ts.declarationNameToString(param.name));
42891                         return;
42892                     }
42893                     diagnostic = declaration.dotDotDotToken ?
42894                         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 :
42895                         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;
42896                     break;
42897                 case 191:
42898                     diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type;
42899                     if (!noImplicitAny) {
42900                         return;
42901                     }
42902                     break;
42903                 case 300:
42904                     error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString);
42905                     return;
42906                 case 244:
42907                 case 161:
42908                 case 160:
42909                 case 163:
42910                 case 164:
42911                 case 201:
42912                 case 202:
42913                     if (noImplicitAny && !declaration.name) {
42914                         if (wideningKind === 3) {
42915                             error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString);
42916                         }
42917                         else {
42918                             error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString);
42919                         }
42920                         return;
42921                     }
42922                     diagnostic = !noImplicitAny ? ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage :
42923                         wideningKind === 3 ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type :
42924                             ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type;
42925                     break;
42926                 case 186:
42927                     if (noImplicitAny) {
42928                         error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type);
42929                     }
42930                     return;
42931                 default:
42932                     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;
42933             }
42934             errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString);
42935         }
42936         function reportErrorsFromWidening(declaration, type, wideningKind) {
42937             if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 524288 && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) {
42938                 if (!reportWideningErrorsInType(type)) {
42939                     reportImplicitAny(declaration, type, wideningKind);
42940                 }
42941             }
42942         }
42943         function applyToParameterTypes(source, target, callback) {
42944             var sourceCount = getParameterCount(source);
42945             var targetCount = getParameterCount(target);
42946             var sourceRestType = getEffectiveRestType(source);
42947             var targetRestType = getEffectiveRestType(target);
42948             var targetNonRestCount = targetRestType ? targetCount - 1 : targetCount;
42949             var paramCount = sourceRestType ? targetNonRestCount : Math.min(sourceCount, targetNonRestCount);
42950             var sourceThisType = getThisTypeOfSignature(source);
42951             if (sourceThisType) {
42952                 var targetThisType = getThisTypeOfSignature(target);
42953                 if (targetThisType) {
42954                     callback(sourceThisType, targetThisType);
42955                 }
42956             }
42957             for (var i = 0; i < paramCount; i++) {
42958                 callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i));
42959             }
42960             if (targetRestType) {
42961                 callback(getRestTypeAtPosition(source, paramCount), targetRestType);
42962             }
42963         }
42964         function applyToReturnTypes(source, target, callback) {
42965             var sourceTypePredicate = getTypePredicateOfSignature(source);
42966             var targetTypePredicate = getTypePredicateOfSignature(target);
42967             if (sourceTypePredicate && targetTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) {
42968                 callback(sourceTypePredicate.type, targetTypePredicate.type);
42969             }
42970             else {
42971                 callback(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
42972             }
42973         }
42974         function createInferenceContext(typeParameters, signature, flags, compareTypes) {
42975             return createInferenceContextWorker(typeParameters.map(createInferenceInfo), signature, flags, compareTypes || compareTypesAssignable);
42976         }
42977         function cloneInferenceContext(context, extraFlags) {
42978             if (extraFlags === void 0) { extraFlags = 0; }
42979             return context && createInferenceContextWorker(ts.map(context.inferences, cloneInferenceInfo), context.signature, context.flags | extraFlags, context.compareTypes);
42980         }
42981         function createInferenceContextWorker(inferences, signature, flags, compareTypes) {
42982             var context = {
42983                 inferences: inferences,
42984                 signature: signature,
42985                 flags: flags,
42986                 compareTypes: compareTypes,
42987                 mapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, true); }),
42988                 nonFixingMapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, false); }),
42989             };
42990             return context;
42991         }
42992         function mapToInferredType(context, t, fix) {
42993             var inferences = context.inferences;
42994             for (var i = 0; i < inferences.length; i++) {
42995                 var inference = inferences[i];
42996                 if (t === inference.typeParameter) {
42997                     if (fix && !inference.isFixed) {
42998                         clearCachedInferences(inferences);
42999                         inference.isFixed = true;
43000                     }
43001                     return getInferredType(context, i);
43002                 }
43003             }
43004             return t;
43005         }
43006         function clearCachedInferences(inferences) {
43007             for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) {
43008                 var inference = inferences_1[_i];
43009                 if (!inference.isFixed) {
43010                     inference.inferredType = undefined;
43011                 }
43012             }
43013         }
43014         function createInferenceInfo(typeParameter) {
43015             return {
43016                 typeParameter: typeParameter,
43017                 candidates: undefined,
43018                 contraCandidates: undefined,
43019                 inferredType: undefined,
43020                 priority: undefined,
43021                 topLevel: true,
43022                 isFixed: false
43023             };
43024         }
43025         function cloneInferenceInfo(inference) {
43026             return {
43027                 typeParameter: inference.typeParameter,
43028                 candidates: inference.candidates && inference.candidates.slice(),
43029                 contraCandidates: inference.contraCandidates && inference.contraCandidates.slice(),
43030                 inferredType: inference.inferredType,
43031                 priority: inference.priority,
43032                 topLevel: inference.topLevel,
43033                 isFixed: inference.isFixed
43034             };
43035         }
43036         function cloneInferredPartOfContext(context) {
43037             var inferences = ts.filter(context.inferences, hasInferenceCandidates);
43038             return inferences.length ?
43039                 createInferenceContextWorker(ts.map(inferences, cloneInferenceInfo), context.signature, context.flags, context.compareTypes) :
43040                 undefined;
43041         }
43042         function getMapperFromContext(context) {
43043             return context && context.mapper;
43044         }
43045         function couldContainTypeVariables(type) {
43046             var objectFlags = ts.getObjectFlags(type);
43047             if (objectFlags & 67108864) {
43048                 return !!(objectFlags & 134217728);
43049             }
43050             var result = !!(type.flags & 63176704 ||
43051                 objectFlags & 4 && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) ||
43052                 objectFlags & 16 && type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && type.symbol.declarations ||
43053                 objectFlags & (32 | 131072) ||
43054                 type.flags & 3145728 && !(type.flags & 1024) && ts.some(type.types, couldContainTypeVariables));
43055             if (type.flags & 3899393) {
43056                 type.objectFlags |= 67108864 | (result ? 134217728 : 0);
43057             }
43058             return result;
43059         }
43060         function isTypeParameterAtTopLevel(type, typeParameter) {
43061             return !!(type === typeParameter ||
43062                 type.flags & 3145728 && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) ||
43063                 type.flags & 16777216 && (isTypeParameterAtTopLevel(getTrueTypeFromConditionalType(type), typeParameter) ||
43064                     isTypeParameterAtTopLevel(getFalseTypeFromConditionalType(type), typeParameter)));
43065         }
43066         function createEmptyObjectTypeFromStringLiteral(type) {
43067             var members = ts.createSymbolTable();
43068             forEachType(type, function (t) {
43069                 if (!(t.flags & 128)) {
43070                     return;
43071                 }
43072                 var name = ts.escapeLeadingUnderscores(t.value);
43073                 var literalProp = createSymbol(4, name);
43074                 literalProp.type = anyType;
43075                 if (t.symbol) {
43076                     literalProp.declarations = t.symbol.declarations;
43077                     literalProp.valueDeclaration = t.symbol.valueDeclaration;
43078                 }
43079                 members.set(name, literalProp);
43080             });
43081             var indexInfo = type.flags & 4 ? createIndexInfo(emptyObjectType, false) : undefined;
43082             return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfo, undefined);
43083         }
43084         function inferTypeForHomomorphicMappedType(source, target, constraint) {
43085             var key = source.id + "," + target.id + "," + constraint.id;
43086             if (reverseMappedCache.has(key)) {
43087                 return reverseMappedCache.get(key);
43088             }
43089             reverseMappedCache.set(key, undefined);
43090             var type = createReverseMappedType(source, target, constraint);
43091             reverseMappedCache.set(key, type);
43092             return type;
43093         }
43094         function isPartiallyInferableType(type) {
43095             return !(ts.getObjectFlags(type) & 2097152) ||
43096                 isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); });
43097         }
43098         function createReverseMappedType(source, target, constraint) {
43099             if (!(getIndexInfoOfType(source, 0) || getPropertiesOfType(source).length !== 0 && isPartiallyInferableType(source))) {
43100                 return undefined;
43101             }
43102             if (isArrayType(source)) {
43103                 return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source));
43104             }
43105             if (isTupleType(source)) {
43106                 var elementTypes = ts.map(getTypeArguments(source), function (t) { return inferReverseMappedType(t, target, constraint); });
43107                 var minLength = getMappedTypeModifiers(target) & 4 ?
43108                     getTypeReferenceArity(source) - (source.target.hasRestElement ? 1 : 0) : source.target.minLength;
43109                 return createTupleType(elementTypes, minLength, source.target.hasRestElement, source.target.readonly, source.target.associatedNames);
43110             }
43111             var reversed = createObjectType(2048 | 16, undefined);
43112             reversed.source = source;
43113             reversed.mappedType = target;
43114             reversed.constraintType = constraint;
43115             return reversed;
43116         }
43117         function getTypeOfReverseMappedSymbol(symbol) {
43118             return inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType);
43119         }
43120         function inferReverseMappedType(sourceType, target, constraint) {
43121             var typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target));
43122             var templateType = getTemplateTypeFromMappedType(target);
43123             var inference = createInferenceInfo(typeParameter);
43124             inferTypes([inference], sourceType, templateType);
43125             return getTypeFromInference(inference) || unknownType;
43126         }
43127         function getUnmatchedProperties(source, target, requireOptionalProperties, matchDiscriminantProperties) {
43128             var properties, _i, properties_2, targetProp, sourceProp, targetType, sourceType;
43129             return __generator(this, function (_a) {
43130                 switch (_a.label) {
43131                     case 0:
43132                         properties = getPropertiesOfType(target);
43133                         _i = 0, properties_2 = properties;
43134                         _a.label = 1;
43135                     case 1:
43136                         if (!(_i < properties_2.length)) return [3, 6];
43137                         targetProp = properties_2[_i];
43138                         if (isStaticPrivateIdentifierProperty(targetProp)) {
43139                             return [3, 5];
43140                         }
43141                         if (!(requireOptionalProperties || !(targetProp.flags & 16777216 || ts.getCheckFlags(targetProp) & 48))) return [3, 5];
43142                         sourceProp = getPropertyOfType(source, targetProp.escapedName);
43143                         if (!!sourceProp) return [3, 3];
43144                         return [4, targetProp];
43145                     case 2:
43146                         _a.sent();
43147                         return [3, 5];
43148                     case 3:
43149                         if (!matchDiscriminantProperties) return [3, 5];
43150                         targetType = getTypeOfSymbol(targetProp);
43151                         if (!(targetType.flags & 109440)) return [3, 5];
43152                         sourceType = getTypeOfSymbol(sourceProp);
43153                         if (!!(sourceType.flags & 1 || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3, 5];
43154                         return [4, targetProp];
43155                     case 4:
43156                         _a.sent();
43157                         _a.label = 5;
43158                     case 5:
43159                         _i++;
43160                         return [3, 1];
43161                     case 6: return [2];
43162                 }
43163             });
43164         }
43165         function getUnmatchedProperty(source, target, requireOptionalProperties, matchDiscriminantProperties) {
43166             var result = getUnmatchedProperties(source, target, requireOptionalProperties, matchDiscriminantProperties).next();
43167             if (!result.done)
43168                 return result.value;
43169         }
43170         function tupleTypesDefinitelyUnrelated(source, target) {
43171             return target.target.minLength > source.target.minLength ||
43172                 !getRestTypeOfTupleType(target) && (!!getRestTypeOfTupleType(source) || getLengthOfTupleType(target) < getLengthOfTupleType(source));
43173         }
43174         function typesDefinitelyUnrelated(source, target) {
43175             return isTupleType(source) && isTupleType(target) && tupleTypesDefinitelyUnrelated(source, target) ||
43176                 !!getUnmatchedProperty(source, target, false, true) &&
43177                     !!getUnmatchedProperty(target, source, false, true);
43178         }
43179         function getTypeFromInference(inference) {
43180             return inference.candidates ? getUnionType(inference.candidates, 2) :
43181                 inference.contraCandidates ? getIntersectionType(inference.contraCandidates) :
43182                     undefined;
43183         }
43184         function hasSkipDirectInferenceFlag(node) {
43185             return !!getNodeLinks(node).skipDirectInference;
43186         }
43187         function isFromInferenceBlockedSource(type) {
43188             return !!(type.symbol && ts.some(type.symbol.declarations, hasSkipDirectInferenceFlag));
43189         }
43190         function inferTypes(inferences, originalSource, originalTarget, priority, contravariant) {
43191             if (priority === void 0) { priority = 0; }
43192             if (contravariant === void 0) { contravariant = false; }
43193             var symbolOrTypeStack;
43194             var visited;
43195             var bivariant = false;
43196             var propagationType;
43197             var inferencePriority = 512;
43198             var allowComplexConstraintInference = true;
43199             inferFromTypes(originalSource, originalTarget);
43200             function inferFromTypes(source, target) {
43201                 if (!couldContainTypeVariables(target)) {
43202                     return;
43203                 }
43204                 if (source === wildcardType) {
43205                     var savePropagationType = propagationType;
43206                     propagationType = source;
43207                     inferFromTypes(target, target);
43208                     propagationType = savePropagationType;
43209                     return;
43210                 }
43211                 if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) {
43212                     inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol));
43213                     return;
43214                 }
43215                 if (source === target && source.flags & 3145728) {
43216                     for (var _i = 0, _a = source.types; _i < _a.length; _i++) {
43217                         var t = _a[_i];
43218                         inferFromTypes(t, t);
43219                     }
43220                     return;
43221                 }
43222                 if (target.flags & 1048576) {
43223                     var _b = inferFromMatchingTypes(source.flags & 1048576 ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1];
43224                     var _c = inferFromMatchingTypes(tempSources, tempTargets, isTypeCloselyMatchedBy), sources = _c[0], targets = _c[1];
43225                     if (targets.length === 0) {
43226                         return;
43227                     }
43228                     target = getUnionType(targets);
43229                     if (sources.length === 0) {
43230                         inferWithPriority(source, target, 1);
43231                         return;
43232                     }
43233                     source = getUnionType(sources);
43234                 }
43235                 else if (target.flags & 2097152 && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) {
43236                     if (!(source.flags & 1048576)) {
43237                         var _d = inferFromMatchingTypes(source.flags & 2097152 ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1];
43238                         if (sources.length === 0 || targets.length === 0) {
43239                             return;
43240                         }
43241                         source = getIntersectionType(sources);
43242                         target = getIntersectionType(targets);
43243                     }
43244                 }
43245                 else if (target.flags & (8388608 | 33554432)) {
43246                     target = getActualTypeVariable(target);
43247                 }
43248                 if (target.flags & 8650752) {
43249                     if (ts.getObjectFlags(source) & 2097152 || source === nonInferrableAnyType || source === silentNeverType ||
43250                         (priority & 32 && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) {
43251                         return;
43252                     }
43253                     var inference = getInferenceInfoForType(target);
43254                     if (inference) {
43255                         if (!inference.isFixed) {
43256                             if (inference.priority === undefined || priority < inference.priority) {
43257                                 inference.candidates = undefined;
43258                                 inference.contraCandidates = undefined;
43259                                 inference.topLevel = true;
43260                                 inference.priority = priority;
43261                             }
43262                             if (priority === inference.priority) {
43263                                 var candidate = propagationType || source;
43264                                 if (contravariant && !bivariant) {
43265                                     if (!ts.contains(inference.contraCandidates, candidate)) {
43266                                         inference.contraCandidates = ts.append(inference.contraCandidates, candidate);
43267                                         clearCachedInferences(inferences);
43268                                     }
43269                                 }
43270                                 else if (!ts.contains(inference.candidates, candidate)) {
43271                                     inference.candidates = ts.append(inference.candidates, candidate);
43272                                     clearCachedInferences(inferences);
43273                                 }
43274                             }
43275                             if (!(priority & 32) && target.flags & 262144 && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) {
43276                                 inference.topLevel = false;
43277                                 clearCachedInferences(inferences);
43278                             }
43279                         }
43280                         inferencePriority = Math.min(inferencePriority, priority);
43281                         return;
43282                     }
43283                     else {
43284                         var simplified = getSimplifiedType(target, false);
43285                         if (simplified !== target) {
43286                             invokeOnce(source, simplified, inferFromTypes);
43287                         }
43288                         else if (target.flags & 8388608) {
43289                             var indexType = getSimplifiedType(target.indexType, false);
43290                             if (indexType.flags & 63176704) {
43291                                 var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, false), indexType, false);
43292                                 if (simplified_1 && simplified_1 !== target) {
43293                                     invokeOnce(source, simplified_1, inferFromTypes);
43294                                 }
43295                             }
43296                         }
43297                     }
43298                 }
43299                 if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && (source.target === target.target || isArrayType(source) && isArrayType(target)) &&
43300                     !(source.node && target.node)) {
43301                     inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
43302                 }
43303                 else if (source.flags & 4194304 && target.flags & 4194304) {
43304                     contravariant = !contravariant;
43305                     inferFromTypes(source.type, target.type);
43306                     contravariant = !contravariant;
43307                 }
43308                 else if ((isLiteralType(source) || source.flags & 4) && target.flags & 4194304) {
43309                     var empty = createEmptyObjectTypeFromStringLiteral(source);
43310                     contravariant = !contravariant;
43311                     inferWithPriority(empty, target.type, 64);
43312                     contravariant = !contravariant;
43313                 }
43314                 else if (source.flags & 8388608 && target.flags & 8388608) {
43315                     inferFromTypes(source.objectType, target.objectType);
43316                     inferFromTypes(source.indexType, target.indexType);
43317                 }
43318                 else if (source.flags & 16777216 && target.flags & 16777216) {
43319                     inferFromTypes(source.checkType, target.checkType);
43320                     inferFromTypes(source.extendsType, target.extendsType);
43321                     inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target));
43322                     inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target));
43323                 }
43324                 else if (target.flags & 16777216) {
43325                     var savePriority = priority;
43326                     priority |= contravariant ? 16 : 0;
43327                     var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)];
43328                     inferToMultipleTypes(source, targetTypes, target.flags);
43329                     priority = savePriority;
43330                 }
43331                 else if (target.flags & 3145728) {
43332                     inferToMultipleTypes(source, target.types, target.flags);
43333                 }
43334                 else if (source.flags & 1048576) {
43335                     var sourceTypes = source.types;
43336                     for (var _e = 0, sourceTypes_2 = sourceTypes; _e < sourceTypes_2.length; _e++) {
43337                         var sourceType = sourceTypes_2[_e];
43338                         inferFromTypes(sourceType, target);
43339                     }
43340                 }
43341                 else {
43342                     source = getReducedType(source);
43343                     if (!(priority & 128 && source.flags & (2097152 | 63176704))) {
43344                         var apparentSource = getApparentType(source);
43345                         if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 | 2097152))) {
43346                             allowComplexConstraintInference = false;
43347                             return inferFromTypes(apparentSource, target);
43348                         }
43349                         source = apparentSource;
43350                     }
43351                     if (source.flags & (524288 | 2097152)) {
43352                         invokeOnce(source, target, inferFromObjectTypes);
43353                     }
43354                 }
43355                 if (source.flags & 25165824) {
43356                     var simplified = getSimplifiedType(source, contravariant);
43357                     if (simplified !== source) {
43358                         inferFromTypes(simplified, target);
43359                     }
43360                 }
43361             }
43362             function inferWithPriority(source, target, newPriority) {
43363                 var savePriority = priority;
43364                 priority |= newPriority;
43365                 inferFromTypes(source, target);
43366                 priority = savePriority;
43367             }
43368             function invokeOnce(source, target, action) {
43369                 var key = source.id + "," + target.id;
43370                 var status = visited && visited.get(key);
43371                 if (status !== undefined) {
43372                     inferencePriority = Math.min(inferencePriority, status);
43373                     return;
43374                 }
43375                 (visited || (visited = ts.createMap())).set(key, -1);
43376                 var saveInferencePriority = inferencePriority;
43377                 inferencePriority = 512;
43378                 action(source, target);
43379                 visited.set(key, inferencePriority);
43380                 inferencePriority = Math.min(inferencePriority, saveInferencePriority);
43381             }
43382             function inferFromMatchingTypes(sources, targets, matches) {
43383                 var matchedSources;
43384                 var matchedTargets;
43385                 for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) {
43386                     var t = targets_1[_i];
43387                     for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) {
43388                         var s = sources_1[_a];
43389                         if (matches(s, t)) {
43390                             inferFromTypes(s, t);
43391                             matchedSources = ts.appendIfUnique(matchedSources, s);
43392                             matchedTargets = ts.appendIfUnique(matchedTargets, t);
43393                         }
43394                     }
43395                 }
43396                 return [
43397                     matchedSources ? ts.filter(sources, function (t) { return !ts.contains(matchedSources, t); }) : sources,
43398                     matchedTargets ? ts.filter(targets, function (t) { return !ts.contains(matchedTargets, t); }) : targets,
43399                 ];
43400             }
43401             function inferFromTypeArguments(sourceTypes, targetTypes, variances) {
43402                 var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length;
43403                 for (var i = 0; i < count; i++) {
43404                     if (i < variances.length && (variances[i] & 7) === 2) {
43405                         inferFromContravariantTypes(sourceTypes[i], targetTypes[i]);
43406                     }
43407                     else {
43408                         inferFromTypes(sourceTypes[i], targetTypes[i]);
43409                     }
43410                 }
43411             }
43412             function inferFromContravariantTypes(source, target) {
43413                 if (strictFunctionTypes || priority & 256) {
43414                     contravariant = !contravariant;
43415                     inferFromTypes(source, target);
43416                     contravariant = !contravariant;
43417                 }
43418                 else {
43419                     inferFromTypes(source, target);
43420                 }
43421             }
43422             function getInferenceInfoForType(type) {
43423                 if (type.flags & 8650752) {
43424                     for (var _i = 0, inferences_2 = inferences; _i < inferences_2.length; _i++) {
43425                         var inference = inferences_2[_i];
43426                         if (type === inference.typeParameter) {
43427                             return inference;
43428                         }
43429                     }
43430                 }
43431                 return undefined;
43432             }
43433             function getSingleTypeVariableFromIntersectionTypes(types) {
43434                 var typeVariable;
43435                 for (var _i = 0, types_14 = types; _i < types_14.length; _i++) {
43436                     var type = types_14[_i];
43437                     var t = type.flags & 2097152 && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); });
43438                     if (!t || typeVariable && t !== typeVariable) {
43439                         return undefined;
43440                     }
43441                     typeVariable = t;
43442                 }
43443                 return typeVariable;
43444             }
43445             function inferToMultipleTypes(source, targets, targetFlags) {
43446                 var typeVariableCount = 0;
43447                 if (targetFlags & 1048576) {
43448                     var nakedTypeVariable = void 0;
43449                     var sources = source.flags & 1048576 ? source.types : [source];
43450                     var matched_1 = new Array(sources.length);
43451                     var inferenceCircularity = false;
43452                     for (var _i = 0, targets_2 = targets; _i < targets_2.length; _i++) {
43453                         var t = targets_2[_i];
43454                         if (getInferenceInfoForType(t)) {
43455                             nakedTypeVariable = t;
43456                             typeVariableCount++;
43457                         }
43458                         else {
43459                             for (var i = 0; i < sources.length; i++) {
43460                                 var saveInferencePriority = inferencePriority;
43461                                 inferencePriority = 512;
43462                                 inferFromTypes(sources[i], t);
43463                                 if (inferencePriority === priority)
43464                                     matched_1[i] = true;
43465                                 inferenceCircularity = inferenceCircularity || inferencePriority === -1;
43466                                 inferencePriority = Math.min(inferencePriority, saveInferencePriority);
43467                             }
43468                         }
43469                     }
43470                     if (typeVariableCount === 0) {
43471                         var intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets);
43472                         if (intersectionTypeVariable) {
43473                             inferWithPriority(source, intersectionTypeVariable, 1);
43474                         }
43475                         return;
43476                     }
43477                     if (typeVariableCount === 1 && !inferenceCircularity) {
43478                         var unmatched = ts.flatMap(sources, function (s, i) { return matched_1[i] ? undefined : s; });
43479                         if (unmatched.length) {
43480                             inferFromTypes(getUnionType(unmatched), nakedTypeVariable);
43481                             return;
43482                         }
43483                     }
43484                 }
43485                 else {
43486                     for (var _a = 0, targets_3 = targets; _a < targets_3.length; _a++) {
43487                         var t = targets_3[_a];
43488                         if (getInferenceInfoForType(t)) {
43489                             typeVariableCount++;
43490                         }
43491                         else {
43492                             inferFromTypes(source, t);
43493                         }
43494                     }
43495                 }
43496                 if (targetFlags & 2097152 ? typeVariableCount === 1 : typeVariableCount > 0) {
43497                     for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) {
43498                         var t = targets_4[_b];
43499                         if (getInferenceInfoForType(t)) {
43500                             inferWithPriority(source, t, 1);
43501                         }
43502                     }
43503                 }
43504             }
43505             function inferToMappedType(source, target, constraintType) {
43506                 if (constraintType.flags & 1048576) {
43507                     var result = false;
43508                     for (var _i = 0, _a = constraintType.types; _i < _a.length; _i++) {
43509                         var type = _a[_i];
43510                         result = inferToMappedType(source, target, type) || result;
43511                     }
43512                     return result;
43513                 }
43514                 if (constraintType.flags & 4194304) {
43515                     var inference = getInferenceInfoForType(constraintType.type);
43516                     if (inference && !inference.isFixed && !isFromInferenceBlockedSource(source)) {
43517                         var inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType);
43518                         if (inferredType) {
43519                             inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 2097152 ?
43520                                 4 :
43521                                 2);
43522                         }
43523                     }
43524                     return true;
43525                 }
43526                 if (constraintType.flags & 262144) {
43527                     inferWithPriority(getIndexType(source), constraintType, 8);
43528                     var extendedConstraint = getConstraintOfType(constraintType);
43529                     if (extendedConstraint && inferToMappedType(source, target, extendedConstraint)) {
43530                         return true;
43531                     }
43532                     var propTypes = ts.map(getPropertiesOfType(source), getTypeOfSymbol);
43533                     var stringIndexType = getIndexTypeOfType(source, 0);
43534                     var numberIndexInfo = getNonEnumNumberIndexInfo(source);
43535                     var numberIndexType = numberIndexInfo && numberIndexInfo.type;
43536                     inferFromTypes(getUnionType(ts.append(ts.append(propTypes, stringIndexType), numberIndexType)), getTemplateTypeFromMappedType(target));
43537                     return true;
43538                 }
43539                 return false;
43540             }
43541             function inferFromObjectTypes(source, target) {
43542                 var isNonConstructorObject = target.flags & 524288 &&
43543                     !(ts.getObjectFlags(target) & 16 && target.symbol && target.symbol.flags & 32);
43544                 var symbolOrType = isNonConstructorObject ? isTupleType(target) ? target.target : target.symbol : undefined;
43545                 if (symbolOrType) {
43546                     if (ts.contains(symbolOrTypeStack, symbolOrType)) {
43547                         inferencePriority = -1;
43548                         return;
43549                     }
43550                     (symbolOrTypeStack || (symbolOrTypeStack = [])).push(symbolOrType);
43551                     inferFromObjectTypesWorker(source, target);
43552                     symbolOrTypeStack.pop();
43553                 }
43554                 else {
43555                     inferFromObjectTypesWorker(source, target);
43556                 }
43557             }
43558             function inferFromObjectTypesWorker(source, target) {
43559                 if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && (source.target === target.target || isArrayType(source) && isArrayType(target))) {
43560                     inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
43561                     return;
43562                 }
43563                 if (isGenericMappedType(source) && isGenericMappedType(target)) {
43564                     inferFromTypes(getConstraintTypeFromMappedType(source), getConstraintTypeFromMappedType(target));
43565                     inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target));
43566                 }
43567                 if (ts.getObjectFlags(target) & 32) {
43568                     var constraintType = getConstraintTypeFromMappedType(target);
43569                     if (inferToMappedType(source, target, constraintType)) {
43570                         return;
43571                     }
43572                 }
43573                 if (!typesDefinitelyUnrelated(source, target)) {
43574                     if (isArrayType(source) || isTupleType(source)) {
43575                         if (isTupleType(target)) {
43576                             var sourceLength = isTupleType(source) ? getLengthOfTupleType(source) : 0;
43577                             var targetLength = getLengthOfTupleType(target);
43578                             var sourceRestType = isTupleType(source) ? getRestTypeOfTupleType(source) : getElementTypeOfArrayType(source);
43579                             var targetRestType = getRestTypeOfTupleType(target);
43580                             var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength;
43581                             for (var i = 0; i < fixedLength; i++) {
43582                                 inferFromTypes(i < sourceLength ? getTypeArguments(source)[i] : sourceRestType, getTypeArguments(target)[i]);
43583                             }
43584                             if (targetRestType) {
43585                                 var types = fixedLength < sourceLength ? getTypeArguments(source).slice(fixedLength, sourceLength) : [];
43586                                 if (sourceRestType) {
43587                                     types.push(sourceRestType);
43588                                 }
43589                                 if (types.length) {
43590                                     inferFromTypes(getUnionType(types), targetRestType);
43591                                 }
43592                             }
43593                             return;
43594                         }
43595                         if (isArrayType(target)) {
43596                             inferFromIndexTypes(source, target);
43597                             return;
43598                         }
43599                     }
43600                     inferFromProperties(source, target);
43601                     inferFromSignatures(source, target, 0);
43602                     inferFromSignatures(source, target, 1);
43603                     inferFromIndexTypes(source, target);
43604                 }
43605             }
43606             function inferFromProperties(source, target) {
43607                 var properties = getPropertiesOfObjectType(target);
43608                 for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) {
43609                     var targetProp = properties_3[_i];
43610                     var sourceProp = getPropertyOfType(source, targetProp.escapedName);
43611                     if (sourceProp) {
43612                         inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
43613                     }
43614                 }
43615             }
43616             function inferFromSignatures(source, target, kind) {
43617                 var sourceSignatures = getSignaturesOfType(source, kind);
43618                 var targetSignatures = getSignaturesOfType(target, kind);
43619                 var sourceLen = sourceSignatures.length;
43620                 var targetLen = targetSignatures.length;
43621                 var len = sourceLen < targetLen ? sourceLen : targetLen;
43622                 var skipParameters = !!(ts.getObjectFlags(source) & 2097152);
43623                 for (var i = 0; i < len; i++) {
43624                     inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters);
43625                 }
43626             }
43627             function inferFromSignature(source, target, skipParameters) {
43628                 if (!skipParameters) {
43629                     var saveBivariant = bivariant;
43630                     var kind = target.declaration ? target.declaration.kind : 0;
43631                     bivariant = bivariant || kind === 161 || kind === 160 || kind === 162;
43632                     applyToParameterTypes(source, target, inferFromContravariantTypes);
43633                     bivariant = saveBivariant;
43634                 }
43635                 applyToReturnTypes(source, target, inferFromTypes);
43636             }
43637             function inferFromIndexTypes(source, target) {
43638                 var targetStringIndexType = getIndexTypeOfType(target, 0);
43639                 if (targetStringIndexType) {
43640                     var sourceIndexType = getIndexTypeOfType(source, 0) ||
43641                         getImplicitIndexTypeOfType(source, 0);
43642                     if (sourceIndexType) {
43643                         inferFromTypes(sourceIndexType, targetStringIndexType);
43644                     }
43645                 }
43646                 var targetNumberIndexType = getIndexTypeOfType(target, 1);
43647                 if (targetNumberIndexType) {
43648                     var sourceIndexType = getIndexTypeOfType(source, 1) ||
43649                         getIndexTypeOfType(source, 0) ||
43650                         getImplicitIndexTypeOfType(source, 1);
43651                     if (sourceIndexType) {
43652                         inferFromTypes(sourceIndexType, targetNumberIndexType);
43653                     }
43654                 }
43655             }
43656         }
43657         function isTypeOrBaseIdenticalTo(s, t) {
43658             return isTypeIdenticalTo(s, t) || !!(t.flags & 4 && s.flags & 128 || t.flags & 8 && s.flags & 256);
43659         }
43660         function isTypeCloselyMatchedBy(s, t) {
43661             return !!(s.flags & 524288 && t.flags & 524288 && s.symbol && s.symbol === t.symbol ||
43662                 s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol);
43663         }
43664         function hasPrimitiveConstraint(type) {
43665             var constraint = getConstraintOfTypeParameter(type);
43666             return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 | 4194304);
43667         }
43668         function isObjectLiteralType(type) {
43669             return !!(ts.getObjectFlags(type) & 128);
43670         }
43671         function isObjectOrArrayLiteralType(type) {
43672             return !!(ts.getObjectFlags(type) & (128 | 65536));
43673         }
43674         function unionObjectAndArrayLiteralCandidates(candidates) {
43675             if (candidates.length > 1) {
43676                 var objectLiterals = ts.filter(candidates, isObjectOrArrayLiteralType);
43677                 if (objectLiterals.length) {
43678                     var literalsType = getUnionType(objectLiterals, 2);
43679                     return ts.concatenate(ts.filter(candidates, function (t) { return !isObjectOrArrayLiteralType(t); }), [literalsType]);
43680                 }
43681             }
43682             return candidates;
43683         }
43684         function getContravariantInference(inference) {
43685             return inference.priority & 104 ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates);
43686         }
43687         function getCovariantInference(inference, signature) {
43688             var candidates = unionObjectAndArrayLiteralCandidates(inference.candidates);
43689             var primitiveConstraint = hasPrimitiveConstraint(inference.typeParameter);
43690             var widenLiteralTypes = !primitiveConstraint && inference.topLevel &&
43691                 (inference.isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), inference.typeParameter));
43692             var baseCandidates = primitiveConstraint ? ts.sameMap(candidates, getRegularTypeOfLiteralType) :
43693                 widenLiteralTypes ? ts.sameMap(candidates, getWidenedLiteralType) :
43694                     candidates;
43695             var unwidenedType = inference.priority & 104 ?
43696                 getUnionType(baseCandidates, 2) :
43697                 getCommonSupertype(baseCandidates);
43698             return getWidenedType(unwidenedType);
43699         }
43700         function getInferredType(context, index) {
43701             var inference = context.inferences[index];
43702             if (!inference.inferredType) {
43703                 var inferredType = void 0;
43704                 var signature = context.signature;
43705                 if (signature) {
43706                     var inferredCovariantType = inference.candidates ? getCovariantInference(inference, signature) : undefined;
43707                     if (inference.contraCandidates) {
43708                         var inferredContravariantType = getContravariantInference(inference);
43709                         inferredType = inferredCovariantType && !(inferredCovariantType.flags & 131072) &&
43710                             isTypeSubtypeOf(inferredCovariantType, inferredContravariantType) ?
43711                             inferredCovariantType : inferredContravariantType;
43712                     }
43713                     else if (inferredCovariantType) {
43714                         inferredType = inferredCovariantType;
43715                     }
43716                     else if (context.flags & 1) {
43717                         inferredType = silentNeverType;
43718                     }
43719                     else {
43720                         var defaultType = getDefaultFromTypeParameter(inference.typeParameter);
43721                         if (defaultType) {
43722                             inferredType = instantiateType(defaultType, mergeTypeMappers(createBackreferenceMapper(context, index), context.nonFixingMapper));
43723                         }
43724                     }
43725                 }
43726                 else {
43727                     inferredType = getTypeFromInference(inference);
43728                 }
43729                 inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2));
43730                 var constraint = getConstraintOfTypeParameter(inference.typeParameter);
43731                 if (constraint) {
43732                     var instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
43733                     if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
43734                         inference.inferredType = inferredType = instantiatedConstraint;
43735                     }
43736                 }
43737             }
43738             return inference.inferredType;
43739         }
43740         function getDefaultTypeArgumentType(isInJavaScriptFile) {
43741             return isInJavaScriptFile ? anyType : unknownType;
43742         }
43743         function getInferredTypes(context) {
43744             var result = [];
43745             for (var i = 0; i < context.inferences.length; i++) {
43746                 result.push(getInferredType(context, i));
43747             }
43748             return result;
43749         }
43750         function getCannotFindNameDiagnosticForName(node) {
43751             switch (node.escapedText) {
43752                 case "document":
43753                 case "console":
43754                     return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom;
43755                 case "$":
43756                     return compilerOptions.types
43757                         ? 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
43758                         : ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery;
43759                 case "describe":
43760                 case "suite":
43761                 case "it":
43762                 case "test":
43763                     return compilerOptions.types
43764                         ? 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
43765                         : 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;
43766                 case "process":
43767                 case "require":
43768                 case "Buffer":
43769                 case "module":
43770                     return compilerOptions.types
43771                         ? 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
43772                         : ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode;
43773                 case "Map":
43774                 case "Set":
43775                 case "Promise":
43776                 case "Symbol":
43777                 case "WeakMap":
43778                 case "WeakSet":
43779                 case "Iterator":
43780                 case "AsyncIterator":
43781                     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;
43782                 default:
43783                     if (node.parent.kind === 282) {
43784                         return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer;
43785                     }
43786                     else {
43787                         return ts.Diagnostics.Cannot_find_name_0;
43788                     }
43789             }
43790         }
43791         function getResolvedSymbol(node) {
43792             var links = getNodeLinks(node);
43793             if (!links.resolvedSymbol) {
43794                 links.resolvedSymbol = !ts.nodeIsMissing(node) &&
43795                     resolveName(node, node.escapedText, 111551 | 1048576, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), false, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol;
43796             }
43797             return links.resolvedSymbol;
43798         }
43799         function isInTypeQuery(node) {
43800             return !!ts.findAncestor(node, function (n) { return n.kind === 172 ? true : n.kind === 75 || n.kind === 153 ? false : "quit"; });
43801         }
43802         function getFlowCacheKey(node, declaredType, initialType, flowContainer) {
43803             switch (node.kind) {
43804                 case 75:
43805                     var symbol = getResolvedSymbol(node);
43806                     return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined;
43807                 case 104:
43808                     return "0";
43809                 case 218:
43810                 case 200:
43811                     return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
43812                 case 194:
43813                 case 195:
43814                     var propName = getAccessedPropertyName(node);
43815                     if (propName !== undefined) {
43816                         var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
43817                         return key && key + "." + propName;
43818                     }
43819             }
43820             return undefined;
43821         }
43822         function isMatchingReference(source, target) {
43823             switch (target.kind) {
43824                 case 200:
43825                 case 218:
43826                     return isMatchingReference(source, target.expression);
43827             }
43828             switch (source.kind) {
43829                 case 75:
43830                     return target.kind === 75 && getResolvedSymbol(source) === getResolvedSymbol(target) ||
43831                         (target.kind === 242 || target.kind === 191) &&
43832                             getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target);
43833                 case 104:
43834                     return target.kind === 104;
43835                 case 102:
43836                     return target.kind === 102;
43837                 case 218:
43838                 case 200:
43839                     return isMatchingReference(source.expression, target);
43840                 case 194:
43841                 case 195:
43842                     return ts.isAccessExpression(target) &&
43843                         getAccessedPropertyName(source) === getAccessedPropertyName(target) &&
43844                         isMatchingReference(source.expression, target.expression);
43845             }
43846             return false;
43847         }
43848         function containsTruthyCheck(source, target) {
43849             return isMatchingReference(source, target) ||
43850                 (target.kind === 209 && target.operatorToken.kind === 55 &&
43851                     (containsTruthyCheck(source, target.left) || containsTruthyCheck(source, target.right)));
43852         }
43853         function getAccessedPropertyName(access) {
43854             return access.kind === 194 ? access.name.escapedText :
43855                 ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) :
43856                     undefined;
43857         }
43858         function containsMatchingReference(source, target) {
43859             while (ts.isAccessExpression(source)) {
43860                 source = source.expression;
43861                 if (isMatchingReference(source, target)) {
43862                     return true;
43863                 }
43864             }
43865             return false;
43866         }
43867         function optionalChainContainsReference(source, target) {
43868             while (ts.isOptionalChain(source)) {
43869                 source = source.expression;
43870                 if (isMatchingReference(source, target)) {
43871                     return true;
43872                 }
43873             }
43874             return false;
43875         }
43876         function isDiscriminantProperty(type, name) {
43877             if (type && type.flags & 1048576) {
43878                 var prop = getUnionOrIntersectionProperty(type, name);
43879                 if (prop && ts.getCheckFlags(prop) & 2) {
43880                     if (prop.isDiscriminantProperty === undefined) {
43881                         prop.isDiscriminantProperty =
43882                             (prop.checkFlags & 192) === 192 &&
43883                                 !maybeTypeOfKind(getTypeOfSymbol(prop), 63176704);
43884                     }
43885                     return !!prop.isDiscriminantProperty;
43886                 }
43887             }
43888             return false;
43889         }
43890         function findDiscriminantProperties(sourceProperties, target) {
43891             var result;
43892             for (var _i = 0, sourceProperties_2 = sourceProperties; _i < sourceProperties_2.length; _i++) {
43893                 var sourceProperty = sourceProperties_2[_i];
43894                 if (isDiscriminantProperty(target, sourceProperty.escapedName)) {
43895                     if (result) {
43896                         result.push(sourceProperty);
43897                         continue;
43898                     }
43899                     result = [sourceProperty];
43900                 }
43901             }
43902             return result;
43903         }
43904         function isOrContainsMatchingReference(source, target) {
43905             return isMatchingReference(source, target) || containsMatchingReference(source, target);
43906         }
43907         function hasMatchingArgument(callExpression, reference) {
43908             if (callExpression.arguments) {
43909                 for (var _i = 0, _a = callExpression.arguments; _i < _a.length; _i++) {
43910                     var argument = _a[_i];
43911                     if (isOrContainsMatchingReference(reference, argument)) {
43912                         return true;
43913                     }
43914                 }
43915             }
43916             if (callExpression.expression.kind === 194 &&
43917                 isOrContainsMatchingReference(reference, callExpression.expression.expression)) {
43918                 return true;
43919             }
43920             return false;
43921         }
43922         function getFlowNodeId(flow) {
43923             if (!flow.id || flow.id < 0) {
43924                 flow.id = nextFlowId;
43925                 nextFlowId++;
43926             }
43927             return flow.id;
43928         }
43929         function typeMaybeAssignableTo(source, target) {
43930             if (!(source.flags & 1048576)) {
43931                 return isTypeAssignableTo(source, target);
43932             }
43933             for (var _i = 0, _a = source.types; _i < _a.length; _i++) {
43934                 var t = _a[_i];
43935                 if (isTypeAssignableTo(t, target)) {
43936                     return true;
43937                 }
43938             }
43939             return false;
43940         }
43941         function getAssignmentReducedType(declaredType, assignedType) {
43942             if (declaredType !== assignedType) {
43943                 if (assignedType.flags & 131072) {
43944                     return assignedType;
43945                 }
43946                 var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); });
43947                 if (assignedType.flags & 512 && isFreshLiteralType(assignedType)) {
43948                     reducedType = mapType(reducedType, getFreshTypeOfLiteralType);
43949                 }
43950                 if (isTypeAssignableTo(assignedType, reducedType)) {
43951                     return reducedType;
43952                 }
43953             }
43954             return declaredType;
43955         }
43956         function getTypeFactsOfTypes(types) {
43957             var result = 0;
43958             for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
43959                 var t = types_15[_i];
43960                 result |= getTypeFacts(t);
43961             }
43962             return result;
43963         }
43964         function isFunctionObjectType(type) {
43965             var resolved = resolveStructuredTypeMembers(type);
43966             return !!(resolved.callSignatures.length || resolved.constructSignatures.length ||
43967                 resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType));
43968         }
43969         function getTypeFacts(type) {
43970             var flags = type.flags;
43971             if (flags & 4) {
43972                 return strictNullChecks ? 16317953 : 16776705;
43973             }
43974             if (flags & 128) {
43975                 var isEmpty = type.value === "";
43976                 return strictNullChecks ?
43977                     isEmpty ? 12123649 : 7929345 :
43978                     isEmpty ? 12582401 : 16776705;
43979             }
43980             if (flags & (8 | 32)) {
43981                 return strictNullChecks ? 16317698 : 16776450;
43982             }
43983             if (flags & 256) {
43984                 var isZero = type.value === 0;
43985                 return strictNullChecks ?
43986                     isZero ? 12123394 : 7929090 :
43987                     isZero ? 12582146 : 16776450;
43988             }
43989             if (flags & 64) {
43990                 return strictNullChecks ? 16317188 : 16775940;
43991             }
43992             if (flags & 2048) {
43993                 var isZero = isZeroBigInt(type);
43994                 return strictNullChecks ?
43995                     isZero ? 12122884 : 7928580 :
43996                     isZero ? 12581636 : 16775940;
43997             }
43998             if (flags & 16) {
43999                 return strictNullChecks ? 16316168 : 16774920;
44000             }
44001             if (flags & 528) {
44002                 return strictNullChecks ?
44003                     (type === falseType || type === regularFalseType) ? 12121864 : 7927560 :
44004                     (type === falseType || type === regularFalseType) ? 12580616 : 16774920;
44005             }
44006             if (flags & 524288) {
44007                 return ts.getObjectFlags(type) & 16 && isEmptyObjectType(type) ?
44008                     strictNullChecks ? 16318463 : 16777215 :
44009                     isFunctionObjectType(type) ?
44010                         strictNullChecks ? 7880640 : 16728000 :
44011                         strictNullChecks ? 7888800 : 16736160;
44012             }
44013             if (flags & (16384 | 32768)) {
44014                 return 9830144;
44015             }
44016             if (flags & 65536) {
44017                 return 9363232;
44018             }
44019             if (flags & 12288) {
44020                 return strictNullChecks ? 7925520 : 16772880;
44021             }
44022             if (flags & 67108864) {
44023                 return strictNullChecks ? 7888800 : 16736160;
44024             }
44025             if (flags & 131072) {
44026                 return 0;
44027             }
44028             if (flags & 63176704) {
44029                 return getTypeFacts(getBaseConstraintOfType(type) || unknownType);
44030             }
44031             if (flags & 3145728) {
44032                 return getTypeFactsOfTypes(type.types);
44033             }
44034             return 16777215;
44035         }
44036         function getTypeWithFacts(type, include) {
44037             return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
44038         }
44039         function getTypeWithDefault(type, defaultExpression) {
44040             if (defaultExpression) {
44041                 var defaultType = getTypeOfExpression(defaultExpression);
44042                 return getUnionType([getTypeWithFacts(type, 524288), defaultType]);
44043             }
44044             return type;
44045         }
44046         function getTypeOfDestructuredProperty(type, name) {
44047             var nameType = getLiteralTypeFromPropertyName(name);
44048             if (!isTypeUsableAsPropertyName(nameType))
44049                 return errorType;
44050             var text = getPropertyNameFromType(nameType);
44051             return getConstraintForLocation(getTypeOfPropertyOfType(type, text), name) ||
44052                 isNumericLiteralName(text) && getIndexTypeOfType(type, 1) ||
44053                 getIndexTypeOfType(type, 0) ||
44054                 errorType;
44055         }
44056         function getTypeOfDestructuredArrayElement(type, index) {
44057             return everyType(type, isTupleLikeType) && getTupleElementType(type, index) ||
44058                 checkIteratedTypeOrElementType(65, type, undefinedType, undefined) ||
44059                 errorType;
44060         }
44061         function getTypeOfDestructuredSpreadExpression(type) {
44062             return createArrayType(checkIteratedTypeOrElementType(65, type, undefinedType, undefined) || errorType);
44063         }
44064         function getAssignedTypeOfBinaryExpression(node) {
44065             var isDestructuringDefaultAssignment = node.parent.kind === 192 && isDestructuringAssignmentTarget(node.parent) ||
44066                 node.parent.kind === 281 && isDestructuringAssignmentTarget(node.parent.parent);
44067             return isDestructuringDefaultAssignment ?
44068                 getTypeWithDefault(getAssignedType(node), node.right) :
44069                 getTypeOfExpression(node.right);
44070         }
44071         function isDestructuringAssignmentTarget(parent) {
44072             return parent.parent.kind === 209 && parent.parent.left === parent ||
44073                 parent.parent.kind === 232 && parent.parent.initializer === parent;
44074         }
44075         function getAssignedTypeOfArrayLiteralElement(node, element) {
44076             return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element));
44077         }
44078         function getAssignedTypeOfSpreadExpression(node) {
44079             return getTypeOfDestructuredSpreadExpression(getAssignedType(node.parent));
44080         }
44081         function getAssignedTypeOfPropertyAssignment(node) {
44082             return getTypeOfDestructuredProperty(getAssignedType(node.parent), node.name);
44083         }
44084         function getAssignedTypeOfShorthandPropertyAssignment(node) {
44085             return getTypeWithDefault(getAssignedTypeOfPropertyAssignment(node), node.objectAssignmentInitializer);
44086         }
44087         function getAssignedType(node) {
44088             var parent = node.parent;
44089             switch (parent.kind) {
44090                 case 231:
44091                     return stringType;
44092                 case 232:
44093                     return checkRightHandSideOfForOf(parent) || errorType;
44094                 case 209:
44095                     return getAssignedTypeOfBinaryExpression(parent);
44096                 case 203:
44097                     return undefinedType;
44098                 case 192:
44099                     return getAssignedTypeOfArrayLiteralElement(parent, node);
44100                 case 213:
44101                     return getAssignedTypeOfSpreadExpression(parent);
44102                 case 281:
44103                     return getAssignedTypeOfPropertyAssignment(parent);
44104                 case 282:
44105                     return getAssignedTypeOfShorthandPropertyAssignment(parent);
44106             }
44107             return errorType;
44108         }
44109         function getInitialTypeOfBindingElement(node) {
44110             var pattern = node.parent;
44111             var parentType = getInitialType(pattern.parent);
44112             var type = pattern.kind === 189 ?
44113                 getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) :
44114                 !node.dotDotDotToken ?
44115                     getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) :
44116                     getTypeOfDestructuredSpreadExpression(parentType);
44117             return getTypeWithDefault(type, node.initializer);
44118         }
44119         function getTypeOfInitializer(node) {
44120             var links = getNodeLinks(node);
44121             return links.resolvedType || getTypeOfExpression(node);
44122         }
44123         function getInitialTypeOfVariableDeclaration(node) {
44124             if (node.initializer) {
44125                 return getTypeOfInitializer(node.initializer);
44126             }
44127             if (node.parent.parent.kind === 231) {
44128                 return stringType;
44129             }
44130             if (node.parent.parent.kind === 232) {
44131                 return checkRightHandSideOfForOf(node.parent.parent) || errorType;
44132             }
44133             return errorType;
44134         }
44135         function getInitialType(node) {
44136             return node.kind === 242 ?
44137                 getInitialTypeOfVariableDeclaration(node) :
44138                 getInitialTypeOfBindingElement(node);
44139         }
44140         function isEmptyArrayAssignment(node) {
44141             return node.kind === 242 && node.initializer &&
44142                 isEmptyArrayLiteral(node.initializer) ||
44143                 node.kind !== 191 && node.parent.kind === 209 &&
44144                     isEmptyArrayLiteral(node.parent.right);
44145         }
44146         function getReferenceCandidate(node) {
44147             switch (node.kind) {
44148                 case 200:
44149                     return getReferenceCandidate(node.expression);
44150                 case 209:
44151                     switch (node.operatorToken.kind) {
44152                         case 62:
44153                             return getReferenceCandidate(node.left);
44154                         case 27:
44155                             return getReferenceCandidate(node.right);
44156                     }
44157             }
44158             return node;
44159         }
44160         function getReferenceRoot(node) {
44161             var parent = node.parent;
44162             return parent.kind === 200 ||
44163                 parent.kind === 209 && parent.operatorToken.kind === 62 && parent.left === node ||
44164                 parent.kind === 209 && parent.operatorToken.kind === 27 && parent.right === node ?
44165                 getReferenceRoot(parent) : node;
44166         }
44167         function getTypeOfSwitchClause(clause) {
44168             if (clause.kind === 277) {
44169                 return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression));
44170             }
44171             return neverType;
44172         }
44173         function getSwitchClauseTypes(switchStatement) {
44174             var links = getNodeLinks(switchStatement);
44175             if (!links.switchTypes) {
44176                 links.switchTypes = [];
44177                 for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) {
44178                     var clause = _a[_i];
44179                     links.switchTypes.push(getTypeOfSwitchClause(clause));
44180                 }
44181             }
44182             return links.switchTypes;
44183         }
44184         function getSwitchClauseTypeOfWitnesses(switchStatement, retainDefault) {
44185             var witnesses = [];
44186             for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) {
44187                 var clause = _a[_i];
44188                 if (clause.kind === 277) {
44189                     if (ts.isStringLiteralLike(clause.expression)) {
44190                         witnesses.push(clause.expression.text);
44191                         continue;
44192                     }
44193                     return ts.emptyArray;
44194                 }
44195                 if (retainDefault)
44196                     witnesses.push(undefined);
44197             }
44198             return witnesses;
44199         }
44200         function eachTypeContainedIn(source, types) {
44201             return source.flags & 1048576 ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source);
44202         }
44203         function isTypeSubsetOf(source, target) {
44204             return source === target || target.flags & 1048576 && isTypeSubsetOfUnion(source, target);
44205         }
44206         function isTypeSubsetOfUnion(source, target) {
44207             if (source.flags & 1048576) {
44208                 for (var _i = 0, _a = source.types; _i < _a.length; _i++) {
44209                     var t = _a[_i];
44210                     if (!containsType(target.types, t)) {
44211                         return false;
44212                     }
44213                 }
44214                 return true;
44215             }
44216             if (source.flags & 1024 && getBaseTypeOfEnumLiteralType(source) === target) {
44217                 return true;
44218             }
44219             return containsType(target.types, source);
44220         }
44221         function forEachType(type, f) {
44222             return type.flags & 1048576 ? ts.forEach(type.types, f) : f(type);
44223         }
44224         function everyType(type, f) {
44225             return type.flags & 1048576 ? ts.every(type.types, f) : f(type);
44226         }
44227         function filterType(type, f) {
44228             if (type.flags & 1048576) {
44229                 var types = type.types;
44230                 var filtered = ts.filter(types, f);
44231                 return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.objectFlags);
44232             }
44233             return type.flags & 131072 || f(type) ? type : neverType;
44234         }
44235         function countTypes(type) {
44236             return type.flags & 1048576 ? type.types.length : 1;
44237         }
44238         function mapType(type, mapper, noReductions) {
44239             if (type.flags & 131072) {
44240                 return type;
44241             }
44242             if (!(type.flags & 1048576)) {
44243                 return mapper(type);
44244             }
44245             var mappedTypes;
44246             for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
44247                 var t = _a[_i];
44248                 var mapped = mapper(t);
44249                 if (mapped) {
44250                     if (!mappedTypes) {
44251                         mappedTypes = [mapped];
44252                     }
44253                     else {
44254                         mappedTypes.push(mapped);
44255                     }
44256                 }
44257             }
44258             return mappedTypes && getUnionType(mappedTypes, noReductions ? 0 : 1);
44259         }
44260         function extractTypesOfKind(type, kind) {
44261             return filterType(type, function (t) { return (t.flags & kind) !== 0; });
44262         }
44263         function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) {
44264             if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128) ||
44265                 isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 256) ||
44266                 isTypeSubsetOf(bigintType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 2048)) {
44267                 return mapType(typeWithPrimitives, function (t) {
44268                     return t.flags & 4 ? extractTypesOfKind(typeWithLiterals, 4 | 128) :
44269                         t.flags & 8 ? extractTypesOfKind(typeWithLiterals, 8 | 256) :
44270                             t.flags & 64 ? extractTypesOfKind(typeWithLiterals, 64 | 2048) : t;
44271                 });
44272             }
44273             return typeWithPrimitives;
44274         }
44275         function isIncomplete(flowType) {
44276             return flowType.flags === 0;
44277         }
44278         function getTypeFromFlowType(flowType) {
44279             return flowType.flags === 0 ? flowType.type : flowType;
44280         }
44281         function createFlowType(type, incomplete) {
44282             return incomplete ? { flags: 0, type: type } : type;
44283         }
44284         function createEvolvingArrayType(elementType) {
44285             var result = createObjectType(256);
44286             result.elementType = elementType;
44287             return result;
44288         }
44289         function getEvolvingArrayType(elementType) {
44290             return evolvingArrayTypes[elementType.id] || (evolvingArrayTypes[elementType.id] = createEvolvingArrayType(elementType));
44291         }
44292         function addEvolvingArrayElementType(evolvingArrayType, node) {
44293             var elementType = getBaseTypeOfLiteralType(getContextFreeTypeOfExpression(node));
44294             return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType]));
44295         }
44296         function createFinalArrayType(elementType) {
44297             return elementType.flags & 131072 ?
44298                 autoArrayType :
44299                 createArrayType(elementType.flags & 1048576 ?
44300                     getUnionType(elementType.types, 2) :
44301                     elementType);
44302         }
44303         function getFinalArrayType(evolvingArrayType) {
44304             return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType));
44305         }
44306         function finalizeEvolvingArrayType(type) {
44307             return ts.getObjectFlags(type) & 256 ? getFinalArrayType(type) : type;
44308         }
44309         function getElementTypeOfEvolvingArrayType(type) {
44310             return ts.getObjectFlags(type) & 256 ? type.elementType : neverType;
44311         }
44312         function isEvolvingArrayTypeList(types) {
44313             var hasEvolvingArrayType = false;
44314             for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
44315                 var t = types_16[_i];
44316                 if (!(t.flags & 131072)) {
44317                     if (!(ts.getObjectFlags(t) & 256)) {
44318                         return false;
44319                     }
44320                     hasEvolvingArrayType = true;
44321                 }
44322             }
44323             return hasEvolvingArrayType;
44324         }
44325         function getUnionOrEvolvingArrayType(types, subtypeReduction) {
44326             return isEvolvingArrayTypeList(types) ?
44327                 getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))) :
44328                 getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction);
44329         }
44330         function isEvolvingArrayOperationTarget(node) {
44331             var root = getReferenceRoot(node);
44332             var parent = root.parent;
44333             var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" ||
44334                 parent.parent.kind === 196
44335                     && ts.isIdentifier(parent.name)
44336                     && ts.isPushOrUnshiftIdentifier(parent.name));
44337             var isElementAssignment = parent.kind === 195 &&
44338                 parent.expression === root &&
44339                 parent.parent.kind === 209 &&
44340                 parent.parent.operatorToken.kind === 62 &&
44341                 parent.parent.left === parent &&
44342                 !ts.isAssignmentTarget(parent.parent) &&
44343                 isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296);
44344             return isLengthPushOrUnshift || isElementAssignment;
44345         }
44346         function isDeclarationWithExplicitTypeAnnotation(declaration) {
44347             return (declaration.kind === 242 || declaration.kind === 156 ||
44348                 declaration.kind === 159 || declaration.kind === 158) &&
44349                 !!ts.getEffectiveTypeAnnotationNode(declaration);
44350         }
44351         function getExplicitTypeOfSymbol(symbol, diagnostic) {
44352             if (symbol.flags & (16 | 8192 | 32 | 512)) {
44353                 return getTypeOfSymbol(symbol);
44354             }
44355             if (symbol.flags & (3 | 4)) {
44356                 var declaration = symbol.valueDeclaration;
44357                 if (declaration) {
44358                     if (isDeclarationWithExplicitTypeAnnotation(declaration)) {
44359                         return getTypeOfSymbol(symbol);
44360                     }
44361                     if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 232) {
44362                         var statement = declaration.parent.parent;
44363                         var expressionType = getTypeOfDottedName(statement.expression, undefined);
44364                         if (expressionType) {
44365                             var use = statement.awaitModifier ? 15 : 13;
44366                             return checkIteratedTypeOrElementType(use, expressionType, undefinedType, undefined);
44367                         }
44368                     }
44369                     if (diagnostic) {
44370                         ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_needs_an_explicit_type_annotation, symbolToString(symbol)));
44371                     }
44372                 }
44373             }
44374         }
44375         function getTypeOfDottedName(node, diagnostic) {
44376             if (!(node.flags & 16777216)) {
44377                 switch (node.kind) {
44378                     case 75:
44379                         var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node));
44380                         return getExplicitTypeOfSymbol(symbol.flags & 2097152 ? resolveAlias(symbol) : symbol, diagnostic);
44381                     case 104:
44382                         return getExplicitThisType(node);
44383                     case 102:
44384                         return checkSuperExpression(node);
44385                     case 194:
44386                         var type = getTypeOfDottedName(node.expression, diagnostic);
44387                         var prop = type && getPropertyOfType(type, node.name.escapedText);
44388                         return prop && getExplicitTypeOfSymbol(prop, diagnostic);
44389                     case 200:
44390                         return getTypeOfDottedName(node.expression, diagnostic);
44391                 }
44392             }
44393         }
44394         function getEffectsSignature(node) {
44395             var links = getNodeLinks(node);
44396             var signature = links.effectsSignature;
44397             if (signature === undefined) {
44398                 var funcType = void 0;
44399                 if (node.parent.kind === 226) {
44400                     funcType = getTypeOfDottedName(node.expression, undefined);
44401                 }
44402                 else if (node.expression.kind !== 102) {
44403                     if (ts.isOptionalChain(node)) {
44404                         funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression);
44405                     }
44406                     else {
44407                         funcType = checkNonNullExpression(node.expression);
44408                     }
44409                 }
44410                 var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0);
44411                 var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] :
44412                     ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) :
44413                         undefined;
44414                 signature = links.effectsSignature = candidate && hasTypePredicateOrNeverReturnType(candidate) ? candidate : unknownSignature;
44415             }
44416             return signature === unknownSignature ? undefined : signature;
44417         }
44418         function hasTypePredicateOrNeverReturnType(signature) {
44419             return !!(getTypePredicateOfSignature(signature) ||
44420                 signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072);
44421         }
44422         function getTypePredicateArgument(predicate, callExpression) {
44423             if (predicate.kind === 1 || predicate.kind === 3) {
44424                 return callExpression.arguments[predicate.parameterIndex];
44425             }
44426             var invokedExpression = ts.skipParentheses(callExpression.expression);
44427             return ts.isAccessExpression(invokedExpression) ? ts.skipParentheses(invokedExpression.expression) : undefined;
44428         }
44429         function reportFlowControlError(node) {
44430             var block = ts.findAncestor(node, ts.isFunctionOrModuleBlock);
44431             var sourceFile = ts.getSourceFileOfNode(node);
44432             var span = ts.getSpanOfTokenAtPosition(sourceFile, block.statements.pos);
44433             diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis));
44434         }
44435         function isReachableFlowNode(flow) {
44436             var result = isReachableFlowNodeWorker(flow, false);
44437             lastFlowNode = flow;
44438             lastFlowNodeReachable = result;
44439             return result;
44440         }
44441         function isFalseExpression(expr) {
44442             var node = ts.skipParentheses(expr);
44443             return node.kind === 91 || node.kind === 209 && (node.operatorToken.kind === 55 && (isFalseExpression(node.left) || isFalseExpression(node.right)) ||
44444                 node.operatorToken.kind === 56 && isFalseExpression(node.left) && isFalseExpression(node.right));
44445         }
44446         function isReachableFlowNodeWorker(flow, noCacheCheck) {
44447             while (true) {
44448                 if (flow === lastFlowNode) {
44449                     return lastFlowNodeReachable;
44450                 }
44451                 var flags = flow.flags;
44452                 if (flags & 4096) {
44453                     if (!noCacheCheck) {
44454                         var id = getFlowNodeId(flow);
44455                         var reachable = flowNodeReachable[id];
44456                         return reachable !== undefined ? reachable : (flowNodeReachable[id] = isReachableFlowNodeWorker(flow, true));
44457                     }
44458                     noCacheCheck = false;
44459                 }
44460                 if (flags & (16 | 96 | 256)) {
44461                     flow = flow.antecedent;
44462                 }
44463                 else if (flags & 512) {
44464                     var signature = getEffectsSignature(flow.node);
44465                     if (signature) {
44466                         var predicate = getTypePredicateOfSignature(signature);
44467                         if (predicate && predicate.kind === 3) {
44468                             var predicateArgument = flow.node.arguments[predicate.parameterIndex];
44469                             if (predicateArgument && isFalseExpression(predicateArgument)) {
44470                                 return false;
44471                             }
44472                         }
44473                         if (getReturnTypeOfSignature(signature).flags & 131072) {
44474                             return false;
44475                         }
44476                     }
44477                     flow = flow.antecedent;
44478                 }
44479                 else if (flags & 4) {
44480                     return ts.some(flow.antecedents, function (f) { return isReachableFlowNodeWorker(f, false); });
44481                 }
44482                 else if (flags & 8) {
44483                     flow = flow.antecedents[0];
44484                 }
44485                 else if (flags & 128) {
44486                     if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) {
44487                         return false;
44488                     }
44489                     flow = flow.antecedent;
44490                 }
44491                 else if (flags & 1024) {
44492                     lastFlowNode = undefined;
44493                     var target = flow.target;
44494                     var saveAntecedents = target.antecedents;
44495                     target.antecedents = flow.antecedents;
44496                     var result = isReachableFlowNodeWorker(flow.antecedent, false);
44497                     target.antecedents = saveAntecedents;
44498                     return result;
44499                 }
44500                 else {
44501                     return !(flags & 1);
44502                 }
44503             }
44504         }
44505         function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) {
44506             if (initialType === void 0) { initialType = declaredType; }
44507             var key;
44508             var keySet = false;
44509             var flowDepth = 0;
44510             if (flowAnalysisDisabled) {
44511                 return errorType;
44512             }
44513             if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943)) {
44514                 return declaredType;
44515             }
44516             flowInvocationCount++;
44517             var sharedFlowStart = sharedFlowCount;
44518             var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode));
44519             sharedFlowCount = sharedFlowStart;
44520             var resultType = ts.getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType);
44521             if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 218 && getTypeWithFacts(resultType, 2097152).flags & 131072) {
44522                 return declaredType;
44523             }
44524             return resultType;
44525             function getOrSetCacheKey() {
44526                 if (keySet) {
44527                     return key;
44528                 }
44529                 keySet = true;
44530                 return key = getFlowCacheKey(reference, declaredType, initialType, flowContainer);
44531             }
44532             function getTypeAtFlowNode(flow) {
44533                 if (flowDepth === 2000) {
44534                     flowAnalysisDisabled = true;
44535                     reportFlowControlError(reference);
44536                     return errorType;
44537                 }
44538                 flowDepth++;
44539                 while (true) {
44540                     var flags = flow.flags;
44541                     if (flags & 4096) {
44542                         for (var i = sharedFlowStart; i < sharedFlowCount; i++) {
44543                             if (sharedFlowNodes[i] === flow) {
44544                                 flowDepth--;
44545                                 return sharedFlowTypes[i];
44546                             }
44547                         }
44548                     }
44549                     var type = void 0;
44550                     if (flags & 16) {
44551                         type = getTypeAtFlowAssignment(flow);
44552                         if (!type) {
44553                             flow = flow.antecedent;
44554                             continue;
44555                         }
44556                     }
44557                     else if (flags & 512) {
44558                         type = getTypeAtFlowCall(flow);
44559                         if (!type) {
44560                             flow = flow.antecedent;
44561                             continue;
44562                         }
44563                     }
44564                     else if (flags & 96) {
44565                         type = getTypeAtFlowCondition(flow);
44566                     }
44567                     else if (flags & 128) {
44568                         type = getTypeAtSwitchClause(flow);
44569                     }
44570                     else if (flags & 12) {
44571                         if (flow.antecedents.length === 1) {
44572                             flow = flow.antecedents[0];
44573                             continue;
44574                         }
44575                         type = flags & 4 ?
44576                             getTypeAtFlowBranchLabel(flow) :
44577                             getTypeAtFlowLoopLabel(flow);
44578                     }
44579                     else if (flags & 256) {
44580                         type = getTypeAtFlowArrayMutation(flow);
44581                         if (!type) {
44582                             flow = flow.antecedent;
44583                             continue;
44584                         }
44585                     }
44586                     else if (flags & 1024) {
44587                         var target = flow.target;
44588                         var saveAntecedents = target.antecedents;
44589                         target.antecedents = flow.antecedents;
44590                         type = getTypeAtFlowNode(flow.antecedent);
44591                         target.antecedents = saveAntecedents;
44592                     }
44593                     else if (flags & 2) {
44594                         var container = flow.node;
44595                         if (container && container !== flowContainer &&
44596                             reference.kind !== 194 &&
44597                             reference.kind !== 195 &&
44598                             reference.kind !== 104) {
44599                             flow = container.flowNode;
44600                             continue;
44601                         }
44602                         type = initialType;
44603                     }
44604                     else {
44605                         type = convertAutoToAny(declaredType);
44606                     }
44607                     if (flags & 4096) {
44608                         sharedFlowNodes[sharedFlowCount] = flow;
44609                         sharedFlowTypes[sharedFlowCount] = type;
44610                         sharedFlowCount++;
44611                     }
44612                     flowDepth--;
44613                     return type;
44614                 }
44615             }
44616             function getInitialOrAssignedType(flow) {
44617                 var node = flow.node;
44618                 return getConstraintForLocation(node.kind === 242 || node.kind === 191 ?
44619                     getInitialType(node) :
44620                     getAssignedType(node), reference);
44621             }
44622             function getTypeAtFlowAssignment(flow) {
44623                 var node = flow.node;
44624                 if (isMatchingReference(reference, node)) {
44625                     if (!isReachableFlowNode(flow)) {
44626                         return unreachableNeverType;
44627                     }
44628                     if (ts.getAssignmentTargetKind(node) === 2) {
44629                         var flowType = getTypeAtFlowNode(flow.antecedent);
44630                         return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType));
44631                     }
44632                     if (declaredType === autoType || declaredType === autoArrayType) {
44633                         if (isEmptyArrayAssignment(node)) {
44634                             return getEvolvingArrayType(neverType);
44635                         }
44636                         var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow));
44637                         return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType;
44638                     }
44639                     if (declaredType.flags & 1048576) {
44640                         return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow));
44641                     }
44642                     return declaredType;
44643                 }
44644                 if (containsMatchingReference(reference, node)) {
44645                     if (!isReachableFlowNode(flow)) {
44646                         return unreachableNeverType;
44647                     }
44648                     if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) {
44649                         var init = ts.getDeclaredExpandoInitializer(node);
44650                         if (init && (init.kind === 201 || init.kind === 202)) {
44651                             return getTypeAtFlowNode(flow.antecedent);
44652                         }
44653                     }
44654                     return declaredType;
44655                 }
44656                 if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 231 && isMatchingReference(reference, node.parent.parent.expression)) {
44657                     return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent)));
44658                 }
44659                 return undefined;
44660             }
44661             function narrowTypeByAssertion(type, expr) {
44662                 var node = ts.skipParentheses(expr);
44663                 if (node.kind === 91) {
44664                     return unreachableNeverType;
44665                 }
44666                 if (node.kind === 209) {
44667                     if (node.operatorToken.kind === 55) {
44668                         return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right);
44669                     }
44670                     if (node.operatorToken.kind === 56) {
44671                         return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]);
44672                     }
44673                 }
44674                 return narrowType(type, node, true);
44675             }
44676             function getTypeAtFlowCall(flow) {
44677                 var signature = getEffectsSignature(flow.node);
44678                 if (signature) {
44679                     var predicate = getTypePredicateOfSignature(signature);
44680                     if (predicate && (predicate.kind === 2 || predicate.kind === 3)) {
44681                         var flowType = getTypeAtFlowNode(flow.antecedent);
44682                         var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType));
44683                         var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, true) :
44684                             predicate.kind === 3 && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) :
44685                                 type;
44686                         return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType));
44687                     }
44688                     if (getReturnTypeOfSignature(signature).flags & 131072) {
44689                         return unreachableNeverType;
44690                     }
44691                 }
44692                 return undefined;
44693             }
44694             function getTypeAtFlowArrayMutation(flow) {
44695                 if (declaredType === autoType || declaredType === autoArrayType) {
44696                     var node = flow.node;
44697                     var expr = node.kind === 196 ?
44698                         node.expression.expression :
44699                         node.left.expression;
44700                     if (isMatchingReference(reference, getReferenceCandidate(expr))) {
44701                         var flowType = getTypeAtFlowNode(flow.antecedent);
44702                         var type = getTypeFromFlowType(flowType);
44703                         if (ts.getObjectFlags(type) & 256) {
44704                             var evolvedType_1 = type;
44705                             if (node.kind === 196) {
44706                                 for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) {
44707                                     var arg = _a[_i];
44708                                     evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg);
44709                                 }
44710                             }
44711                             else {
44712                                 var indexType = getContextFreeTypeOfExpression(node.left.argumentExpression);
44713                                 if (isTypeAssignableToKind(indexType, 296)) {
44714                                     evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right);
44715                                 }
44716                             }
44717                             return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType));
44718                         }
44719                         return flowType;
44720                     }
44721                 }
44722                 return undefined;
44723             }
44724             function getTypeAtFlowCondition(flow) {
44725                 var flowType = getTypeAtFlowNode(flow.antecedent);
44726                 var type = getTypeFromFlowType(flowType);
44727                 if (type.flags & 131072) {
44728                     return flowType;
44729                 }
44730                 var assumeTrue = (flow.flags & 32) !== 0;
44731                 var nonEvolvingType = finalizeEvolvingArrayType(type);
44732                 var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue);
44733                 if (narrowedType === nonEvolvingType) {
44734                     return flowType;
44735                 }
44736                 var incomplete = isIncomplete(flowType);
44737                 var resultType = incomplete && narrowedType.flags & 131072 ? silentNeverType : narrowedType;
44738                 return createFlowType(resultType, incomplete);
44739             }
44740             function getTypeAtSwitchClause(flow) {
44741                 var expr = flow.switchStatement.expression;
44742                 var flowType = getTypeAtFlowNode(flow.antecedent);
44743                 var type = getTypeFromFlowType(flowType);
44744                 if (isMatchingReference(reference, expr)) {
44745                     type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
44746                 }
44747                 else if (expr.kind === 204 && isMatchingReference(reference, expr.expression)) {
44748                     type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
44749                 }
44750                 else {
44751                     if (strictNullChecks) {
44752                         if (optionalChainContainsReference(expr, reference)) {
44753                             type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 | 131072)); });
44754                         }
44755                         else if (expr.kind === 204 && optionalChainContainsReference(expr.expression, reference)) {
44756                             type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 || t.flags & 128 && t.value === "undefined"); });
44757                         }
44758                     }
44759                     if (isMatchingReferenceDiscriminant(expr, type)) {
44760                         type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); });
44761                     }
44762                 }
44763                 return createFlowType(type, isIncomplete(flowType));
44764             }
44765             function getTypeAtFlowBranchLabel(flow) {
44766                 var antecedentTypes = [];
44767                 var subtypeReduction = false;
44768                 var seenIncomplete = false;
44769                 var bypassFlow;
44770                 for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) {
44771                     var antecedent = _a[_i];
44772                     if (!bypassFlow && antecedent.flags & 128 && antecedent.clauseStart === antecedent.clauseEnd) {
44773                         bypassFlow = antecedent;
44774                         continue;
44775                     }
44776                     var flowType = getTypeAtFlowNode(antecedent);
44777                     var type = getTypeFromFlowType(flowType);
44778                     if (type === declaredType && declaredType === initialType) {
44779                         return type;
44780                     }
44781                     ts.pushIfUnique(antecedentTypes, type);
44782                     if (!isTypeSubsetOf(type, declaredType)) {
44783                         subtypeReduction = true;
44784                     }
44785                     if (isIncomplete(flowType)) {
44786                         seenIncomplete = true;
44787                     }
44788                 }
44789                 if (bypassFlow) {
44790                     var flowType = getTypeAtFlowNode(bypassFlow);
44791                     var type = getTypeFromFlowType(flowType);
44792                     if (!ts.contains(antecedentTypes, type) && !isExhaustiveSwitchStatement(bypassFlow.switchStatement)) {
44793                         if (type === declaredType && declaredType === initialType) {
44794                             return type;
44795                         }
44796                         antecedentTypes.push(type);
44797                         if (!isTypeSubsetOf(type, declaredType)) {
44798                             subtypeReduction = true;
44799                         }
44800                         if (isIncomplete(flowType)) {
44801                             seenIncomplete = true;
44802                         }
44803                     }
44804                 }
44805                 return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 : 1), seenIncomplete);
44806             }
44807             function getTypeAtFlowLoopLabel(flow) {
44808                 var id = getFlowNodeId(flow);
44809                 var cache = flowLoopCaches[id] || (flowLoopCaches[id] = ts.createMap());
44810                 var key = getOrSetCacheKey();
44811                 if (!key) {
44812                     return declaredType;
44813                 }
44814                 var cached = cache.get(key);
44815                 if (cached) {
44816                     return cached;
44817                 }
44818                 for (var i = flowLoopStart; i < flowLoopCount; i++) {
44819                     if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) {
44820                         return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1), true);
44821                     }
44822                 }
44823                 var antecedentTypes = [];
44824                 var subtypeReduction = false;
44825                 var firstAntecedentType;
44826                 for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) {
44827                     var antecedent = _a[_i];
44828                     var flowType = void 0;
44829                     if (!firstAntecedentType) {
44830                         flowType = firstAntecedentType = getTypeAtFlowNode(antecedent);
44831                     }
44832                     else {
44833                         flowLoopNodes[flowLoopCount] = flow;
44834                         flowLoopKeys[flowLoopCount] = key;
44835                         flowLoopTypes[flowLoopCount] = antecedentTypes;
44836                         flowLoopCount++;
44837                         var saveFlowTypeCache = flowTypeCache;
44838                         flowTypeCache = undefined;
44839                         flowType = getTypeAtFlowNode(antecedent);
44840                         flowTypeCache = saveFlowTypeCache;
44841                         flowLoopCount--;
44842                         var cached_1 = cache.get(key);
44843                         if (cached_1) {
44844                             return cached_1;
44845                         }
44846                     }
44847                     var type = getTypeFromFlowType(flowType);
44848                     ts.pushIfUnique(antecedentTypes, type);
44849                     if (!isTypeSubsetOf(type, declaredType)) {
44850                         subtypeReduction = true;
44851                     }
44852                     if (type === declaredType) {
44853                         break;
44854                     }
44855                 }
44856                 var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 : 1);
44857                 if (isIncomplete(firstAntecedentType)) {
44858                     return createFlowType(result, true);
44859                 }
44860                 cache.set(key, result);
44861                 return result;
44862             }
44863             function isMatchingReferenceDiscriminant(expr, computedType) {
44864                 if (!(computedType.flags & 1048576) || !ts.isAccessExpression(expr)) {
44865                     return false;
44866                 }
44867                 var name = getAccessedPropertyName(expr);
44868                 if (name === undefined) {
44869                     return false;
44870                 }
44871                 return isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, name);
44872             }
44873             function narrowTypeByDiscriminant(type, access, narrowType) {
44874                 var propName = getAccessedPropertyName(access);
44875                 if (propName === undefined) {
44876                     return type;
44877                 }
44878                 var propType = getTypeOfPropertyOfType(type, propName);
44879                 if (!propType) {
44880                     return type;
44881                 }
44882                 var narrowedPropType = narrowType(propType);
44883                 return filterType(type, function (t) {
44884                     var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName);
44885                     return !(discriminantType.flags & 131072) && isTypeComparableTo(discriminantType, narrowedPropType);
44886                 });
44887             }
44888             function narrowTypeByTruthiness(type, expr, assumeTrue) {
44889                 if (isMatchingReference(reference, expr)) {
44890                     return getTypeWithFacts(type, assumeTrue ? 4194304 : 8388608);
44891                 }
44892                 if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) {
44893                     type = getTypeWithFacts(type, 2097152);
44894                 }
44895                 if (isMatchingReferenceDiscriminant(expr, declaredType)) {
44896                     return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 : 8388608); });
44897                 }
44898                 return type;
44899             }
44900             function isTypePresencePossible(type, propName, assumeTrue) {
44901                 if (getIndexInfoOfType(type, 0)) {
44902                     return true;
44903                 }
44904                 var prop = getPropertyOfType(type, propName);
44905                 if (prop) {
44906                     return prop.flags & 16777216 ? true : assumeTrue;
44907                 }
44908                 return !assumeTrue;
44909             }
44910             function narrowByInKeyword(type, literal, assumeTrue) {
44911                 if (type.flags & (1048576 | 524288) || isThisTypeParameter(type)) {
44912                     var propName_1 = ts.escapeLeadingUnderscores(literal.text);
44913                     return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); });
44914                 }
44915                 return type;
44916             }
44917             function narrowTypeByBinaryExpression(type, expr, assumeTrue) {
44918                 switch (expr.operatorToken.kind) {
44919                     case 62:
44920                         return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue);
44921                     case 34:
44922                     case 35:
44923                     case 36:
44924                     case 37:
44925                         var operator_1 = expr.operatorToken.kind;
44926                         var left_1 = getReferenceCandidate(expr.left);
44927                         var right_1 = getReferenceCandidate(expr.right);
44928                         if (left_1.kind === 204 && ts.isStringLiteralLike(right_1)) {
44929                             return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue);
44930                         }
44931                         if (right_1.kind === 204 && ts.isStringLiteralLike(left_1)) {
44932                             return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue);
44933                         }
44934                         if (isMatchingReference(reference, left_1)) {
44935                             return narrowTypeByEquality(type, operator_1, right_1, assumeTrue);
44936                         }
44937                         if (isMatchingReference(reference, right_1)) {
44938                             return narrowTypeByEquality(type, operator_1, left_1, assumeTrue);
44939                         }
44940                         if (strictNullChecks) {
44941                             if (optionalChainContainsReference(left_1, reference)) {
44942                                 type = narrowTypeByOptionalChainContainment(type, operator_1, right_1, assumeTrue);
44943                             }
44944                             else if (optionalChainContainsReference(right_1, reference)) {
44945                                 type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue);
44946                             }
44947                         }
44948                         if (isMatchingReferenceDiscriminant(left_1, declaredType)) {
44949                             return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); });
44950                         }
44951                         if (isMatchingReferenceDiscriminant(right_1, declaredType)) {
44952                             return narrowTypeByDiscriminant(type, right_1, function (t) { return narrowTypeByEquality(t, operator_1, left_1, assumeTrue); });
44953                         }
44954                         if (isMatchingConstructorReference(left_1)) {
44955                             return narrowTypeByConstructor(type, operator_1, right_1, assumeTrue);
44956                         }
44957                         if (isMatchingConstructorReference(right_1)) {
44958                             return narrowTypeByConstructor(type, operator_1, left_1, assumeTrue);
44959                         }
44960                         break;
44961                     case 98:
44962                         return narrowTypeByInstanceof(type, expr, assumeTrue);
44963                     case 97:
44964                         var target = getReferenceCandidate(expr.right);
44965                         if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) {
44966                             return narrowByInKeyword(type, expr.left, assumeTrue);
44967                         }
44968                         break;
44969                     case 27:
44970                         return narrowType(type, expr.right, assumeTrue);
44971                 }
44972                 return type;
44973             }
44974             function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
44975                 var equalsOperator = operator === 34 || operator === 36;
44976                 var nullableFlags = operator === 34 || operator === 35 ? 98304 : 32768;
44977                 var valueType = getTypeOfExpression(value);
44978                 var removeNullable = equalsOperator !== assumeTrue && everyType(valueType, function (t) { return !!(t.flags & nullableFlags); }) ||
44979                     equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 | nullableFlags)); });
44980                 return removeNullable ? getTypeWithFacts(type, 2097152) : type;
44981             }
44982             function narrowTypeByEquality(type, operator, value, assumeTrue) {
44983                 if (type.flags & 1) {
44984                     return type;
44985                 }
44986                 if (operator === 35 || operator === 37) {
44987                     assumeTrue = !assumeTrue;
44988                 }
44989                 var valueType = getTypeOfExpression(value);
44990                 if ((type.flags & 2) && assumeTrue && (operator === 36 || operator === 37)) {
44991                     if (valueType.flags & (131068 | 67108864)) {
44992                         return valueType;
44993                     }
44994                     if (valueType.flags & 524288) {
44995                         return nonPrimitiveType;
44996                     }
44997                     return type;
44998                 }
44999                 if (valueType.flags & 98304) {
45000                     if (!strictNullChecks) {
45001                         return type;
45002                     }
45003                     var doubleEquals = operator === 34 || operator === 35;
45004                     var facts = doubleEquals ?
45005                         assumeTrue ? 262144 : 2097152 :
45006                         valueType.flags & 65536 ?
45007                             assumeTrue ? 131072 : 1048576 :
45008                             assumeTrue ? 65536 : 524288;
45009                     return getTypeWithFacts(type, facts);
45010                 }
45011                 if (type.flags & 67637251) {
45012                     return type;
45013                 }
45014                 if (assumeTrue) {
45015                     var filterFn = operator === 34 ?
45016                         (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) :
45017                         function (t) { return areTypesComparable(t, valueType); };
45018                     var narrowedType = filterType(type, filterFn);
45019                     return narrowedType.flags & 131072 ? type : replacePrimitivesWithLiterals(narrowedType, valueType);
45020                 }
45021                 if (isUnitType(valueType)) {
45022                     var regularType_1 = getRegularTypeOfLiteralType(valueType);
45023                     return filterType(type, function (t) { return isUnitType(t) ? !areTypesComparable(t, valueType) : getRegularTypeOfLiteralType(t) !== regularType_1; });
45024                 }
45025                 return type;
45026             }
45027             function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) {
45028                 if (operator === 35 || operator === 37) {
45029                     assumeTrue = !assumeTrue;
45030                 }
45031                 var target = getReferenceCandidate(typeOfExpr.expression);
45032                 if (!isMatchingReference(reference, target)) {
45033                     if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) {
45034                         return getTypeWithFacts(type, 2097152);
45035                     }
45036                     return type;
45037                 }
45038                 if (type.flags & 1 && literal.text === "function") {
45039                     return type;
45040                 }
45041                 if (assumeTrue && type.flags & 2 && literal.text === "object") {
45042                     if (typeOfExpr.parent.parent.kind === 209) {
45043                         var expr = typeOfExpr.parent.parent;
45044                         if (expr.operatorToken.kind === 55 && expr.right === typeOfExpr.parent && containsTruthyCheck(reference, expr.left)) {
45045                             return nonPrimitiveType;
45046                         }
45047                     }
45048                     return getUnionType([nonPrimitiveType, nullType]);
45049                 }
45050                 var facts = assumeTrue ?
45051                     typeofEQFacts.get(literal.text) || 128 :
45052                     typeofNEFacts.get(literal.text) || 32768;
45053                 return getTypeWithFacts(assumeTrue ? mapType(type, narrowTypeForTypeof) : type, facts);
45054                 function narrowTypeForTypeof(type) {
45055                     var targetType = literal.text === "function" ? globalFunctionType : typeofTypesByName.get(literal.text);
45056                     if (targetType) {
45057                         if (isTypeSubtypeOf(type, targetType)) {
45058                             return type;
45059                         }
45060                         if (isTypeSubtypeOf(targetType, type)) {
45061                             return targetType;
45062                         }
45063                         if (type.flags & 63176704) {
45064                             var constraint = getBaseConstraintOfType(type) || anyType;
45065                             if (isTypeSubtypeOf(targetType, constraint)) {
45066                                 return getIntersectionType([type, targetType]);
45067                             }
45068                         }
45069                     }
45070                     return type;
45071                 }
45072             }
45073             function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
45074                 var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
45075                 return everyClauseChecks ? getTypeWithFacts(type, 2097152) : type;
45076             }
45077             function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) {
45078                 var switchTypes = getSwitchClauseTypes(switchStatement);
45079                 if (!switchTypes.length) {
45080                     return type;
45081                 }
45082                 var clauseTypes = switchTypes.slice(clauseStart, clauseEnd);
45083                 var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType);
45084                 if ((type.flags & 2) && !hasDefaultClause) {
45085                     var groundClauseTypes = void 0;
45086                     for (var i = 0; i < clauseTypes.length; i += 1) {
45087                         var t = clauseTypes[i];
45088                         if (t.flags & (131068 | 67108864)) {
45089                             if (groundClauseTypes !== undefined) {
45090                                 groundClauseTypes.push(t);
45091                             }
45092                         }
45093                         else if (t.flags & 524288) {
45094                             if (groundClauseTypes === undefined) {
45095                                 groundClauseTypes = clauseTypes.slice(0, i);
45096                             }
45097                             groundClauseTypes.push(nonPrimitiveType);
45098                         }
45099                         else {
45100                             return type;
45101                         }
45102                     }
45103                     return getUnionType(groundClauseTypes === undefined ? clauseTypes : groundClauseTypes);
45104                 }
45105                 var discriminantType = getUnionType(clauseTypes);
45106                 var caseType = discriminantType.flags & 131072 ? neverType :
45107                     replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType);
45108                 if (!hasDefaultClause) {
45109                     return caseType;
45110                 }
45111                 var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); });
45112                 return caseType.flags & 131072 ? defaultType : getUnionType([caseType, defaultType]);
45113             }
45114             function getImpliedTypeFromTypeofCase(type, text) {
45115                 switch (text) {
45116                     case "function":
45117                         return type.flags & 1 ? type : globalFunctionType;
45118                     case "object":
45119                         return type.flags & 2 ? getUnionType([nonPrimitiveType, nullType]) : type;
45120                     default:
45121                         return typeofTypesByName.get(text) || type;
45122                 }
45123             }
45124             function narrowTypeForTypeofSwitch(candidate) {
45125                 return function (type) {
45126                     if (isTypeSubtypeOf(candidate, type)) {
45127                         return candidate;
45128                     }
45129                     if (type.flags & 63176704) {
45130                         var constraint = getBaseConstraintOfType(type) || anyType;
45131                         if (isTypeSubtypeOf(candidate, constraint)) {
45132                             return getIntersectionType([type, candidate]);
45133                         }
45134                     }
45135                     return type;
45136                 };
45137             }
45138             function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
45139                 var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, true);
45140                 if (!switchWitnesses.length) {
45141                     return type;
45142                 }
45143                 var defaultCaseLocation = ts.findIndex(switchWitnesses, function (elem) { return elem === undefined; });
45144                 var hasDefaultClause = clauseStart === clauseEnd || (defaultCaseLocation >= clauseStart && defaultCaseLocation < clauseEnd);
45145                 var clauseWitnesses;
45146                 var switchFacts;
45147                 if (defaultCaseLocation > -1) {
45148                     var witnesses = switchWitnesses.filter(function (witness) { return witness !== undefined; });
45149                     var fixedClauseStart = defaultCaseLocation < clauseStart ? clauseStart - 1 : clauseStart;
45150                     var fixedClauseEnd = defaultCaseLocation < clauseEnd ? clauseEnd - 1 : clauseEnd;
45151                     clauseWitnesses = witnesses.slice(fixedClauseStart, fixedClauseEnd);
45152                     switchFacts = getFactsFromTypeofSwitch(fixedClauseStart, fixedClauseEnd, witnesses, hasDefaultClause);
45153                 }
45154                 else {
45155                     clauseWitnesses = switchWitnesses.slice(clauseStart, clauseEnd);
45156                     switchFacts = getFactsFromTypeofSwitch(clauseStart, clauseEnd, switchWitnesses, hasDefaultClause);
45157                 }
45158                 if (hasDefaultClause) {
45159                     return filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; });
45160                 }
45161                 var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofCase(type, text); })), switchFacts);
45162                 if (impliedType.flags & 1048576) {
45163                     impliedType = getAssignmentReducedType(impliedType, getBaseConstraintOrType(type));
45164                 }
45165                 return getTypeWithFacts(mapType(type, narrowTypeForTypeofSwitch(impliedType)), switchFacts);
45166             }
45167             function isMatchingConstructorReference(expr) {
45168                 return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
45169                     ts.isElementAccessExpression(expr) && ts.isStringLiteralLike(expr.argumentExpression) && expr.argumentExpression.text === "constructor") &&
45170                     isMatchingReference(reference, expr.expression);
45171             }
45172             function narrowTypeByConstructor(type, operator, identifier, assumeTrue) {
45173                 if (assumeTrue ? (operator !== 34 && operator !== 36) : (operator !== 35 && operator !== 37)) {
45174                     return type;
45175                 }
45176                 var identifierType = getTypeOfExpression(identifier);
45177                 if (!isFunctionType(identifierType) && !isConstructorType(identifierType)) {
45178                     return type;
45179                 }
45180                 var prototypeProperty = getPropertyOfType(identifierType, "prototype");
45181                 if (!prototypeProperty) {
45182                     return type;
45183                 }
45184                 var prototypeType = getTypeOfSymbol(prototypeProperty);
45185                 var candidate = !isTypeAny(prototypeType) ? prototypeType : undefined;
45186                 if (!candidate || candidate === globalObjectType || candidate === globalFunctionType) {
45187                     return type;
45188                 }
45189                 if (isTypeAny(type)) {
45190                     return candidate;
45191                 }
45192                 return filterType(type, function (t) { return isConstructedBy(t, candidate); });
45193                 function isConstructedBy(source, target) {
45194                     if (source.flags & 524288 && ts.getObjectFlags(source) & 1 ||
45195                         target.flags & 524288 && ts.getObjectFlags(target) & 1) {
45196                         return source.symbol === target.symbol;
45197                     }
45198                     return isTypeSubtypeOf(source, target);
45199                 }
45200             }
45201             function narrowTypeByInstanceof(type, expr, assumeTrue) {
45202                 var left = getReferenceCandidate(expr.left);
45203                 if (!isMatchingReference(reference, left)) {
45204                     if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) {
45205                         return getTypeWithFacts(type, 2097152);
45206                     }
45207                     return type;
45208                 }
45209                 var rightType = getTypeOfExpression(expr.right);
45210                 if (!isTypeDerivedFrom(rightType, globalFunctionType)) {
45211                     return type;
45212                 }
45213                 var targetType;
45214                 var prototypeProperty = getPropertyOfType(rightType, "prototype");
45215                 if (prototypeProperty) {
45216                     var prototypePropertyType = getTypeOfSymbol(prototypeProperty);
45217                     if (!isTypeAny(prototypePropertyType)) {
45218                         targetType = prototypePropertyType;
45219                     }
45220                 }
45221                 if (isTypeAny(type) && (targetType === globalObjectType || targetType === globalFunctionType)) {
45222                     return type;
45223                 }
45224                 if (!targetType) {
45225                     var constructSignatures = getSignaturesOfType(rightType, 1);
45226                     targetType = constructSignatures.length ?
45227                         getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })) :
45228                         emptyObjectType;
45229                 }
45230                 return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom);
45231             }
45232             function getNarrowedType(type, candidate, assumeTrue, isRelated) {
45233                 if (!assumeTrue) {
45234                     return filterType(type, function (t) { return !isRelated(t, candidate); });
45235                 }
45236                 if (type.flags & 1048576) {
45237                     var assignableType = filterType(type, function (t) { return isRelated(t, candidate); });
45238                     if (!(assignableType.flags & 131072)) {
45239                         return assignableType;
45240                     }
45241                 }
45242                 return isTypeSubtypeOf(candidate, type) ? candidate :
45243                     isTypeAssignableTo(type, candidate) ? type :
45244                         isTypeAssignableTo(candidate, type) ? candidate :
45245                             getIntersectionType([type, candidate]);
45246             }
45247             function narrowTypeByCallExpression(type, callExpression, assumeTrue) {
45248                 if (hasMatchingArgument(callExpression, reference)) {
45249                     var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined;
45250                     var predicate = signature && getTypePredicateOfSignature(signature);
45251                     if (predicate && (predicate.kind === 0 || predicate.kind === 1)) {
45252                         return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue);
45253                     }
45254                 }
45255                 return type;
45256             }
45257             function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) {
45258                 if (predicate.type && !(isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType))) {
45259                     var predicateArgument = getTypePredicateArgument(predicate, callExpression);
45260                     if (predicateArgument) {
45261                         if (isMatchingReference(reference, predicateArgument)) {
45262                             return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf);
45263                         }
45264                         if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) &&
45265                             !(getTypeFacts(predicate.type) & 65536)) {
45266                             type = getTypeWithFacts(type, 2097152);
45267                         }
45268                         if (isMatchingReferenceDiscriminant(predicateArgument, declaredType)) {
45269                             return narrowTypeByDiscriminant(type, predicateArgument, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); });
45270                         }
45271                     }
45272                 }
45273                 return type;
45274             }
45275             function narrowType(type, expr, assumeTrue) {
45276                 if (ts.isExpressionOfOptionalChainRoot(expr) ||
45277                     ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 && expr.parent.left === expr) {
45278                     return narrowTypeByOptionality(type, expr, assumeTrue);
45279                 }
45280                 switch (expr.kind) {
45281                     case 75:
45282                     case 104:
45283                     case 102:
45284                     case 194:
45285                     case 195:
45286                         return narrowTypeByTruthiness(type, expr, assumeTrue);
45287                     case 196:
45288                         return narrowTypeByCallExpression(type, expr, assumeTrue);
45289                     case 200:
45290                         return narrowType(type, expr.expression, assumeTrue);
45291                     case 209:
45292                         return narrowTypeByBinaryExpression(type, expr, assumeTrue);
45293                     case 207:
45294                         if (expr.operator === 53) {
45295                             return narrowType(type, expr.operand, !assumeTrue);
45296                         }
45297                         break;
45298                 }
45299                 return type;
45300             }
45301             function narrowTypeByOptionality(type, expr, assumePresent) {
45302                 if (isMatchingReference(reference, expr)) {
45303                     return getTypeWithFacts(type, assumePresent ? 2097152 : 262144);
45304                 }
45305                 if (isMatchingReferenceDiscriminant(expr, declaredType)) {
45306                     return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 : 262144); });
45307                 }
45308                 return type;
45309             }
45310         }
45311         function getTypeOfSymbolAtLocation(symbol, location) {
45312             symbol = symbol.exportSymbol || symbol;
45313             if (location.kind === 75) {
45314                 if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) {
45315                     location = location.parent;
45316                 }
45317                 if (ts.isExpressionNode(location) && !ts.isAssignmentTarget(location)) {
45318                     var type = getTypeOfExpression(location);
45319                     if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) {
45320                         return type;
45321                     }
45322                 }
45323             }
45324             return getTypeOfSymbol(symbol);
45325         }
45326         function getControlFlowContainer(node) {
45327             return ts.findAncestor(node.parent, function (node) {
45328                 return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) ||
45329                     node.kind === 250 ||
45330                     node.kind === 290 ||
45331                     node.kind === 159;
45332             });
45333         }
45334         function isParameterAssigned(symbol) {
45335             var func = ts.getRootDeclaration(symbol.valueDeclaration).parent;
45336             var links = getNodeLinks(func);
45337             if (!(links.flags & 8388608)) {
45338                 links.flags |= 8388608;
45339                 if (!hasParentWithAssignmentsMarked(func)) {
45340                     markParameterAssignments(func);
45341                 }
45342             }
45343             return symbol.isAssigned || false;
45344         }
45345         function hasParentWithAssignmentsMarked(node) {
45346             return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608); });
45347         }
45348         function markParameterAssignments(node) {
45349             if (node.kind === 75) {
45350                 if (ts.isAssignmentTarget(node)) {
45351                     var symbol = getResolvedSymbol(node);
45352                     if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 156) {
45353                         symbol.isAssigned = true;
45354                     }
45355                 }
45356             }
45357             else {
45358                 ts.forEachChild(node, markParameterAssignments);
45359             }
45360         }
45361         function isConstVariable(symbol) {
45362             return symbol.flags & 3 && (getDeclarationNodeFlagsFromSymbol(symbol) & 2) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType;
45363         }
45364         function removeOptionalityFromDeclaredType(declaredType, declaration) {
45365             if (pushTypeResolution(declaration.symbol, 2)) {
45366                 var annotationIncludesUndefined = strictNullChecks &&
45367                     declaration.kind === 156 &&
45368                     declaration.initializer &&
45369                     getFalsyFlags(declaredType) & 32768 &&
45370                     !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768);
45371                 popTypeResolution();
45372                 return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288) : declaredType;
45373             }
45374             else {
45375                 reportCircularityError(declaration.symbol);
45376                 return declaredType;
45377             }
45378         }
45379         function isConstraintPosition(node) {
45380             var parent = node.parent;
45381             return parent.kind === 194 ||
45382                 parent.kind === 196 && parent.expression === node ||
45383                 parent.kind === 195 && parent.expression === node ||
45384                 parent.kind === 191 && parent.name === node && !!parent.initializer;
45385         }
45386         function typeHasNullableConstraint(type) {
45387             return type.flags & 58982400 && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304);
45388         }
45389         function getConstraintForLocation(type, node) {
45390             if (type && isConstraintPosition(node) && forEachType(type, typeHasNullableConstraint)) {
45391                 return mapType(getWidenedType(type), getBaseConstraintOrType);
45392             }
45393             return type;
45394         }
45395         function isExportOrExportExpression(location) {
45396             return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); });
45397         }
45398         function markAliasReferenced(symbol, location) {
45399             if (isNonLocalAlias(symbol, 111551) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) {
45400                 if (compilerOptions.preserveConstEnums && isExportOrExportExpression(location) || !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) {
45401                     markAliasSymbolAsReferenced(symbol);
45402                 }
45403                 else {
45404                     markConstEnumAliasAsReferenced(symbol);
45405                 }
45406             }
45407         }
45408         function checkIdentifier(node) {
45409             var symbol = getResolvedSymbol(node);
45410             if (symbol === unknownSymbol) {
45411                 return errorType;
45412             }
45413             if (symbol === argumentsSymbol) {
45414                 var container = ts.getContainingFunction(node);
45415                 if (languageVersion < 2) {
45416                     if (container.kind === 202) {
45417                         error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression);
45418                     }
45419                     else if (ts.hasModifier(container, 256)) {
45420                         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);
45421                     }
45422                 }
45423                 getNodeLinks(container).flags |= 8192;
45424                 return getTypeOfSymbol(symbol);
45425             }
45426             if (!(node.parent && ts.isPropertyAccessExpression(node.parent) && node.parent.expression === node)) {
45427                 markAliasReferenced(symbol, node);
45428             }
45429             var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
45430             var declaration = localOrExportSymbol.valueDeclaration;
45431             if (localOrExportSymbol.flags & 32) {
45432                 if (declaration.kind === 245
45433                     && ts.nodeIsDecorated(declaration)) {
45434                     var container = ts.getContainingClass(node);
45435                     while (container !== undefined) {
45436                         if (container === declaration && container.name !== node) {
45437                             getNodeLinks(declaration).flags |= 16777216;
45438                             getNodeLinks(node).flags |= 33554432;
45439                             break;
45440                         }
45441                         container = ts.getContainingClass(container);
45442                     }
45443                 }
45444                 else if (declaration.kind === 214) {
45445                     var container = ts.getThisContainer(node, false);
45446                     while (container.kind !== 290) {
45447                         if (container.parent === declaration) {
45448                             if (container.kind === 159 && ts.hasModifier(container, 32)) {
45449                                 getNodeLinks(declaration).flags |= 16777216;
45450                                 getNodeLinks(node).flags |= 33554432;
45451                             }
45452                             break;
45453                         }
45454                         container = ts.getThisContainer(container, false);
45455                     }
45456                 }
45457             }
45458             checkNestedBlockScopedBinding(node, symbol);
45459             var type = getConstraintForLocation(getTypeOfSymbol(localOrExportSymbol), node);
45460             var assignmentKind = ts.getAssignmentTargetKind(node);
45461             if (assignmentKind) {
45462                 if (!(localOrExportSymbol.flags & 3) &&
45463                     !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512)) {
45464                     error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol));
45465                     return errorType;
45466                 }
45467                 if (isReadonlySymbol(localOrExportSymbol)) {
45468                     if (localOrExportSymbol.flags & 3) {
45469                         error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant, symbolToString(symbol));
45470                     }
45471                     else {
45472                         error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(symbol));
45473                     }
45474                     return errorType;
45475                 }
45476             }
45477             var isAlias = localOrExportSymbol.flags & 2097152;
45478             if (localOrExportSymbol.flags & 3) {
45479                 if (assignmentKind === 1) {
45480                     return type;
45481                 }
45482             }
45483             else if (isAlias) {
45484                 declaration = ts.find(symbol.declarations, isSomeImportDeclaration);
45485             }
45486             else {
45487                 return type;
45488             }
45489             if (!declaration) {
45490                 return type;
45491             }
45492             var isParameter = ts.getRootDeclaration(declaration).kind === 156;
45493             var declarationContainer = getControlFlowContainer(declaration);
45494             var flowContainer = getControlFlowContainer(node);
45495             var isOuterVariable = flowContainer !== declarationContainer;
45496             var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent);
45497             var isModuleExports = symbol.flags & 134217728;
45498             while (flowContainer !== declarationContainer && (flowContainer.kind === 201 ||
45499                 flowContainer.kind === 202 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) &&
45500                 (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) {
45501                 flowContainer = getControlFlowContainer(flowContainer);
45502             }
45503             var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) ||
45504                 type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 | 16384)) !== 0 ||
45505                     isInTypeQuery(node) || node.parent.kind === 263) ||
45506                 node.parent.kind === 218 ||
45507                 declaration.kind === 242 && declaration.exclamationToken ||
45508                 declaration.flags & 8388608;
45509             var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) :
45510                 type === autoType || type === autoArrayType ? undefinedType :
45511                     getOptionalType(type);
45512             var flowType = getFlowTypeOfReference(node, type, initialType, flowContainer, !assumeInitialized);
45513             if (!isEvolvingArrayOperationTarget(node) && (type === autoType || type === autoArrayType)) {
45514                 if (flowType === autoType || flowType === autoArrayType) {
45515                     if (noImplicitAny) {
45516                         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));
45517                         error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType));
45518                     }
45519                     return convertAutoToAny(flowType);
45520                 }
45521             }
45522             else if (!assumeInitialized && !(getFalsyFlags(type) & 32768) && getFalsyFlags(flowType) & 32768) {
45523                 error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol));
45524                 return type;
45525             }
45526             return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
45527         }
45528         function isInsideFunction(node, threshold) {
45529             return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n); });
45530         }
45531         function getPartOfForStatementContainingNode(node, container) {
45532             return ts.findAncestor(node, function (n) { return n === container ? "quit" : n === container.initializer || n === container.condition || n === container.incrementor || n === container.statement; });
45533         }
45534         function checkNestedBlockScopedBinding(node, symbol) {
45535             if (languageVersion >= 2 ||
45536                 (symbol.flags & (2 | 32)) === 0 ||
45537                 ts.isSourceFile(symbol.valueDeclaration) ||
45538                 symbol.valueDeclaration.parent.kind === 280) {
45539                 return;
45540             }
45541             var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration);
45542             var usedInFunction = isInsideFunction(node.parent, container);
45543             var current = container;
45544             var containedInIterationStatement = false;
45545             while (current && !ts.nodeStartsNewLexicalEnvironment(current)) {
45546                 if (ts.isIterationStatement(current, false)) {
45547                     containedInIterationStatement = true;
45548                     break;
45549                 }
45550                 current = current.parent;
45551             }
45552             if (containedInIterationStatement) {
45553                 if (usedInFunction) {
45554                     var capturesBlockScopeBindingInLoopBody = true;
45555                     if (ts.isForStatement(container)) {
45556                         var varDeclList = ts.getAncestor(symbol.valueDeclaration, 243);
45557                         if (varDeclList && varDeclList.parent === container) {
45558                             var part = getPartOfForStatementContainingNode(node.parent, container);
45559                             if (part) {
45560                                 var links = getNodeLinks(part);
45561                                 links.flags |= 131072;
45562                                 var capturedBindings = links.capturedBlockScopeBindings || (links.capturedBlockScopeBindings = []);
45563                                 ts.pushIfUnique(capturedBindings, symbol);
45564                                 if (part === container.initializer) {
45565                                     capturesBlockScopeBindingInLoopBody = false;
45566                                 }
45567                             }
45568                         }
45569                     }
45570                     if (capturesBlockScopeBindingInLoopBody) {
45571                         getNodeLinks(current).flags |= 65536;
45572                     }
45573                 }
45574                 if (ts.isForStatement(container)) {
45575                     var varDeclList = ts.getAncestor(symbol.valueDeclaration, 243);
45576                     if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) {
45577                         getNodeLinks(symbol.valueDeclaration).flags |= 4194304;
45578                     }
45579                 }
45580                 getNodeLinks(symbol.valueDeclaration).flags |= 524288;
45581             }
45582             if (usedInFunction) {
45583                 getNodeLinks(symbol.valueDeclaration).flags |= 262144;
45584             }
45585         }
45586         function isBindingCapturedByNode(node, decl) {
45587             var links = getNodeLinks(node);
45588             return !!links && ts.contains(links.capturedBlockScopeBindings, getSymbolOfNode(decl));
45589         }
45590         function isAssignedInBodyOfForStatement(node, container) {
45591             var current = node;
45592             while (current.parent.kind === 200) {
45593                 current = current.parent;
45594             }
45595             var isAssigned = false;
45596             if (ts.isAssignmentTarget(current)) {
45597                 isAssigned = true;
45598             }
45599             else if ((current.parent.kind === 207 || current.parent.kind === 208)) {
45600                 var expr = current.parent;
45601                 isAssigned = expr.operator === 45 || expr.operator === 46;
45602             }
45603             if (!isAssigned) {
45604                 return false;
45605             }
45606             return !!ts.findAncestor(current, function (n) { return n === container ? "quit" : n === container.statement; });
45607         }
45608         function captureLexicalThis(node, container) {
45609             getNodeLinks(node).flags |= 2;
45610             if (container.kind === 159 || container.kind === 162) {
45611                 var classNode = container.parent;
45612                 getNodeLinks(classNode).flags |= 4;
45613             }
45614             else {
45615                 getNodeLinks(container).flags |= 4;
45616             }
45617         }
45618         function findFirstSuperCall(n) {
45619             if (ts.isSuperCall(n)) {
45620                 return n;
45621             }
45622             else if (ts.isFunctionLike(n)) {
45623                 return undefined;
45624             }
45625             return ts.forEachChild(n, findFirstSuperCall);
45626         }
45627         function getSuperCallInConstructor(constructor) {
45628             var links = getNodeLinks(constructor);
45629             if (links.hasSuperCall === undefined) {
45630                 links.superCall = findFirstSuperCall(constructor.body);
45631                 links.hasSuperCall = links.superCall ? true : false;
45632             }
45633             return links.superCall;
45634         }
45635         function classDeclarationExtendsNull(classDecl) {
45636             var classSymbol = getSymbolOfNode(classDecl);
45637             var classInstanceType = getDeclaredTypeOfSymbol(classSymbol);
45638             var baseConstructorType = getBaseConstructorTypeOfClass(classInstanceType);
45639             return baseConstructorType === nullWideningType;
45640         }
45641         function checkThisBeforeSuper(node, container, diagnosticMessage) {
45642             var containingClassDecl = container.parent;
45643             var baseTypeNode = ts.getClassExtendsHeritageElement(containingClassDecl);
45644             if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) {
45645                 var superCall = getSuperCallInConstructor(container);
45646                 if (!superCall || superCall.end > node.pos) {
45647                     error(node, diagnosticMessage);
45648                 }
45649             }
45650         }
45651         function checkThisExpression(node) {
45652             var container = ts.getThisContainer(node, true);
45653             var capturedByArrowFunction = false;
45654             if (container.kind === 162) {
45655                 checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class);
45656             }
45657             if (container.kind === 202) {
45658                 container = ts.getThisContainer(container, false);
45659                 capturedByArrowFunction = true;
45660             }
45661             switch (container.kind) {
45662                 case 249:
45663                     error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body);
45664                     break;
45665                 case 248:
45666                     error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location);
45667                     break;
45668                 case 162:
45669                     if (isInConstructorArgumentInitializer(node, container)) {
45670                         error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments);
45671                     }
45672                     break;
45673                 case 159:
45674                 case 158:
45675                     if (ts.hasModifier(container, 32) && !(compilerOptions.target === 99 && compilerOptions.useDefineForClassFields)) {
45676                         error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer);
45677                     }
45678                     break;
45679                 case 154:
45680                     error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name);
45681                     break;
45682             }
45683             if (capturedByArrowFunction && languageVersion < 2) {
45684                 captureLexicalThis(node, container);
45685             }
45686             var type = tryGetThisTypeAt(node, true, container);
45687             if (noImplicitThis) {
45688                 var globalThisType_1 = getTypeOfSymbol(globalThisSymbol);
45689                 if (type === globalThisType_1 && capturedByArrowFunction) {
45690                     error(node, ts.Diagnostics.The_containing_arrow_function_captures_the_global_value_of_this);
45691                 }
45692                 else if (!type) {
45693                     var diag = error(node, ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation);
45694                     if (!ts.isSourceFile(container)) {
45695                         var outsideThis = tryGetThisTypeAt(container);
45696                         if (outsideThis && outsideThis !== globalThisType_1) {
45697                             ts.addRelatedInfo(diag, ts.createDiagnosticForNode(container, ts.Diagnostics.An_outer_value_of_this_is_shadowed_by_this_container));
45698                         }
45699                     }
45700                 }
45701             }
45702             return type || anyType;
45703         }
45704         function tryGetThisTypeAt(node, includeGlobalThis, container) {
45705             if (includeGlobalThis === void 0) { includeGlobalThis = true; }
45706             if (container === void 0) { container = ts.getThisContainer(node, false); }
45707             var isInJS = ts.isInJSFile(node);
45708             if (ts.isFunctionLike(container) &&
45709                 (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) {
45710                 var className = getClassNameFromPrototypeMethod(container);
45711                 if (isInJS && className) {
45712                     var classSymbol = checkExpression(className).symbol;
45713                     if (classSymbol && classSymbol.members && (classSymbol.flags & 16)) {
45714                         var classType = getDeclaredTypeOfSymbol(classSymbol).thisType;
45715                         if (classType) {
45716                             return getFlowTypeOfReference(node, classType);
45717                         }
45718                     }
45719                 }
45720                 else if (isInJS &&
45721                     (container.kind === 201 || container.kind === 244) &&
45722                     ts.getJSDocClassTag(container)) {
45723                     var classType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType;
45724                     return getFlowTypeOfReference(node, classType);
45725                 }
45726                 var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container);
45727                 if (thisType) {
45728                     return getFlowTypeOfReference(node, thisType);
45729                 }
45730             }
45731             if (ts.isClassLike(container.parent)) {
45732                 var symbol = getSymbolOfNode(container.parent);
45733                 var type = ts.hasModifier(container, 32) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType;
45734                 return getFlowTypeOfReference(node, type);
45735             }
45736             if (isInJS) {
45737                 var type = getTypeForThisExpressionFromJSDoc(container);
45738                 if (type && type !== errorType) {
45739                     return getFlowTypeOfReference(node, type);
45740                 }
45741             }
45742             if (ts.isSourceFile(container)) {
45743                 if (container.commonJsModuleIndicator) {
45744                     var fileSymbol = getSymbolOfNode(container);
45745                     return fileSymbol && getTypeOfSymbol(fileSymbol);
45746                 }
45747                 else if (includeGlobalThis) {
45748                     return getTypeOfSymbol(globalThisSymbol);
45749                 }
45750             }
45751         }
45752         function getExplicitThisType(node) {
45753             var container = ts.getThisContainer(node, false);
45754             if (ts.isFunctionLike(container)) {
45755                 var signature = getSignatureFromDeclaration(container);
45756                 if (signature.thisParameter) {
45757                     return getExplicitTypeOfSymbol(signature.thisParameter);
45758                 }
45759             }
45760             if (ts.isClassLike(container.parent)) {
45761                 var symbol = getSymbolOfNode(container.parent);
45762                 return ts.hasModifier(container, 32) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType;
45763             }
45764         }
45765         function getClassNameFromPrototypeMethod(container) {
45766             if (container.kind === 201 &&
45767                 ts.isBinaryExpression(container.parent) &&
45768                 ts.getAssignmentDeclarationKind(container.parent) === 3) {
45769                 return container.parent
45770                     .left
45771                     .expression
45772                     .expression;
45773             }
45774             else if (container.kind === 161 &&
45775                 container.parent.kind === 193 &&
45776                 ts.isBinaryExpression(container.parent.parent) &&
45777                 ts.getAssignmentDeclarationKind(container.parent.parent) === 6) {
45778                 return container.parent.parent.left.expression;
45779             }
45780             else if (container.kind === 201 &&
45781                 container.parent.kind === 281 &&
45782                 container.parent.parent.kind === 193 &&
45783                 ts.isBinaryExpression(container.parent.parent.parent) &&
45784                 ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6) {
45785                 return container.parent.parent.parent.left.expression;
45786             }
45787             else if (container.kind === 201 &&
45788                 ts.isPropertyAssignment(container.parent) &&
45789                 ts.isIdentifier(container.parent.name) &&
45790                 (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") &&
45791                 ts.isObjectLiteralExpression(container.parent.parent) &&
45792                 ts.isCallExpression(container.parent.parent.parent) &&
45793                 container.parent.parent.parent.arguments[2] === container.parent.parent &&
45794                 ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9) {
45795                 return container.parent.parent.parent.arguments[0].expression;
45796             }
45797             else if (ts.isMethodDeclaration(container) &&
45798                 ts.isIdentifier(container.name) &&
45799                 (container.name.escapedText === "value" || container.name.escapedText === "get" || container.name.escapedText === "set") &&
45800                 ts.isObjectLiteralExpression(container.parent) &&
45801                 ts.isCallExpression(container.parent.parent) &&
45802                 container.parent.parent.arguments[2] === container.parent &&
45803                 ts.getAssignmentDeclarationKind(container.parent.parent) === 9) {
45804                 return container.parent.parent.arguments[0].expression;
45805             }
45806         }
45807         function getTypeForThisExpressionFromJSDoc(node) {
45808             var jsdocType = ts.getJSDocType(node);
45809             if (jsdocType && jsdocType.kind === 300) {
45810                 var jsDocFunctionType = jsdocType;
45811                 if (jsDocFunctionType.parameters.length > 0 &&
45812                     jsDocFunctionType.parameters[0].name &&
45813                     jsDocFunctionType.parameters[0].name.escapedText === "this") {
45814                     return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type);
45815                 }
45816             }
45817             var thisTag = ts.getJSDocThisTag(node);
45818             if (thisTag && thisTag.typeExpression) {
45819                 return getTypeFromTypeNode(thisTag.typeExpression);
45820             }
45821         }
45822         function isInConstructorArgumentInitializer(node, constructorDecl) {
45823             return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 156 && n.parent === constructorDecl; });
45824         }
45825         function checkSuperExpression(node) {
45826             var isCallExpression = node.parent.kind === 196 && node.parent.expression === node;
45827             var container = ts.getSuperContainer(node, true);
45828             var needToCaptureLexicalThis = false;
45829             if (!isCallExpression) {
45830                 while (container && container.kind === 202) {
45831                     container = ts.getSuperContainer(container, true);
45832                     needToCaptureLexicalThis = languageVersion < 2;
45833                 }
45834             }
45835             var canUseSuperExpression = isLegalUsageOfSuperExpression(container);
45836             var nodeCheckFlag = 0;
45837             if (!canUseSuperExpression) {
45838                 var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 154; });
45839                 if (current && current.kind === 154) {
45840                     error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name);
45841                 }
45842                 else if (isCallExpression) {
45843                     error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors);
45844                 }
45845                 else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 193)) {
45846                     error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions);
45847                 }
45848                 else {
45849                     error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class);
45850                 }
45851                 return errorType;
45852             }
45853             if (!isCallExpression && container.kind === 162) {
45854                 checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class);
45855             }
45856             if (ts.hasModifier(container, 32) || isCallExpression) {
45857                 nodeCheckFlag = 512;
45858             }
45859             else {
45860                 nodeCheckFlag = 256;
45861             }
45862             getNodeLinks(node).flags |= nodeCheckFlag;
45863             if (container.kind === 161 && ts.hasModifier(container, 256)) {
45864                 if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) {
45865                     getNodeLinks(container).flags |= 4096;
45866                 }
45867                 else {
45868                     getNodeLinks(container).flags |= 2048;
45869                 }
45870             }
45871             if (needToCaptureLexicalThis) {
45872                 captureLexicalThis(node.parent, container);
45873             }
45874             if (container.parent.kind === 193) {
45875                 if (languageVersion < 2) {
45876                     error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher);
45877                     return errorType;
45878                 }
45879                 else {
45880                     return anyType;
45881                 }
45882             }
45883             var classLikeDeclaration = container.parent;
45884             if (!ts.getClassExtendsHeritageElement(classLikeDeclaration)) {
45885                 error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class);
45886                 return errorType;
45887             }
45888             var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classLikeDeclaration));
45889             var baseClassType = classType && getBaseTypes(classType)[0];
45890             if (!baseClassType) {
45891                 return errorType;
45892             }
45893             if (container.kind === 162 && isInConstructorArgumentInitializer(node, container)) {
45894                 error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments);
45895                 return errorType;
45896             }
45897             return nodeCheckFlag === 512
45898                 ? getBaseConstructorTypeOfClass(classType)
45899                 : getTypeWithThisArgument(baseClassType, classType.thisType);
45900             function isLegalUsageOfSuperExpression(container) {
45901                 if (!container) {
45902                     return false;
45903                 }
45904                 if (isCallExpression) {
45905                     return container.kind === 162;
45906                 }
45907                 else {
45908                     if (ts.isClassLike(container.parent) || container.parent.kind === 193) {
45909                         if (ts.hasModifier(container, 32)) {
45910                             return container.kind === 161 ||
45911                                 container.kind === 160 ||
45912                                 container.kind === 163 ||
45913                                 container.kind === 164;
45914                         }
45915                         else {
45916                             return container.kind === 161 ||
45917                                 container.kind === 160 ||
45918                                 container.kind === 163 ||
45919                                 container.kind === 164 ||
45920                                 container.kind === 159 ||
45921                                 container.kind === 158 ||
45922                                 container.kind === 162;
45923                         }
45924                     }
45925                 }
45926                 return false;
45927             }
45928         }
45929         function getContainingObjectLiteral(func) {
45930             return (func.kind === 161 ||
45931                 func.kind === 163 ||
45932                 func.kind === 164) && func.parent.kind === 193 ? func.parent :
45933                 func.kind === 201 && func.parent.kind === 281 ? func.parent.parent :
45934                     undefined;
45935         }
45936         function getThisTypeArgument(type) {
45937             return ts.getObjectFlags(type) & 4 && type.target === globalThisType ? getTypeArguments(type)[0] : undefined;
45938         }
45939         function getThisTypeFromContextualType(type) {
45940             return mapType(type, function (t) {
45941                 return t.flags & 2097152 ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t);
45942             });
45943         }
45944         function getContextualThisParameterType(func) {
45945             if (func.kind === 202) {
45946                 return undefined;
45947             }
45948             if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
45949                 var contextualSignature = getContextualSignature(func);
45950                 if (contextualSignature) {
45951                     var thisParameter = contextualSignature.thisParameter;
45952                     if (thisParameter) {
45953                         return getTypeOfSymbol(thisParameter);
45954                     }
45955                 }
45956             }
45957             var inJs = ts.isInJSFile(func);
45958             if (noImplicitThis || inJs) {
45959                 var containingLiteral = getContainingObjectLiteral(func);
45960                 if (containingLiteral) {
45961                     var contextualType = getApparentTypeOfContextualType(containingLiteral);
45962                     var literal = containingLiteral;
45963                     var type = contextualType;
45964                     while (type) {
45965                         var thisType = getThisTypeFromContextualType(type);
45966                         if (thisType) {
45967                             return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral)));
45968                         }
45969                         if (literal.parent.kind !== 281) {
45970                             break;
45971                         }
45972                         literal = literal.parent.parent;
45973                         type = getApparentTypeOfContextualType(literal);
45974                     }
45975                     return getWidenedType(contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral));
45976                 }
45977                 var parent = ts.walkUpParenthesizedExpressions(func.parent);
45978                 if (parent.kind === 209 && parent.operatorToken.kind === 62) {
45979                     var target = parent.left;
45980                     if (ts.isAccessExpression(target)) {
45981                         var expression = target.expression;
45982                         if (inJs && ts.isIdentifier(expression)) {
45983                             var sourceFile = ts.getSourceFileOfNode(parent);
45984                             if (sourceFile.commonJsModuleIndicator && getResolvedSymbol(expression) === sourceFile.symbol) {
45985                                 return undefined;
45986                             }
45987                         }
45988                         return getWidenedType(checkExpressionCached(expression));
45989                     }
45990                 }
45991             }
45992             return undefined;
45993         }
45994         function getContextuallyTypedParameterType(parameter) {
45995             var func = parameter.parent;
45996             if (!isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
45997                 return undefined;
45998             }
45999             var iife = ts.getImmediatelyInvokedFunctionExpression(func);
46000             if (iife && iife.arguments) {
46001                 var args = getEffectiveCallArguments(iife);
46002                 var indexOfParameter = func.parameters.indexOf(parameter);
46003                 if (parameter.dotDotDotToken) {
46004                     return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, undefined);
46005                 }
46006                 var links = getNodeLinks(iife);
46007                 var cached = links.resolvedSignature;
46008                 links.resolvedSignature = anySignature;
46009                 var type = indexOfParameter < args.length ?
46010                     getWidenedLiteralType(checkExpression(args[indexOfParameter])) :
46011                     parameter.initializer ? undefined : undefinedWideningType;
46012                 links.resolvedSignature = cached;
46013                 return type;
46014             }
46015             var contextualSignature = getContextualSignature(func);
46016             if (contextualSignature) {
46017                 var index = func.parameters.indexOf(parameter) - (ts.getThisParameter(func) ? 1 : 0);
46018                 return parameter.dotDotDotToken && ts.lastOrUndefined(func.parameters) === parameter ?
46019                     getRestTypeAtPosition(contextualSignature, index) :
46020                     tryGetTypeAtPosition(contextualSignature, index);
46021             }
46022         }
46023         function getContextualTypeForVariableLikeDeclaration(declaration) {
46024             var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
46025             if (typeNode) {
46026                 return getTypeFromTypeNode(typeNode);
46027             }
46028             switch (declaration.kind) {
46029                 case 156:
46030                     return getContextuallyTypedParameterType(declaration);
46031                 case 191:
46032                     return getContextualTypeForBindingElement(declaration);
46033             }
46034         }
46035         function getContextualTypeForBindingElement(declaration) {
46036             var parent = declaration.parent.parent;
46037             var name = declaration.propertyName || declaration.name;
46038             var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
46039                 parent.kind !== 191 && parent.initializer && checkDeclarationInitializer(parent);
46040             if (parentType && !ts.isBindingPattern(name) && !ts.isComputedNonLiteralName(name)) {
46041                 var nameType = getLiteralTypeFromPropertyName(name);
46042                 if (isTypeUsableAsPropertyName(nameType)) {
46043                     var text = getPropertyNameFromType(nameType);
46044                     return getTypeOfPropertyOfType(parentType, text);
46045                 }
46046             }
46047         }
46048         function getContextualTypeForInitializerExpression(node) {
46049             var declaration = node.parent;
46050             if (ts.hasInitializer(declaration) && node === declaration.initializer) {
46051                 var result = getContextualTypeForVariableLikeDeclaration(declaration);
46052                 if (result) {
46053                     return result;
46054                 }
46055                 if (ts.isBindingPattern(declaration.name)) {
46056                     return getTypeFromBindingPattern(declaration.name, true, false);
46057                 }
46058             }
46059             return undefined;
46060         }
46061         function getContextualTypeForReturnExpression(node) {
46062             var func = ts.getContainingFunction(node);
46063             if (func) {
46064                 var functionFlags = ts.getFunctionFlags(func);
46065                 if (functionFlags & 1) {
46066                     return undefined;
46067                 }
46068                 var contextualReturnType = getContextualReturnType(func);
46069                 if (contextualReturnType) {
46070                     if (functionFlags & 2) {
46071                         var contextualAwaitedType = mapType(contextualReturnType, getAwaitedTypeOfPromise);
46072                         return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]);
46073                     }
46074                     return contextualReturnType;
46075                 }
46076             }
46077             return undefined;
46078         }
46079         function getContextualTypeForAwaitOperand(node) {
46080             var contextualType = getContextualType(node);
46081             if (contextualType) {
46082                 var contextualAwaitedType = getAwaitedType(contextualType);
46083                 return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]);
46084             }
46085             return undefined;
46086         }
46087         function getContextualTypeForYieldOperand(node) {
46088             var func = ts.getContainingFunction(node);
46089             if (func) {
46090                 var functionFlags = ts.getFunctionFlags(func);
46091                 var contextualReturnType = getContextualReturnType(func);
46092                 if (contextualReturnType) {
46093                     return node.asteriskToken
46094                         ? contextualReturnType
46095                         : getIterationTypeOfGeneratorFunctionReturnType(0, contextualReturnType, (functionFlags & 2) !== 0);
46096                 }
46097             }
46098             return undefined;
46099         }
46100         function isInParameterInitializerBeforeContainingFunction(node) {
46101             var inBindingInitializer = false;
46102             while (node.parent && !ts.isFunctionLike(node.parent)) {
46103                 if (ts.isParameter(node.parent) && (inBindingInitializer || node.parent.initializer === node)) {
46104                     return true;
46105                 }
46106                 if (ts.isBindingElement(node.parent) && node.parent.initializer === node) {
46107                     inBindingInitializer = true;
46108                 }
46109                 node = node.parent;
46110             }
46111             return false;
46112         }
46113         function getContextualIterationType(kind, functionDecl) {
46114             var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2);
46115             var contextualReturnType = getContextualReturnType(functionDecl);
46116             if (contextualReturnType) {
46117                 return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync)
46118                     || undefined;
46119             }
46120             return undefined;
46121         }
46122         function getContextualReturnType(functionDecl) {
46123             var returnType = getReturnTypeFromAnnotation(functionDecl);
46124             if (returnType) {
46125                 return returnType;
46126             }
46127             var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl);
46128             if (signature && !isResolvingReturnTypeOfSignature(signature)) {
46129                 return getReturnTypeOfSignature(signature);
46130             }
46131             return undefined;
46132         }
46133         function getContextualTypeForArgument(callTarget, arg) {
46134             var args = getEffectiveCallArguments(callTarget);
46135             var argIndex = args.indexOf(arg);
46136             return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex);
46137         }
46138         function getContextualTypeForArgumentAtIndex(callTarget, argIndex) {
46139             var signature = getNodeLinks(callTarget).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(callTarget);
46140             if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) {
46141                 return getEffectiveFirstArgumentForJsxSignature(signature, callTarget);
46142             }
46143             return getTypeAtPosition(signature, argIndex);
46144         }
46145         function getContextualTypeForSubstitutionExpression(template, substitutionExpression) {
46146             if (template.parent.kind === 198) {
46147                 return getContextualTypeForArgument(template.parent, substitutionExpression);
46148             }
46149             return undefined;
46150         }
46151         function getContextualTypeForBinaryOperand(node, contextFlags) {
46152             var binaryExpression = node.parent;
46153             var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right;
46154             switch (operatorToken.kind) {
46155                 case 62:
46156                     if (node !== right) {
46157                         return undefined;
46158                     }
46159                     var contextSensitive = getIsContextSensitiveAssignmentOrContextType(binaryExpression);
46160                     if (!contextSensitive) {
46161                         return undefined;
46162                     }
46163                     return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive;
46164                 case 56:
46165                 case 60:
46166                     var type = getContextualType(binaryExpression, contextFlags);
46167                     return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ?
46168                         getTypeOfExpression(left) : type;
46169                 case 55:
46170                 case 27:
46171                     return node === right ? getContextualType(binaryExpression, contextFlags) : undefined;
46172                 default:
46173                     return undefined;
46174             }
46175         }
46176         function getIsContextSensitiveAssignmentOrContextType(binaryExpression) {
46177             var kind = ts.getAssignmentDeclarationKind(binaryExpression);
46178             switch (kind) {
46179                 case 0:
46180                     return true;
46181                 case 5:
46182                 case 1:
46183                 case 6:
46184                 case 3:
46185                     if (!binaryExpression.left.symbol) {
46186                         return true;
46187                     }
46188                     else {
46189                         var decl = binaryExpression.left.symbol.valueDeclaration;
46190                         if (!decl) {
46191                             return false;
46192                         }
46193                         var lhs = ts.cast(binaryExpression.left, ts.isAccessExpression);
46194                         var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl);
46195                         if (overallAnnotation) {
46196                             return getTypeFromTypeNode(overallAnnotation);
46197                         }
46198                         else if (ts.isIdentifier(lhs.expression)) {
46199                             var id = lhs.expression;
46200                             var parentSymbol = resolveName(id, id.escapedText, 111551, undefined, id.escapedText, true);
46201                             if (parentSymbol) {
46202                                 var annotated = ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration);
46203                                 if (annotated) {
46204                                     var nameStr_1 = ts.getElementOrPropertyAccessName(lhs);
46205                                     if (nameStr_1 !== undefined) {
46206                                         var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr_1);
46207                                         return type || false;
46208                                     }
46209                                 }
46210                                 return false;
46211                             }
46212                         }
46213                         return !ts.isInJSFile(decl);
46214                     }
46215                 case 2:
46216                 case 4:
46217                     if (!binaryExpression.symbol)
46218                         return true;
46219                     if (binaryExpression.symbol.valueDeclaration) {
46220                         var annotated = ts.getEffectiveTypeAnnotationNode(binaryExpression.symbol.valueDeclaration);
46221                         if (annotated) {
46222                             var type = getTypeFromTypeNode(annotated);
46223                             if (type) {
46224                                 return type;
46225                             }
46226                         }
46227                     }
46228                     if (kind === 2)
46229                         return false;
46230                     var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression);
46231                     if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, false))) {
46232                         return false;
46233                     }
46234                     var thisType = checkThisExpression(thisAccess.expression);
46235                     var nameStr = ts.getElementOrPropertyAccessName(thisAccess);
46236                     return nameStr !== undefined && thisType && getTypeOfPropertyOfContextualType(thisType, nameStr) || false;
46237                 case 7:
46238                 case 8:
46239                 case 9:
46240                     return ts.Debug.fail("Does not apply");
46241                 default:
46242                     return ts.Debug.assertNever(kind);
46243             }
46244         }
46245         function getTypeOfPropertyOfContextualType(type, name) {
46246             return mapType(type, function (t) {
46247                 if (isGenericMappedType(t)) {
46248                     var constraint = getConstraintTypeFromMappedType(t);
46249                     var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
46250                     var propertyNameType = getLiteralType(ts.unescapeLeadingUnderscores(name));
46251                     if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
46252                         return substituteIndexedMappedType(t, propertyNameType);
46253                     }
46254                 }
46255                 else if (t.flags & 3670016) {
46256                     var prop = getPropertyOfType(t, name);
46257                     if (prop) {
46258                         return getTypeOfSymbol(prop);
46259                     }
46260                     if (isTupleType(t)) {
46261                         var restType = getRestTypeOfTupleType(t);
46262                         if (restType && isNumericLiteralName(name) && +name >= 0) {
46263                             return restType;
46264                         }
46265                     }
46266                     return isNumericLiteralName(name) && getIndexTypeOfContextualType(t, 1) ||
46267                         getIndexTypeOfContextualType(t, 0);
46268                 }
46269                 return undefined;
46270             }, true);
46271         }
46272         function getIndexTypeOfContextualType(type, kind) {
46273             return mapType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }, true);
46274         }
46275         function getContextualTypeForObjectLiteralMethod(node, contextFlags) {
46276             ts.Debug.assert(ts.isObjectLiteralMethod(node));
46277             if (node.flags & 16777216) {
46278                 return undefined;
46279             }
46280             return getContextualTypeForObjectLiteralElement(node, contextFlags);
46281         }
46282         function getContextualTypeForObjectLiteralElement(element, contextFlags) {
46283             var objectLiteral = element.parent;
46284             var type = getApparentTypeOfContextualType(objectLiteral, contextFlags);
46285             if (type) {
46286                 if (!hasNonBindableDynamicName(element)) {
46287                     var symbolName_3 = getSymbolOfNode(element).escapedName;
46288                     var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3);
46289                     if (propertyType) {
46290                         return propertyType;
46291                     }
46292                 }
46293                 return isNumericName(element.name) && getIndexTypeOfContextualType(type, 1) ||
46294                     getIndexTypeOfContextualType(type, 0);
46295             }
46296             return undefined;
46297         }
46298         function getContextualTypeForElementExpression(arrayContextualType, index) {
46299             return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index)
46300                 || getIteratedTypeOrElementType(1, arrayContextualType, undefinedType, undefined, false));
46301         }
46302         function getContextualTypeForConditionalOperand(node, contextFlags) {
46303             var conditional = node.parent;
46304             return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional, contextFlags) : undefined;
46305         }
46306         function getContextualTypeForChildJsxExpression(node, child) {
46307             var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName);
46308             var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
46309             if (!(attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "")) {
46310                 return undefined;
46311             }
46312             var realChildren = getSemanticJsxChildren(node.children);
46313             var childIndex = realChildren.indexOf(child);
46314             var childFieldType = getTypeOfPropertyOfContextualType(attributesType, jsxChildrenPropertyName);
46315             return childFieldType && (realChildren.length === 1 ? childFieldType : mapType(childFieldType, function (t) {
46316                 if (isArrayLikeType(t)) {
46317                     return getIndexedAccessType(t, getLiteralType(childIndex));
46318                 }
46319                 else {
46320                     return t;
46321                 }
46322             }, true));
46323         }
46324         function getContextualTypeForJsxExpression(node) {
46325             var exprParent = node.parent;
46326             return ts.isJsxAttributeLike(exprParent)
46327                 ? getContextualType(node)
46328                 : ts.isJsxElement(exprParent)
46329                     ? getContextualTypeForChildJsxExpression(exprParent, node)
46330                     : undefined;
46331         }
46332         function getContextualTypeForJsxAttribute(attribute) {
46333             if (ts.isJsxAttribute(attribute)) {
46334                 var attributesType = getApparentTypeOfContextualType(attribute.parent);
46335                 if (!attributesType || isTypeAny(attributesType)) {
46336                     return undefined;
46337                 }
46338                 return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText);
46339             }
46340             else {
46341                 return getContextualType(attribute.parent);
46342             }
46343         }
46344         function isPossiblyDiscriminantValue(node) {
46345             switch (node.kind) {
46346                 case 10:
46347                 case 8:
46348                 case 9:
46349                 case 14:
46350                 case 106:
46351                 case 91:
46352                 case 100:
46353                 case 75:
46354                 case 146:
46355                     return true;
46356                 case 194:
46357                 case 200:
46358                     return isPossiblyDiscriminantValue(node.expression);
46359                 case 276:
46360                     return !node.expression || isPossiblyDiscriminantValue(node.expression);
46361             }
46362             return false;
46363         }
46364         function discriminateContextualTypeByObjectMembers(node, contextualType) {
46365             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);
46366         }
46367         function discriminateContextualTypeByJSXAttributes(node, contextualType) {
46368             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);
46369         }
46370         function getApparentTypeOfContextualType(node, contextFlags) {
46371             var contextualType = ts.isObjectLiteralMethod(node) ?
46372                 getContextualTypeForObjectLiteralMethod(node, contextFlags) :
46373                 getContextualType(node, contextFlags);
46374             var instantiatedType = instantiateContextualType(contextualType, node, contextFlags);
46375             if (instantiatedType && !(contextFlags && contextFlags & 2 && instantiatedType.flags & 8650752)) {
46376                 var apparentType = mapType(instantiatedType, getApparentType, true);
46377                 if (apparentType.flags & 1048576) {
46378                     if (ts.isObjectLiteralExpression(node)) {
46379                         return discriminateContextualTypeByObjectMembers(node, apparentType);
46380                     }
46381                     else if (ts.isJsxAttributes(node)) {
46382                         return discriminateContextualTypeByJSXAttributes(node, apparentType);
46383                     }
46384                 }
46385                 return apparentType;
46386             }
46387         }
46388         function instantiateContextualType(contextualType, node, contextFlags) {
46389             if (contextualType && maybeTypeOfKind(contextualType, 63176704)) {
46390                 var inferenceContext = getInferenceContext(node);
46391                 if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
46392                     if (contextFlags && contextFlags & 1) {
46393                         return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
46394                     }
46395                     if (inferenceContext.returnMapper) {
46396                         return instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
46397                     }
46398                 }
46399             }
46400             return contextualType;
46401         }
46402         function instantiateInstantiableTypes(type, mapper) {
46403             if (type.flags & 63176704) {
46404                 return instantiateType(type, mapper);
46405             }
46406             if (type.flags & 1048576) {
46407                 return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0);
46408             }
46409             if (type.flags & 2097152) {
46410                 return getIntersectionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }));
46411             }
46412             return type;
46413         }
46414         function getContextualType(node, contextFlags) {
46415             if (node.flags & 16777216) {
46416                 return undefined;
46417             }
46418             if (node.contextualType) {
46419                 return node.contextualType;
46420             }
46421             var parent = node.parent;
46422             switch (parent.kind) {
46423                 case 242:
46424                 case 156:
46425                 case 159:
46426                 case 158:
46427                 case 191:
46428                     return getContextualTypeForInitializerExpression(node);
46429                 case 202:
46430                 case 235:
46431                     return getContextualTypeForReturnExpression(node);
46432                 case 212:
46433                     return getContextualTypeForYieldOperand(parent);
46434                 case 206:
46435                     return getContextualTypeForAwaitOperand(parent);
46436                 case 196:
46437                     if (parent.expression.kind === 96) {
46438                         return stringType;
46439                     }
46440                 case 197:
46441                     return getContextualTypeForArgument(parent, node);
46442                 case 199:
46443                 case 217:
46444                     return ts.isConstTypeReference(parent.type) ? undefined : getTypeFromTypeNode(parent.type);
46445                 case 209:
46446                     return getContextualTypeForBinaryOperand(node, contextFlags);
46447                 case 281:
46448                 case 282:
46449                     return getContextualTypeForObjectLiteralElement(parent, contextFlags);
46450                 case 283:
46451                     return getApparentTypeOfContextualType(parent.parent, contextFlags);
46452                 case 192: {
46453                     var arrayLiteral = parent;
46454                     var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags);
46455                     return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node));
46456                 }
46457                 case 210:
46458                     return getContextualTypeForConditionalOperand(node, contextFlags);
46459                 case 221:
46460                     ts.Debug.assert(parent.parent.kind === 211);
46461                     return getContextualTypeForSubstitutionExpression(parent.parent, node);
46462                 case 200: {
46463                     var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined;
46464                     return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags);
46465                 }
46466                 case 276:
46467                     return getContextualTypeForJsxExpression(parent);
46468                 case 273:
46469                 case 275:
46470                     return getContextualTypeForJsxAttribute(parent);
46471                 case 268:
46472                 case 267:
46473                     return getContextualJsxElementAttributesType(parent, contextFlags);
46474             }
46475             return undefined;
46476         }
46477         function getInferenceContext(node) {
46478             var ancestor = ts.findAncestor(node, function (n) { return !!n.inferenceContext; });
46479             return ancestor && ancestor.inferenceContext;
46480         }
46481         function getContextualJsxElementAttributesType(node, contextFlags) {
46482             if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4) {
46483                 return node.parent.contextualType;
46484             }
46485             return getContextualTypeForArgumentAtIndex(node, 0);
46486         }
46487         function getEffectiveFirstArgumentForJsxSignature(signature, node) {
46488             return getJsxReferenceKind(node) !== 0
46489                 ? getJsxPropsTypeFromCallSignature(signature, node)
46490                 : getJsxPropsTypeFromClassType(signature, node);
46491         }
46492         function getJsxPropsTypeFromCallSignature(sig, context) {
46493             var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType);
46494             propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType);
46495             var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
46496             if (intrinsicAttribs !== errorType) {
46497                 propsType = intersectTypes(intrinsicAttribs, propsType);
46498             }
46499             return propsType;
46500         }
46501         function getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation) {
46502             if (sig.unionSignatures) {
46503                 var results = [];
46504                 for (var _i = 0, _a = sig.unionSignatures; _i < _a.length; _i++) {
46505                     var signature = _a[_i];
46506                     var instance = getReturnTypeOfSignature(signature);
46507                     if (isTypeAny(instance)) {
46508                         return instance;
46509                     }
46510                     var propType = getTypeOfPropertyOfType(instance, forcedLookupLocation);
46511                     if (!propType) {
46512                         return;
46513                     }
46514                     results.push(propType);
46515                 }
46516                 return getIntersectionType(results);
46517             }
46518             var instanceType = getReturnTypeOfSignature(sig);
46519             return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation);
46520         }
46521         function getStaticTypeOfReferencedJsxConstructor(context) {
46522             if (isJsxIntrinsicIdentifier(context.tagName)) {
46523                 var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(context);
46524                 var fakeSignature = createSignatureForJSXIntrinsic(context, result);
46525                 return getOrCreateTypeFromSignature(fakeSignature);
46526             }
46527             var tagType = checkExpressionCached(context.tagName);
46528             if (tagType.flags & 128) {
46529                 var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context);
46530                 if (!result) {
46531                     return errorType;
46532                 }
46533                 var fakeSignature = createSignatureForJSXIntrinsic(context, result);
46534                 return getOrCreateTypeFromSignature(fakeSignature);
46535             }
46536             return tagType;
46537         }
46538         function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) {
46539             var managedSym = getJsxLibraryManagedAttributes(ns);
46540             if (managedSym) {
46541                 var declaredManagedType = getDeclaredTypeOfSymbol(managedSym);
46542                 var ctorType = getStaticTypeOfReferencedJsxConstructor(context);
46543                 if (ts.length(declaredManagedType.typeParameters) >= 2) {
46544                     var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context));
46545                     return createTypeReference(declaredManagedType, args);
46546                 }
46547                 else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) {
46548                     var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context));
46549                     return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args);
46550                 }
46551             }
46552             return attributesType;
46553         }
46554         function getJsxPropsTypeFromClassType(sig, context) {
46555             var ns = getJsxNamespaceAt(context);
46556             var forcedLookupLocation = getJsxElementPropertiesName(ns);
46557             var attributesType = forcedLookupLocation === undefined
46558                 ? getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType)
46559                 : forcedLookupLocation === ""
46560                     ? getReturnTypeOfSignature(sig)
46561                     : getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation);
46562             if (!attributesType) {
46563                 if (!!forcedLookupLocation && !!ts.length(context.attributes.properties)) {
46564                     error(context, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, ts.unescapeLeadingUnderscores(forcedLookupLocation));
46565                 }
46566                 return unknownType;
46567             }
46568             attributesType = getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType);
46569             if (isTypeAny(attributesType)) {
46570                 return attributesType;
46571             }
46572             else {
46573                 var apparentAttributesType = attributesType;
46574                 var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes, context);
46575                 if (intrinsicClassAttribs !== errorType) {
46576                     var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol);
46577                     var hostClassType = getReturnTypeOfSignature(sig);
46578                     apparentAttributesType = intersectTypes(typeParams
46579                         ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context)))
46580                         : intrinsicClassAttribs, apparentAttributesType);
46581                 }
46582                 var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
46583                 if (intrinsicAttribs !== errorType) {
46584                     apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType);
46585                 }
46586                 return apparentAttributesType;
46587             }
46588         }
46589         function getContextualCallSignature(type, node) {
46590             var signatures = getSignaturesOfType(type, 0);
46591             if (signatures.length === 1) {
46592                 var signature = signatures[0];
46593                 if (!isAritySmaller(signature, node)) {
46594                     return signature;
46595                 }
46596             }
46597         }
46598         function isAritySmaller(signature, target) {
46599             var targetParameterCount = 0;
46600             for (; targetParameterCount < target.parameters.length; targetParameterCount++) {
46601                 var param = target.parameters[targetParameterCount];
46602                 if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) {
46603                     break;
46604                 }
46605             }
46606             if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) {
46607                 targetParameterCount--;
46608             }
46609             return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount;
46610         }
46611         function isFunctionExpressionOrArrowFunction(node) {
46612             return node.kind === 201 || node.kind === 202;
46613         }
46614         function getContextualSignatureForFunctionLikeDeclaration(node) {
46615             return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node)
46616                 ? getContextualSignature(node)
46617                 : undefined;
46618         }
46619         function getContextualSignature(node) {
46620             ts.Debug.assert(node.kind !== 161 || ts.isObjectLiteralMethod(node));
46621             var typeTagSignature = getSignatureOfTypeTag(node);
46622             if (typeTagSignature) {
46623                 return typeTagSignature;
46624             }
46625             var type = getApparentTypeOfContextualType(node, 1);
46626             if (!type) {
46627                 return undefined;
46628             }
46629             if (!(type.flags & 1048576)) {
46630                 return getContextualCallSignature(type, node);
46631             }
46632             var signatureList;
46633             var types = type.types;
46634             for (var _i = 0, types_17 = types; _i < types_17.length; _i++) {
46635                 var current = types_17[_i];
46636                 var signature = getContextualCallSignature(current, node);
46637                 if (signature) {
46638                     if (!signatureList) {
46639                         signatureList = [signature];
46640                     }
46641                     else if (!compareSignaturesIdentical(signatureList[0], signature, false, true, true, compareTypesIdentical)) {
46642                         return undefined;
46643                     }
46644                     else {
46645                         signatureList.push(signature);
46646                     }
46647                 }
46648             }
46649             if (signatureList) {
46650                 return signatureList.length === 1 ? signatureList[0] : createUnionSignature(signatureList[0], signatureList);
46651             }
46652         }
46653         function checkSpreadExpression(node, checkMode) {
46654             if (languageVersion < 2) {
46655                 checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 : 2048);
46656             }
46657             var arrayOrIterableType = checkExpression(node.expression, checkMode);
46658             return checkIteratedTypeOrElementType(33, arrayOrIterableType, undefinedType, node.expression);
46659         }
46660         function hasDefaultValue(node) {
46661             return (node.kind === 191 && !!node.initializer) ||
46662                 (node.kind === 209 && node.operatorToken.kind === 62);
46663         }
46664         function checkArrayLiteral(node, checkMode, forceTuple) {
46665             var elements = node.elements;
46666             var elementCount = elements.length;
46667             var elementTypes = [];
46668             var hasEndingSpreadElement = false;
46669             var hasNonEndingSpreadElement = false;
46670             var contextualType = getApparentTypeOfContextualType(node);
46671             var inDestructuringPattern = ts.isAssignmentTarget(node);
46672             var inConstContext = isConstContext(node);
46673             for (var i = 0; i < elementCount; i++) {
46674                 var e = elements[i];
46675                 var spread = e.kind === 213 && e.expression;
46676                 var spreadType = spread && checkExpression(spread, checkMode, forceTuple);
46677                 if (spreadType && isTupleType(spreadType)) {
46678                     elementTypes.push.apply(elementTypes, getTypeArguments(spreadType));
46679                     if (spreadType.target.hasRestElement) {
46680                         if (i === elementCount - 1)
46681                             hasEndingSpreadElement = true;
46682                         else
46683                             hasNonEndingSpreadElement = true;
46684                     }
46685                 }
46686                 else {
46687                     if (inDestructuringPattern && spreadType) {
46688                         var restElementType = getIndexTypeOfType(spreadType, 1) ||
46689                             getIteratedTypeOrElementType(65, spreadType, undefinedType, undefined, false);
46690                         if (restElementType) {
46691                             elementTypes.push(restElementType);
46692                         }
46693                     }
46694                     else {
46695                         var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length);
46696                         var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple);
46697                         elementTypes.push(type);
46698                     }
46699                     if (spread) {
46700                         if (i === elementCount - 1)
46701                             hasEndingSpreadElement = true;
46702                         else
46703                             hasNonEndingSpreadElement = true;
46704                     }
46705                 }
46706             }
46707             if (!hasNonEndingSpreadElement) {
46708                 var minLength = elementTypes.length - (hasEndingSpreadElement ? 1 : 0);
46709                 var tupleResult = void 0;
46710                 if (inDestructuringPattern && minLength > 0) {
46711                     var type = cloneTypeReference(createTupleType(elementTypes, minLength, hasEndingSpreadElement));
46712                     type.pattern = node;
46713                     return type;
46714                 }
46715                 else if (tupleResult = getArrayLiteralTupleTypeIfApplicable(elementTypes, contextualType, hasEndingSpreadElement, elementTypes.length, inConstContext)) {
46716                     return createArrayLiteralType(tupleResult);
46717                 }
46718                 else if (forceTuple) {
46719                     return createArrayLiteralType(createTupleType(elementTypes, minLength, hasEndingSpreadElement));
46720                 }
46721             }
46722             return createArrayLiteralType(createArrayType(elementTypes.length ?
46723                 getUnionType(elementTypes, 2) :
46724                 strictNullChecks ? implicitNeverType : undefinedWideningType, inConstContext));
46725         }
46726         function createArrayLiteralType(type) {
46727             if (!(ts.getObjectFlags(type) & 4)) {
46728                 return type;
46729             }
46730             var literalType = type.literalType;
46731             if (!literalType) {
46732                 literalType = type.literalType = cloneTypeReference(type);
46733                 literalType.objectFlags |= 65536 | 1048576;
46734             }
46735             return literalType;
46736         }
46737         function getArrayLiteralTupleTypeIfApplicable(elementTypes, contextualType, hasRestElement, elementCount, readonly) {
46738             if (elementCount === void 0) { elementCount = elementTypes.length; }
46739             if (readonly === void 0) { readonly = false; }
46740             if (readonly || (contextualType && forEachType(contextualType, isTupleLikeType))) {
46741                 return createTupleType(elementTypes, elementCount - (hasRestElement ? 1 : 0), hasRestElement, readonly);
46742             }
46743         }
46744         function isNumericName(name) {
46745             switch (name.kind) {
46746                 case 154:
46747                     return isNumericComputedName(name);
46748                 case 75:
46749                     return isNumericLiteralName(name.escapedText);
46750                 case 8:
46751                 case 10:
46752                     return isNumericLiteralName(name.text);
46753                 default:
46754                     return false;
46755             }
46756         }
46757         function isNumericComputedName(name) {
46758             return isTypeAssignableToKind(checkComputedPropertyName(name), 296);
46759         }
46760         function isInfinityOrNaNString(name) {
46761             return name === "Infinity" || name === "-Infinity" || name === "NaN";
46762         }
46763         function isNumericLiteralName(name) {
46764             return (+name).toString() === name;
46765         }
46766         function checkComputedPropertyName(node) {
46767             var links = getNodeLinks(node.expression);
46768             if (!links.resolvedType) {
46769                 links.resolvedType = checkExpression(node.expression);
46770                 if (links.resolvedType.flags & 98304 ||
46771                     !isTypeAssignableToKind(links.resolvedType, 132 | 296 | 12288) &&
46772                         !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) {
46773                     error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any);
46774                 }
46775                 else {
46776                     checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, true);
46777                 }
46778             }
46779             return links.resolvedType;
46780         }
46781         function getObjectLiteralIndexInfo(node, offset, properties, kind) {
46782             var propTypes = [];
46783             for (var i = 0; i < properties.length; i++) {
46784                 if (kind === 0 || isNumericName(node.properties[i + offset].name)) {
46785                     propTypes.push(getTypeOfSymbol(properties[i]));
46786                 }
46787             }
46788             var unionType = propTypes.length ? getUnionType(propTypes, 2) : undefinedType;
46789             return createIndexInfo(unionType, isConstContext(node));
46790         }
46791         function getImmediateAliasedSymbol(symbol) {
46792             ts.Debug.assert((symbol.flags & 2097152) !== 0, "Should only get Alias here.");
46793             var links = getSymbolLinks(symbol);
46794             if (!links.immediateTarget) {
46795                 var node = getDeclarationOfAliasSymbol(symbol);
46796                 if (!node)
46797                     return ts.Debug.fail();
46798                 links.immediateTarget = getTargetOfAliasDeclaration(node, true);
46799             }
46800             return links.immediateTarget;
46801         }
46802         function checkObjectLiteral(node, checkMode) {
46803             var inDestructuringPattern = ts.isAssignmentTarget(node);
46804             checkGrammarObjectLiteralExpression(node, inDestructuringPattern);
46805             var allPropertiesTable = strictNullChecks ? ts.createSymbolTable() : undefined;
46806             var propertiesTable = ts.createSymbolTable();
46807             var propertiesArray = [];
46808             var spread = emptyObjectType;
46809             var contextualType = getApparentTypeOfContextualType(node);
46810             var contextualTypeHasPattern = contextualType && contextualType.pattern &&
46811                 (contextualType.pattern.kind === 189 || contextualType.pattern.kind === 193);
46812             var inConstContext = isConstContext(node);
46813             var checkFlags = inConstContext ? 8 : 0;
46814             var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node);
46815             var enumTag = ts.getJSDocEnumTag(node);
46816             var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag;
46817             var objectFlags = freshObjectLiteralFlag;
46818             var patternWithComputedProperties = false;
46819             var hasComputedStringProperty = false;
46820             var hasComputedNumberProperty = false;
46821             for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
46822                 var elem = _a[_i];
46823                 if (elem.name && ts.isComputedPropertyName(elem.name) && !ts.isWellKnownSymbolSyntactically(elem.name)) {
46824                     checkComputedPropertyName(elem.name);
46825                 }
46826             }
46827             var offset = 0;
46828             for (var i = 0; i < node.properties.length; i++) {
46829                 var memberDecl = node.properties[i];
46830                 var member = getSymbolOfNode(memberDecl);
46831                 var computedNameType = memberDecl.name && memberDecl.name.kind === 154 && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ?
46832                     checkComputedPropertyName(memberDecl.name) : undefined;
46833                 if (memberDecl.kind === 281 ||
46834                     memberDecl.kind === 282 ||
46835                     ts.isObjectLiteralMethod(memberDecl)) {
46836                     var type = memberDecl.kind === 281 ? checkPropertyAssignment(memberDecl, checkMode) :
46837                         memberDecl.kind === 282 ? checkExpressionForMutableLocation(memberDecl.name, checkMode) :
46838                             checkObjectLiteralMethod(memberDecl, checkMode);
46839                     if (isInJavascript) {
46840                         var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
46841                         if (jsDocType) {
46842                             checkTypeAssignableTo(type, jsDocType, memberDecl);
46843                             type = jsDocType;
46844                         }
46845                         else if (enumTag && enumTag.typeExpression) {
46846                             checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl);
46847                         }
46848                     }
46849                     objectFlags |= ts.getObjectFlags(type) & 3670016;
46850                     var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined;
46851                     var prop = nameType ?
46852                         createSymbol(4 | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096) :
46853                         createSymbol(4 | member.flags, member.escapedName, checkFlags);
46854                     if (nameType) {
46855                         prop.nameType = nameType;
46856                     }
46857                     if (inDestructuringPattern) {
46858                         var isOptional = (memberDecl.kind === 281 && hasDefaultValue(memberDecl.initializer)) ||
46859                             (memberDecl.kind === 282 && memberDecl.objectAssignmentInitializer);
46860                         if (isOptional) {
46861                             prop.flags |= 16777216;
46862                         }
46863                     }
46864                     else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512)) {
46865                         var impliedProp = getPropertyOfType(contextualType, member.escapedName);
46866                         if (impliedProp) {
46867                             prop.flags |= impliedProp.flags & 16777216;
46868                         }
46869                         else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, 0)) {
46870                             error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType));
46871                         }
46872                     }
46873                     prop.declarations = member.declarations;
46874                     prop.parent = member.parent;
46875                     if (member.valueDeclaration) {
46876                         prop.valueDeclaration = member.valueDeclaration;
46877                     }
46878                     prop.type = type;
46879                     prop.target = member;
46880                     member = prop;
46881                     allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
46882                 }
46883                 else if (memberDecl.kind === 283) {
46884                     if (languageVersion < 2) {
46885                         checkExternalEmitHelpers(memberDecl, 2);
46886                     }
46887                     if (propertiesArray.length > 0) {
46888                         spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext);
46889                         propertiesArray = [];
46890                         propertiesTable = ts.createSymbolTable();
46891                         hasComputedStringProperty = false;
46892                         hasComputedNumberProperty = false;
46893                     }
46894                     var type = getReducedType(checkExpression(memberDecl.expression));
46895                     if (!isValidSpreadType(type)) {
46896                         error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types);
46897                         return errorType;
46898                     }
46899                     if (allPropertiesTable) {
46900                         checkSpreadPropOverrides(type, allPropertiesTable, memberDecl);
46901                     }
46902                     spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext);
46903                     offset = i + 1;
46904                     continue;
46905                 }
46906                 else {
46907                     ts.Debug.assert(memberDecl.kind === 163 || memberDecl.kind === 164);
46908                     checkNodeDeferred(memberDecl);
46909                 }
46910                 if (computedNameType && !(computedNameType.flags & 8576)) {
46911                     if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) {
46912                         if (isTypeAssignableTo(computedNameType, numberType)) {
46913                             hasComputedNumberProperty = true;
46914                         }
46915                         else {
46916                             hasComputedStringProperty = true;
46917                         }
46918                         if (inDestructuringPattern) {
46919                             patternWithComputedProperties = true;
46920                         }
46921                     }
46922                 }
46923                 else {
46924                     propertiesTable.set(member.escapedName, member);
46925                 }
46926                 propertiesArray.push(member);
46927             }
46928             if (contextualTypeHasPattern && node.parent.kind !== 283) {
46929                 for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) {
46930                     var prop = _c[_b];
46931                     if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
46932                         if (!(prop.flags & 16777216)) {
46933                             error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
46934                         }
46935                         propertiesTable.set(prop.escapedName, prop);
46936                         propertiesArray.push(prop);
46937                     }
46938                 }
46939             }
46940             if (spread !== emptyObjectType) {
46941                 if (propertiesArray.length > 0) {
46942                     spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext);
46943                     propertiesArray = [];
46944                     propertiesTable = ts.createSymbolTable();
46945                     hasComputedStringProperty = false;
46946                     hasComputedNumberProperty = false;
46947                 }
46948                 return mapType(spread, function (t) { return t === emptyObjectType ? createObjectLiteralType() : t; });
46949             }
46950             return createObjectLiteralType();
46951             function createObjectLiteralType() {
46952                 var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 0) : undefined;
46953                 var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 1) : undefined;
46954                 var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
46955                 result.objectFlags |= objectFlags | 128 | 1048576;
46956                 if (isJSObjectLiteral) {
46957                     result.objectFlags |= 16384;
46958                 }
46959                 if (patternWithComputedProperties) {
46960                     result.objectFlags |= 512;
46961                 }
46962                 if (inDestructuringPattern) {
46963                     result.pattern = node;
46964                 }
46965                 return result;
46966             }
46967         }
46968         function isValidSpreadType(type) {
46969             if (type.flags & 63176704) {
46970                 var constraint = getBaseConstraintOfType(type);
46971                 if (constraint !== undefined) {
46972                     return isValidSpreadType(constraint);
46973                 }
46974             }
46975             return !!(type.flags & (1 | 67108864 | 524288 | 58982400) ||
46976                 getFalsyFlags(type) & 117632 && isValidSpreadType(removeDefinitelyFalsyTypes(type)) ||
46977                 type.flags & 3145728 && ts.every(type.types, isValidSpreadType));
46978         }
46979         function checkJsxSelfClosingElementDeferred(node) {
46980             checkJsxOpeningLikeElementOrOpeningFragment(node);
46981             resolveUntypedCall(node);
46982         }
46983         function checkJsxSelfClosingElement(node, _checkMode) {
46984             checkNodeDeferred(node);
46985             return getJsxElementTypeAt(node) || anyType;
46986         }
46987         function checkJsxElementDeferred(node) {
46988             checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement);
46989             if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) {
46990                 getIntrinsicTagSymbol(node.closingElement);
46991             }
46992             else {
46993                 checkExpression(node.closingElement.tagName);
46994             }
46995             checkJsxChildren(node);
46996         }
46997         function checkJsxElement(node, _checkMode) {
46998             checkNodeDeferred(node);
46999             return getJsxElementTypeAt(node) || anyType;
47000         }
47001         function checkJsxFragment(node) {
47002             checkJsxOpeningLikeElementOrOpeningFragment(node.openingFragment);
47003             if (compilerOptions.jsx === 2 && (compilerOptions.jsxFactory || ts.getSourceFileOfNode(node).pragmas.has("jsx"))) {
47004                 error(node, compilerOptions.jsxFactory
47005                     ? ts.Diagnostics.JSX_fragment_is_not_supported_when_using_jsxFactory
47006                     : ts.Diagnostics.JSX_fragment_is_not_supported_when_using_an_inline_JSX_factory_pragma);
47007             }
47008             checkJsxChildren(node);
47009             return getJsxElementTypeAt(node) || anyType;
47010         }
47011         function isUnhyphenatedJsxName(name) {
47012             return !ts.stringContains(name, "-");
47013         }
47014         function isJsxIntrinsicIdentifier(tagName) {
47015             return tagName.kind === 75 && ts.isIntrinsicJsxName(tagName.escapedText);
47016         }
47017         function checkJsxAttribute(node, checkMode) {
47018             return node.initializer
47019                 ? checkExpressionForMutableLocation(node.initializer, checkMode)
47020                 : trueType;
47021         }
47022         function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, checkMode) {
47023             var attributes = openingLikeElement.attributes;
47024             var allAttributesTable = strictNullChecks ? ts.createSymbolTable() : undefined;
47025             var attributesTable = ts.createSymbolTable();
47026             var spread = emptyJsxObjectType;
47027             var hasSpreadAnyType = false;
47028             var typeToIntersect;
47029             var explicitlySpecifyChildrenAttribute = false;
47030             var objectFlags = 4096;
47031             var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(openingLikeElement));
47032             for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) {
47033                 var attributeDecl = _a[_i];
47034                 var member = attributeDecl.symbol;
47035                 if (ts.isJsxAttribute(attributeDecl)) {
47036                     var exprType = checkJsxAttribute(attributeDecl, checkMode);
47037                     objectFlags |= ts.getObjectFlags(exprType) & 3670016;
47038                     var attributeSymbol = createSymbol(4 | 33554432 | member.flags, member.escapedName);
47039                     attributeSymbol.declarations = member.declarations;
47040                     attributeSymbol.parent = member.parent;
47041                     if (member.valueDeclaration) {
47042                         attributeSymbol.valueDeclaration = member.valueDeclaration;
47043                     }
47044                     attributeSymbol.type = exprType;
47045                     attributeSymbol.target = member;
47046                     attributesTable.set(attributeSymbol.escapedName, attributeSymbol);
47047                     allAttributesTable === null || allAttributesTable === void 0 ? void 0 : allAttributesTable.set(attributeSymbol.escapedName, attributeSymbol);
47048                     if (attributeDecl.name.escapedText === jsxChildrenPropertyName) {
47049                         explicitlySpecifyChildrenAttribute = true;
47050                     }
47051                 }
47052                 else {
47053                     ts.Debug.assert(attributeDecl.kind === 275);
47054                     if (attributesTable.size > 0) {
47055                         spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, false);
47056                         attributesTable = ts.createSymbolTable();
47057                     }
47058                     var exprType = getReducedType(checkExpressionCached(attributeDecl.expression, checkMode));
47059                     if (isTypeAny(exprType)) {
47060                         hasSpreadAnyType = true;
47061                     }
47062                     if (isValidSpreadType(exprType)) {
47063                         spread = getSpreadType(spread, exprType, attributes.symbol, objectFlags, false);
47064                         if (allAttributesTable) {
47065                             checkSpreadPropOverrides(exprType, allAttributesTable, attributeDecl);
47066                         }
47067                     }
47068                     else {
47069                         typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType;
47070                     }
47071                 }
47072             }
47073             if (!hasSpreadAnyType) {
47074                 if (attributesTable.size > 0) {
47075                     spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, false);
47076                 }
47077             }
47078             var parent = openingLikeElement.parent.kind === 266 ? openingLikeElement.parent : undefined;
47079             if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) {
47080                 var childrenTypes = checkJsxChildren(parent, checkMode);
47081                 if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") {
47082                     if (explicitlySpecifyChildrenAttribute) {
47083                         error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName));
47084                     }
47085                     var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes);
47086                     var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName);
47087                     var childrenPropSymbol = createSymbol(4 | 33554432, jsxChildrenPropertyName);
47088                     childrenPropSymbol.type = childrenTypes.length === 1 ?
47089                         childrenTypes[0] :
47090                         (getArrayLiteralTupleTypeIfApplicable(childrenTypes, childrenContextualType, false) || createArrayType(getUnionType(childrenTypes)));
47091                     childrenPropSymbol.valueDeclaration = ts.createPropertySignature(undefined, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName), undefined, undefined, undefined);
47092                     childrenPropSymbol.valueDeclaration.parent = attributes;
47093                     childrenPropSymbol.valueDeclaration.symbol = childrenPropSymbol;
47094                     var childPropMap = ts.createSymbolTable();
47095                     childPropMap.set(jsxChildrenPropertyName, childrenPropSymbol);
47096                     spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, ts.emptyArray, ts.emptyArray, undefined, undefined), attributes.symbol, objectFlags, false);
47097                 }
47098             }
47099             if (hasSpreadAnyType) {
47100                 return anyType;
47101             }
47102             if (typeToIntersect && spread !== emptyJsxObjectType) {
47103                 return getIntersectionType([typeToIntersect, spread]);
47104             }
47105             return typeToIntersect || (spread === emptyJsxObjectType ? createJsxAttributesType() : spread);
47106             function createJsxAttributesType() {
47107                 objectFlags |= freshObjectLiteralFlag;
47108                 var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, undefined, undefined);
47109                 result.objectFlags |= objectFlags | 128 | 1048576;
47110                 return result;
47111             }
47112         }
47113         function checkJsxChildren(node, checkMode) {
47114             var childrenTypes = [];
47115             for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
47116                 var child = _a[_i];
47117                 if (child.kind === 11) {
47118                     if (!child.containsOnlyTriviaWhiteSpaces) {
47119                         childrenTypes.push(stringType);
47120                     }
47121                 }
47122                 else {
47123                     childrenTypes.push(checkExpressionForMutableLocation(child, checkMode));
47124                 }
47125             }
47126             return childrenTypes;
47127         }
47128         function checkSpreadPropOverrides(type, props, spread) {
47129             for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
47130                 var right = _a[_i];
47131                 var left = props.get(right.escapedName);
47132                 var rightType = getTypeOfSymbol(right);
47133                 if (left && !maybeTypeOfKind(rightType, 98304) && !(maybeTypeOfKind(rightType, 3) && right.flags & 16777216)) {
47134                     var diagnostic = error(left.valueDeclaration, ts.Diagnostics._0_is_specified_more_than_once_so_this_usage_will_be_overwritten, ts.unescapeLeadingUnderscores(left.escapedName));
47135                     ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(spread, ts.Diagnostics.This_spread_always_overwrites_this_property));
47136                 }
47137             }
47138         }
47139         function checkJsxAttributes(node, checkMode) {
47140             return createJsxAttributesTypeFromAttributesProperty(node.parent, checkMode);
47141         }
47142         function getJsxType(name, location) {
47143             var namespace = getJsxNamespaceAt(location);
47144             var exports = namespace && getExportsOfSymbol(namespace);
47145             var typeSymbol = exports && getSymbol(exports, name, 788968);
47146             return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType;
47147         }
47148         function getIntrinsicTagSymbol(node) {
47149             var links = getNodeLinks(node);
47150             if (!links.resolvedSymbol) {
47151                 var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, node);
47152                 if (intrinsicElementsType !== errorType) {
47153                     if (!ts.isIdentifier(node.tagName))
47154                         return ts.Debug.fail();
47155                     var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.escapedText);
47156                     if (intrinsicProp) {
47157                         links.jsxFlags |= 1;
47158                         return links.resolvedSymbol = intrinsicProp;
47159                     }
47160                     var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0);
47161                     if (indexSignatureType) {
47162                         links.jsxFlags |= 2;
47163                         return links.resolvedSymbol = intrinsicElementsType.symbol;
47164                     }
47165                     error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.idText(node.tagName), "JSX." + JsxNames.IntrinsicElements);
47166                     return links.resolvedSymbol = unknownSymbol;
47167                 }
47168                 else {
47169                     if (noImplicitAny) {
47170                         error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, ts.unescapeLeadingUnderscores(JsxNames.IntrinsicElements));
47171                     }
47172                     return links.resolvedSymbol = unknownSymbol;
47173                 }
47174             }
47175             return links.resolvedSymbol;
47176         }
47177         function getJsxNamespaceAt(location) {
47178             var links = location && getNodeLinks(location);
47179             if (links && links.jsxNamespace) {
47180                 return links.jsxNamespace;
47181             }
47182             if (!links || links.jsxNamespace !== false) {
47183                 var namespaceName = getJsxNamespace(location);
47184                 var resolvedNamespace = resolveName(location, namespaceName, 1920, undefined, namespaceName, false);
47185                 if (resolvedNamespace) {
47186                     var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920));
47187                     if (candidate) {
47188                         if (links) {
47189                             links.jsxNamespace = candidate;
47190                         }
47191                         return candidate;
47192                     }
47193                     if (links) {
47194                         links.jsxNamespace = false;
47195                     }
47196                 }
47197             }
47198             return getGlobalSymbol(JsxNames.JSX, 1920, undefined);
47199         }
47200         function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) {
47201             var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968);
47202             var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym);
47203             var propertiesOfJsxElementAttribPropInterface = jsxElementAttribPropInterfaceType && getPropertiesOfType(jsxElementAttribPropInterfaceType);
47204             if (propertiesOfJsxElementAttribPropInterface) {
47205                 if (propertiesOfJsxElementAttribPropInterface.length === 0) {
47206                     return "";
47207                 }
47208                 else if (propertiesOfJsxElementAttribPropInterface.length === 1) {
47209                     return propertiesOfJsxElementAttribPropInterface[0].escapedName;
47210                 }
47211                 else if (propertiesOfJsxElementAttribPropInterface.length > 1) {
47212                     error(jsxElementAttribPropInterfaceSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, ts.unescapeLeadingUnderscores(nameOfAttribPropContainer));
47213                 }
47214             }
47215             return undefined;
47216         }
47217         function getJsxLibraryManagedAttributes(jsxNamespace) {
47218             return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968);
47219         }
47220         function getJsxElementPropertiesName(jsxNamespace) {
47221             return getNameFromJsxElementAttributesContainer(JsxNames.ElementAttributesPropertyNameContainer, jsxNamespace);
47222         }
47223         function getJsxElementChildrenPropertyName(jsxNamespace) {
47224             return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace);
47225         }
47226         function getUninstantiatedJsxSignaturesOfType(elementType, caller) {
47227             if (elementType.flags & 4) {
47228                 return [anySignature];
47229             }
47230             else if (elementType.flags & 128) {
47231                 var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller);
47232                 if (!intrinsicType) {
47233                     error(caller, ts.Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements);
47234                     return ts.emptyArray;
47235                 }
47236                 else {
47237                     var fakeSignature = createSignatureForJSXIntrinsic(caller, intrinsicType);
47238                     return [fakeSignature];
47239                 }
47240             }
47241             var apparentElemType = getApparentType(elementType);
47242             var signatures = getSignaturesOfType(apparentElemType, 1);
47243             if (signatures.length === 0) {
47244                 signatures = getSignaturesOfType(apparentElemType, 0);
47245             }
47246             if (signatures.length === 0 && apparentElemType.flags & 1048576) {
47247                 signatures = getUnionSignatures(ts.map(apparentElemType.types, function (t) { return getUninstantiatedJsxSignaturesOfType(t, caller); }));
47248             }
47249             return signatures;
47250         }
47251         function getIntrinsicAttributesTypeFromStringLiteralType(type, location) {
47252             var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, location);
47253             if (intrinsicElementsType !== errorType) {
47254                 var stringLiteralTypeName = type.value;
47255                 var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName));
47256                 if (intrinsicProp) {
47257                     return getTypeOfSymbol(intrinsicProp);
47258                 }
47259                 var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0);
47260                 if (indexSignatureType) {
47261                     return indexSignatureType;
47262                 }
47263                 return undefined;
47264             }
47265             return anyType;
47266         }
47267         function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) {
47268             if (refKind === 1) {
47269                 var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement);
47270                 if (sfcReturnConstraint) {
47271                     checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_return_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain);
47272                 }
47273             }
47274             else if (refKind === 0) {
47275                 var classConstraint = getJsxElementClassTypeAt(openingLikeElement);
47276                 if (classConstraint) {
47277                     checkTypeRelatedTo(elemInstanceType, classConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_instance_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain);
47278                 }
47279             }
47280             else {
47281                 var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement);
47282                 var classConstraint = getJsxElementClassTypeAt(openingLikeElement);
47283                 if (!sfcReturnConstraint || !classConstraint) {
47284                     return;
47285                 }
47286                 var combined = getUnionType([sfcReturnConstraint, classConstraint]);
47287                 checkTypeRelatedTo(elemInstanceType, combined, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_element_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain);
47288             }
47289             function generateInitialErrorChain() {
47290                 var componentName = ts.getTextOfNode(openingLikeElement.tagName);
47291                 return ts.chainDiagnosticMessages(undefined, ts.Diagnostics._0_cannot_be_used_as_a_JSX_component, componentName);
47292             }
47293         }
47294         function getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node) {
47295             ts.Debug.assert(isJsxIntrinsicIdentifier(node.tagName));
47296             var links = getNodeLinks(node);
47297             if (!links.resolvedJsxElementAttributesType) {
47298                 var symbol = getIntrinsicTagSymbol(node);
47299                 if (links.jsxFlags & 1) {
47300                     return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol);
47301                 }
47302                 else if (links.jsxFlags & 2) {
47303                     return links.resolvedJsxElementAttributesType =
47304                         getIndexTypeOfType(getDeclaredTypeOfSymbol(symbol), 0);
47305                 }
47306                 else {
47307                     return links.resolvedJsxElementAttributesType = errorType;
47308                 }
47309             }
47310             return links.resolvedJsxElementAttributesType;
47311         }
47312         function getJsxElementClassTypeAt(location) {
47313             var type = getJsxType(JsxNames.ElementClass, location);
47314             if (type === errorType)
47315                 return undefined;
47316             return type;
47317         }
47318         function getJsxElementTypeAt(location) {
47319             return getJsxType(JsxNames.Element, location);
47320         }
47321         function getJsxStatelessElementTypeAt(location) {
47322             var jsxElementType = getJsxElementTypeAt(location);
47323             if (jsxElementType) {
47324                 return getUnionType([jsxElementType, nullType]);
47325             }
47326         }
47327         function getJsxIntrinsicTagNamesAt(location) {
47328             var intrinsics = getJsxType(JsxNames.IntrinsicElements, location);
47329             return intrinsics ? getPropertiesOfType(intrinsics) : ts.emptyArray;
47330         }
47331         function checkJsxPreconditions(errorNode) {
47332             if ((compilerOptions.jsx || 0) === 0) {
47333                 error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided);
47334             }
47335             if (getJsxElementTypeAt(errorNode) === undefined) {
47336                 if (noImplicitAny) {
47337                     error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist);
47338                 }
47339             }
47340         }
47341         function checkJsxOpeningLikeElementOrOpeningFragment(node) {
47342             var isNodeOpeningLikeElement = ts.isJsxOpeningLikeElement(node);
47343             if (isNodeOpeningLikeElement) {
47344                 checkGrammarJsxElement(node);
47345             }
47346             checkJsxPreconditions(node);
47347             var reactRefErr = diagnostics && compilerOptions.jsx === 2 ? ts.Diagnostics.Cannot_find_name_0 : undefined;
47348             var reactNamespace = getJsxNamespace(node);
47349             var reactLocation = isNodeOpeningLikeElement ? node.tagName : node;
47350             var reactSym = resolveName(reactLocation, reactNamespace, 111551, reactRefErr, reactNamespace, true);
47351             if (reactSym) {
47352                 reactSym.isReferenced = 67108863;
47353                 if (reactSym.flags & 2097152 && !getTypeOnlyAliasDeclaration(reactSym)) {
47354                     markAliasSymbolAsReferenced(reactSym);
47355                 }
47356             }
47357             if (isNodeOpeningLikeElement) {
47358                 var jsxOpeningLikeNode = node;
47359                 var sig = getResolvedSignature(jsxOpeningLikeNode);
47360                 checkJsxReturnAssignableToAppropriateBound(getJsxReferenceKind(jsxOpeningLikeNode), getReturnTypeOfSignature(sig), jsxOpeningLikeNode);
47361             }
47362         }
47363         function isKnownProperty(targetType, name, isComparingJsxAttributes) {
47364             if (targetType.flags & 524288) {
47365                 var resolved = resolveStructuredTypeMembers(targetType);
47366                 if (resolved.stringIndexInfo ||
47367                     resolved.numberIndexInfo && isNumericLiteralName(name) ||
47368                     getPropertyOfObjectType(targetType, name) ||
47369                     isComparingJsxAttributes && !isUnhyphenatedJsxName(name)) {
47370                     return true;
47371                 }
47372             }
47373             else if (targetType.flags & 3145728 && isExcessPropertyCheckTarget(targetType)) {
47374                 for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) {
47375                     var t = _a[_i];
47376                     if (isKnownProperty(t, name, isComparingJsxAttributes)) {
47377                         return true;
47378                     }
47379                 }
47380             }
47381             return false;
47382         }
47383         function isExcessPropertyCheckTarget(type) {
47384             return !!(type.flags & 524288 && !(ts.getObjectFlags(type) & 512) ||
47385                 type.flags & 67108864 ||
47386                 type.flags & 1048576 && ts.some(type.types, isExcessPropertyCheckTarget) ||
47387                 type.flags & 2097152 && ts.every(type.types, isExcessPropertyCheckTarget));
47388         }
47389         function checkJsxExpression(node, checkMode) {
47390             checkGrammarJsxExpression(node);
47391             if (node.expression) {
47392                 var type = checkExpression(node.expression, checkMode);
47393                 if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) {
47394                     error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type);
47395                 }
47396                 return type;
47397             }
47398             else {
47399                 return errorType;
47400             }
47401         }
47402         function getDeclarationNodeFlagsFromSymbol(s) {
47403             return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0;
47404         }
47405         function isPrototypeProperty(symbol) {
47406             if (symbol.flags & 8192 || ts.getCheckFlags(symbol) & 4) {
47407                 return true;
47408             }
47409             if (ts.isInJSFile(symbol.valueDeclaration)) {
47410                 var parent = symbol.valueDeclaration.parent;
47411                 return parent && ts.isBinaryExpression(parent) &&
47412                     ts.getAssignmentDeclarationKind(parent) === 3;
47413             }
47414         }
47415         function checkPropertyAccessibility(node, isSuper, type, prop) {
47416             var flags = ts.getDeclarationModifierFlagsFromSymbol(prop);
47417             var errorNode = node.kind === 153 ? node.right : node.kind === 188 ? node : node.name;
47418             if (isSuper) {
47419                 if (languageVersion < 2) {
47420                     if (symbolHasNonMethodDeclaration(prop)) {
47421                         error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword);
47422                         return false;
47423                     }
47424                 }
47425                 if (flags & 128) {
47426                     error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop)));
47427                     return false;
47428                 }
47429             }
47430             if ((flags & 128) && ts.isThisProperty(node) && symbolHasNonMethodDeclaration(prop)) {
47431                 var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop));
47432                 if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(node)) {
47433                     error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name));
47434                     return false;
47435                 }
47436             }
47437             if (ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name)) {
47438                 if (!ts.getContainingClass(node)) {
47439                     error(errorNode, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
47440                     return false;
47441                 }
47442                 return true;
47443             }
47444             if (!(flags & 24)) {
47445                 return true;
47446             }
47447             if (flags & 8) {
47448                 var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop));
47449                 if (!isNodeWithinClass(node, declaringClassDeclaration)) {
47450                     error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop)));
47451                     return false;
47452                 }
47453                 return true;
47454             }
47455             if (isSuper) {
47456                 return true;
47457             }
47458             var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) {
47459                 var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration));
47460                 return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined;
47461             });
47462             if (!enclosingClass) {
47463                 var thisParameter = void 0;
47464                 if (flags & 32 || !(thisParameter = getThisParameterFromNodeContext(node)) || !thisParameter.type) {
47465                     error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type));
47466                     return false;
47467                 }
47468                 var thisType = getTypeFromTypeNode(thisParameter.type);
47469                 enclosingClass = ((thisType.flags & 262144) ? getConstraintOfTypeParameter(thisType) : thisType).target;
47470             }
47471             if (flags & 32) {
47472                 return true;
47473             }
47474             if (type.flags & 262144) {
47475                 type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type);
47476             }
47477             if (!type || !hasBaseType(type, enclosingClass)) {
47478                 error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass));
47479                 return false;
47480             }
47481             return true;
47482         }
47483         function getThisParameterFromNodeContext(node) {
47484             var thisContainer = ts.getThisContainer(node, false);
47485             return thisContainer && ts.isFunctionLike(thisContainer) ? ts.getThisParameter(thisContainer) : undefined;
47486         }
47487         function symbolHasNonMethodDeclaration(symbol) {
47488             return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192); });
47489         }
47490         function checkNonNullExpression(node) {
47491             return checkNonNullType(checkExpression(node), node);
47492         }
47493         function isNullableType(type) {
47494             return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304);
47495         }
47496         function getNonNullableTypeIfNeeded(type) {
47497             return isNullableType(type) ? getNonNullableType(type) : type;
47498         }
47499         function reportObjectPossiblyNullOrUndefinedError(node, flags) {
47500             error(node, flags & 32768 ? flags & 65536 ?
47501                 ts.Diagnostics.Object_is_possibly_null_or_undefined :
47502                 ts.Diagnostics.Object_is_possibly_undefined :
47503                 ts.Diagnostics.Object_is_possibly_null);
47504         }
47505         function reportCannotInvokePossiblyNullOrUndefinedError(node, flags) {
47506             error(node, flags & 32768 ? flags & 65536 ?
47507                 ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined :
47508                 ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined :
47509                 ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null);
47510         }
47511         function checkNonNullTypeWithReporter(type, node, reportError) {
47512             if (strictNullChecks && type.flags & 2) {
47513                 error(node, ts.Diagnostics.Object_is_of_type_unknown);
47514                 return errorType;
47515             }
47516             var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304;
47517             if (kind) {
47518                 reportError(node, kind);
47519                 var t = getNonNullableType(type);
47520                 return t.flags & (98304 | 131072) ? errorType : t;
47521             }
47522             return type;
47523         }
47524         function checkNonNullType(type, node) {
47525             return checkNonNullTypeWithReporter(type, node, reportObjectPossiblyNullOrUndefinedError);
47526         }
47527         function checkNonNullNonVoidType(type, node) {
47528             var nonNullType = checkNonNullType(type, node);
47529             if (nonNullType !== errorType && nonNullType.flags & 16384) {
47530                 error(node, ts.Diagnostics.Object_is_possibly_undefined);
47531             }
47532             return nonNullType;
47533         }
47534         function checkPropertyAccessExpression(node) {
47535             return node.flags & 32 ? checkPropertyAccessChain(node) :
47536                 checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name);
47537         }
47538         function checkPropertyAccessChain(node) {
47539             var leftType = checkExpression(node.expression);
47540             var nonOptionalType = getOptionalExpressionType(leftType, node.expression);
47541             return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), node, nonOptionalType !== leftType);
47542         }
47543         function checkQualifiedName(node) {
47544             return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right);
47545         }
47546         function isMethodAccessForCall(node) {
47547             while (node.parent.kind === 200) {
47548                 node = node.parent;
47549             }
47550             return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node;
47551         }
47552         function lookupSymbolForPrivateIdentifierDeclaration(propName, location) {
47553             for (var containingClass = ts.getContainingClass(location); !!containingClass; containingClass = ts.getContainingClass(containingClass)) {
47554                 var symbol = containingClass.symbol;
47555                 var name = ts.getSymbolNameForPrivateIdentifier(symbol, propName);
47556                 var prop = (symbol.members && symbol.members.get(name)) || (symbol.exports && symbol.exports.get(name));
47557                 if (prop) {
47558                     return prop;
47559                 }
47560             }
47561         }
47562         function getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) {
47563             return getPropertyOfType(leftType, lexicallyScopedIdentifier.escapedName);
47564         }
47565         function checkPrivateIdentifierPropertyAccess(leftType, right, lexicallyScopedIdentifier) {
47566             var propertyOnType;
47567             var properties = getPropertiesOfType(leftType);
47568             if (properties) {
47569                 ts.forEach(properties, function (symbol) {
47570                     var decl = symbol.valueDeclaration;
47571                     if (decl && ts.isNamedDeclaration(decl) && ts.isPrivateIdentifier(decl.name) && decl.name.escapedText === right.escapedText) {
47572                         propertyOnType = symbol;
47573                         return true;
47574                     }
47575                 });
47576             }
47577             var diagName = diagnosticName(right);
47578             if (propertyOnType) {
47579                 var typeValueDecl = propertyOnType.valueDeclaration;
47580                 var typeClass_1 = ts.getContainingClass(typeValueDecl);
47581                 ts.Debug.assert(!!typeClass_1);
47582                 if (lexicallyScopedIdentifier) {
47583                     var lexicalValueDecl = lexicallyScopedIdentifier.valueDeclaration;
47584                     var lexicalClass = ts.getContainingClass(lexicalValueDecl);
47585                     ts.Debug.assert(!!lexicalClass);
47586                     if (ts.findAncestor(lexicalClass, function (n) { return typeClass_1 === n; })) {
47587                         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));
47588                         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));
47589                         return true;
47590                     }
47591                 }
47592                 error(right, ts.Diagnostics.Property_0_is_not_accessible_outside_class_1_because_it_has_a_private_identifier, diagName, diagnosticName(typeClass_1.name || anon));
47593                 return true;
47594             }
47595             return false;
47596         }
47597         function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) {
47598             var parentSymbol = getNodeLinks(left).resolvedSymbol;
47599             var assignmentKind = ts.getAssignmentTargetKind(node);
47600             var apparentType = getApparentType(assignmentKind !== 0 || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType);
47601             if (ts.isPrivateIdentifier(right)) {
47602                 checkExternalEmitHelpers(node, 262144);
47603             }
47604             var isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType;
47605             var prop;
47606             if (ts.isPrivateIdentifier(right)) {
47607                 var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right);
47608                 if (isAnyLike) {
47609                     if (lexicallyScopedSymbol) {
47610                         return apparentType;
47611                     }
47612                     if (!ts.getContainingClass(right)) {
47613                         grammarErrorOnNode(right, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
47614                         return anyType;
47615                     }
47616                 }
47617                 prop = lexicallyScopedSymbol ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedSymbol) : undefined;
47618                 if (!prop && checkPrivateIdentifierPropertyAccess(leftType, right, lexicallyScopedSymbol)) {
47619                     return errorType;
47620                 }
47621             }
47622             else {
47623                 if (isAnyLike) {
47624                     if (ts.isIdentifier(left) && parentSymbol) {
47625                         markAliasReferenced(parentSymbol, node);
47626                     }
47627                     return apparentType;
47628                 }
47629                 prop = getPropertyOfType(apparentType, right.escapedText);
47630             }
47631             if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) {
47632                 markAliasReferenced(parentSymbol, node);
47633             }
47634             var propType;
47635             if (!prop) {
47636                 var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 || !isGenericObjectType(leftType) || isThisTypeParameter(leftType)) ? getIndexInfoOfType(apparentType, 0) : undefined;
47637                 if (!(indexInfo && indexInfo.type)) {
47638                     if (isJSLiteralType(leftType)) {
47639                         return anyType;
47640                     }
47641                     if (leftType.symbol === globalThisSymbol) {
47642                         if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418)) {
47643                             error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(right.escapedText), typeToString(leftType));
47644                         }
47645                         else if (noImplicitAny) {
47646                             error(right, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(leftType));
47647                         }
47648                         return anyType;
47649                     }
47650                     if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) {
47651                         reportNonexistentProperty(right, isThisTypeParameter(leftType) ? apparentType : leftType);
47652                     }
47653                     return errorType;
47654                 }
47655                 if (indexInfo.isReadonly && (ts.isAssignmentTarget(node) || ts.isDeleteTarget(node))) {
47656                     error(node, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(apparentType));
47657                 }
47658                 propType = indexInfo.type;
47659             }
47660             else {
47661                 checkPropertyNotUsedBeforeDeclaration(prop, node, right);
47662                 markPropertyAsReferenced(prop, node, left.kind === 104);
47663                 getNodeLinks(node).resolvedSymbol = prop;
47664                 checkPropertyAccessibility(node, left.kind === 102, apparentType, prop);
47665                 if (isAssignmentToReadonlyEntity(node, prop, assignmentKind)) {
47666                     error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right));
47667                     return errorType;
47668                 }
47669                 propType = getConstraintForLocation(getTypeOfSymbol(prop), node);
47670             }
47671             return getFlowTypeOfAccessExpression(node, prop, propType, right);
47672         }
47673         function getFlowTypeOfAccessExpression(node, prop, propType, errorNode) {
47674             var assignmentKind = ts.getAssignmentTargetKind(node);
47675             if (!ts.isAccessExpression(node) ||
47676                 assignmentKind === 1 ||
47677                 prop && !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 1048576)) {
47678                 return propType;
47679             }
47680             var assumeUninitialized = false;
47681             if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 104) {
47682                 var declaration = prop && prop.valueDeclaration;
47683                 if (declaration && isInstancePropertyWithoutInitializer(declaration)) {
47684                     var flowContainer = getControlFlowContainer(node);
47685                     if (flowContainer.kind === 162 && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608)) {
47686                         assumeUninitialized = true;
47687                     }
47688                 }
47689             }
47690             else if (strictNullChecks && prop && prop.valueDeclaration &&
47691                 ts.isPropertyAccessExpression(prop.valueDeclaration) &&
47692                 ts.getAssignmentDeclarationPropertyAccessKind(prop.valueDeclaration) &&
47693                 getControlFlowContainer(node) === getControlFlowContainer(prop.valueDeclaration)) {
47694                 assumeUninitialized = true;
47695             }
47696             var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType);
47697             if (assumeUninitialized && !(getFalsyFlags(propType) & 32768) && getFalsyFlags(flowType) & 32768) {
47698                 error(errorNode, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop));
47699                 return propType;
47700             }
47701             return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
47702         }
47703         function checkPropertyNotUsedBeforeDeclaration(prop, node, right) {
47704             var valueDeclaration = prop.valueDeclaration;
47705             if (!valueDeclaration || ts.getSourceFileOfNode(node).isDeclarationFile) {
47706                 return;
47707             }
47708             var diagnosticMessage;
47709             var declarationName = ts.idText(right);
47710             if (isInPropertyInitializer(node)
47711                 && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression))
47712                 && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)
47713                 && !isPropertyDeclaredInAncestorClass(prop)) {
47714                 diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName);
47715             }
47716             else if (valueDeclaration.kind === 245 &&
47717                 node.parent.kind !== 169 &&
47718                 !(valueDeclaration.flags & 8388608) &&
47719                 !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) {
47720                 diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
47721             }
47722             if (diagnosticMessage) {
47723                 ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_is_declared_here, declarationName));
47724             }
47725         }
47726         function isInPropertyInitializer(node) {
47727             return !!ts.findAncestor(node, function (node) {
47728                 switch (node.kind) {
47729                     case 159:
47730                         return true;
47731                     case 281:
47732                     case 161:
47733                     case 163:
47734                     case 164:
47735                     case 283:
47736                     case 154:
47737                     case 221:
47738                     case 276:
47739                     case 273:
47740                     case 274:
47741                     case 275:
47742                     case 268:
47743                     case 216:
47744                     case 279:
47745                         return false;
47746                     default:
47747                         return ts.isExpressionNode(node) ? false : "quit";
47748                 }
47749             });
47750         }
47751         function isPropertyDeclaredInAncestorClass(prop) {
47752             if (!(prop.parent.flags & 32)) {
47753                 return false;
47754             }
47755             var classType = getTypeOfSymbol(prop.parent);
47756             while (true) {
47757                 classType = classType.symbol && getSuperClass(classType);
47758                 if (!classType) {
47759                     return false;
47760                 }
47761                 var superProperty = getPropertyOfType(classType, prop.escapedName);
47762                 if (superProperty && superProperty.valueDeclaration) {
47763                     return true;
47764                 }
47765             }
47766         }
47767         function getSuperClass(classType) {
47768             var x = getBaseTypes(classType);
47769             if (x.length === 0) {
47770                 return undefined;
47771             }
47772             return getIntersectionType(x);
47773         }
47774         function reportNonexistentProperty(propNode, containingType) {
47775             var errorInfo;
47776             var relatedInfo;
47777             if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 && !(containingType.flags & 131068)) {
47778                 for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) {
47779                     var subtype = _a[_i];
47780                     if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0)) {
47781                         errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype));
47782                         break;
47783                     }
47784                 }
47785             }
47786             if (typeHasStaticProperty(propNode.escapedText, containingType)) {
47787                 errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_is_a_static_member_of_type_1, ts.declarationNameToString(propNode), typeToString(containingType));
47788             }
47789             else {
47790                 var promisedType = getPromisedTypeOfPromise(containingType);
47791                 if (promisedType && getPropertyOfType(promisedType, propNode.escapedText)) {
47792                     errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType));
47793                     relatedInfo = ts.createDiagnosticForNode(propNode, ts.Diagnostics.Did_you_forget_to_use_await);
47794                 }
47795                 else {
47796                     var suggestion = getSuggestedSymbolForNonexistentProperty(propNode, containingType);
47797                     if (suggestion !== undefined) {
47798                         var suggestedName = ts.symbolName(suggestion);
47799                         errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestedName);
47800                         relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestedName);
47801                     }
47802                     else {
47803                         errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType));
47804                     }
47805                 }
47806             }
47807             var resultDiagnostic = ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo);
47808             if (relatedInfo) {
47809                 ts.addRelatedInfo(resultDiagnostic, relatedInfo);
47810             }
47811             diagnostics.add(resultDiagnostic);
47812         }
47813         function typeHasStaticProperty(propName, containingType) {
47814             var prop = containingType.symbol && getPropertyOfType(getTypeOfSymbol(containingType.symbol), propName);
47815             return prop !== undefined && prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 32);
47816         }
47817         function getSuggestedSymbolForNonexistentProperty(name, containingType) {
47818             return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551);
47819         }
47820         function getSuggestionForNonexistentProperty(name, containingType) {
47821             var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType);
47822             return suggestion && ts.symbolName(suggestion);
47823         }
47824         function getSuggestedSymbolForNonexistentSymbol(location, outerName, meaning) {
47825             ts.Debug.assert(outerName !== undefined, "outername should always be defined");
47826             var result = resolveNameHelper(location, outerName, meaning, undefined, outerName, false, false, function (symbols, name, meaning) {
47827                 ts.Debug.assertEqual(outerName, name, "name should equal outerName");
47828                 var symbol = getSymbol(symbols, name, meaning);
47829                 return symbol || getSpellingSuggestionForName(ts.unescapeLeadingUnderscores(name), ts.arrayFrom(symbols.values()), meaning);
47830             });
47831             return result;
47832         }
47833         function getSuggestionForNonexistentSymbol(location, outerName, meaning) {
47834             var symbolResult = getSuggestedSymbolForNonexistentSymbol(location, outerName, meaning);
47835             return symbolResult && ts.symbolName(symbolResult);
47836         }
47837         function getSuggestedSymbolForNonexistentModule(name, targetModule) {
47838             return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475);
47839         }
47840         function getSuggestionForNonexistentExport(name, targetModule) {
47841             var suggestion = getSuggestedSymbolForNonexistentModule(name, targetModule);
47842             return suggestion && ts.symbolName(suggestion);
47843         }
47844         function getSuggestionForNonexistentIndexSignature(objectType, expr, keyedType) {
47845             function hasProp(name) {
47846                 var prop = getPropertyOfObjectType(objectType, name);
47847                 if (prop) {
47848                     var s = getSingleCallSignature(getTypeOfSymbol(prop));
47849                     return !!s && getMinArgumentCount(s) >= 1 && isTypeAssignableTo(keyedType, getTypeAtPosition(s, 0));
47850                 }
47851                 return false;
47852             }
47853             ;
47854             var suggestedMethod = ts.isAssignmentTarget(expr) ? "set" : "get";
47855             if (!hasProp(suggestedMethod)) {
47856                 return undefined;
47857             }
47858             var suggestion = ts.tryGetPropertyAccessOrIdentifierToString(expr.expression);
47859             if (suggestion === undefined) {
47860                 suggestion = suggestedMethod;
47861             }
47862             else {
47863                 suggestion += "." + suggestedMethod;
47864             }
47865             return suggestion;
47866         }
47867         function getSpellingSuggestionForName(name, symbols, meaning) {
47868             return ts.getSpellingSuggestion(name, symbols, getCandidateName);
47869             function getCandidateName(candidate) {
47870                 var candidateName = ts.symbolName(candidate);
47871                 if (ts.startsWith(candidateName, "\"")) {
47872                     return undefined;
47873                 }
47874                 if (candidate.flags & meaning) {
47875                     return candidateName;
47876                 }
47877                 if (candidate.flags & 2097152) {
47878                     var alias = tryResolveAlias(candidate);
47879                     if (alias && alias.flags & meaning) {
47880                         return candidateName;
47881                     }
47882                 }
47883                 return undefined;
47884             }
47885         }
47886         function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isThisAccess) {
47887             var valueDeclaration = prop && (prop.flags & 106500) && prop.valueDeclaration;
47888             if (!valueDeclaration) {
47889                 return;
47890             }
47891             var hasPrivateModifier = ts.hasModifier(valueDeclaration, 8);
47892             var hasPrivateIdentifier = ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name);
47893             if (!hasPrivateModifier && !hasPrivateIdentifier) {
47894                 return;
47895             }
47896             if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536)) {
47897                 return;
47898             }
47899             if (isThisAccess) {
47900                 var containingMethod = ts.findAncestor(nodeForCheckWriteOnly, ts.isFunctionLikeDeclaration);
47901                 if (containingMethod && containingMethod.symbol === prop) {
47902                     return;
47903                 }
47904             }
47905             (ts.getCheckFlags(prop) & 1 ? getSymbolLinks(prop).target : prop).isReferenced = 67108863;
47906         }
47907         function isValidPropertyAccess(node, propertyName) {
47908             switch (node.kind) {
47909                 case 194:
47910                     return isValidPropertyAccessWithType(node, node.expression.kind === 102, propertyName, getWidenedType(checkExpression(node.expression)));
47911                 case 153:
47912                     return isValidPropertyAccessWithType(node, false, propertyName, getWidenedType(checkExpression(node.left)));
47913                 case 188:
47914                     return isValidPropertyAccessWithType(node, false, propertyName, getTypeFromTypeNode(node));
47915             }
47916         }
47917         function isValidPropertyAccessForCompletions(node, type, property) {
47918             return isValidPropertyAccessWithType(node, node.kind === 194 && node.expression.kind === 102, property.escapedName, type);
47919         }
47920         function isValidPropertyAccessWithType(node, isSuper, propertyName, type) {
47921             if (type === errorType || isTypeAny(type)) {
47922                 return true;
47923             }
47924             var prop = getPropertyOfType(type, propertyName);
47925             if (prop) {
47926                 if (ts.isPropertyAccessExpression(node) && prop.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(prop.valueDeclaration)) {
47927                     var declClass_1 = ts.getContainingClass(prop.valueDeclaration);
47928                     return !ts.isOptionalChain(node) && !!ts.findAncestor(node, function (parent) { return parent === declClass_1; });
47929                 }
47930                 return checkPropertyAccessibility(node, isSuper, type, prop);
47931             }
47932             return ts.isInJSFile(node) && (type.flags & 1048576) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); });
47933         }
47934         function getForInVariableSymbol(node) {
47935             var initializer = node.initializer;
47936             if (initializer.kind === 243) {
47937                 var variable = initializer.declarations[0];
47938                 if (variable && !ts.isBindingPattern(variable.name)) {
47939                     return getSymbolOfNode(variable);
47940                 }
47941             }
47942             else if (initializer.kind === 75) {
47943                 return getResolvedSymbol(initializer);
47944             }
47945             return undefined;
47946         }
47947         function hasNumericPropertyNames(type) {
47948             return getIndexTypeOfType(type, 1) && !getIndexTypeOfType(type, 0);
47949         }
47950         function isForInVariableForNumericPropertyNames(expr) {
47951             var e = ts.skipParentheses(expr);
47952             if (e.kind === 75) {
47953                 var symbol = getResolvedSymbol(e);
47954                 if (symbol.flags & 3) {
47955                     var child = expr;
47956                     var node = expr.parent;
47957                     while (node) {
47958                         if (node.kind === 231 &&
47959                             child === node.statement &&
47960                             getForInVariableSymbol(node) === symbol &&
47961                             hasNumericPropertyNames(getTypeOfExpression(node.expression))) {
47962                             return true;
47963                         }
47964                         child = node;
47965                         node = node.parent;
47966                     }
47967                 }
47968             }
47969             return false;
47970         }
47971         function checkIndexedAccess(node) {
47972             return node.flags & 32 ? checkElementAccessChain(node) :
47973                 checkElementAccessExpression(node, checkNonNullExpression(node.expression));
47974         }
47975         function checkElementAccessChain(node) {
47976             var exprType = checkExpression(node.expression);
47977             var nonOptionalType = getOptionalExpressionType(exprType, node.expression);
47978             return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), node, nonOptionalType !== exprType);
47979         }
47980         function checkElementAccessExpression(node, exprType) {
47981             var objectType = ts.getAssignmentTargetKind(node) !== 0 || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType;
47982             var indexExpression = node.argumentExpression;
47983             var indexType = checkExpression(indexExpression);
47984             if (objectType === errorType || objectType === silentNeverType) {
47985                 return objectType;
47986             }
47987             if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) {
47988                 error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal);
47989                 return errorType;
47990             }
47991             var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType;
47992             var accessFlags = ts.isAssignmentTarget(node) ?
47993                 2 | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 : 0) :
47994                 0;
47995             var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, node, accessFlags) || errorType;
47996             return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node);
47997         }
47998         function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) {
47999             if (expressionType === errorType) {
48000                 return false;
48001             }
48002             if (!ts.isWellKnownSymbolSyntactically(expression)) {
48003                 return false;
48004             }
48005             if ((expressionType.flags & 12288) === 0) {
48006                 if (reportError) {
48007                     error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression));
48008                 }
48009                 return false;
48010             }
48011             var leftHandSide = expression.expression;
48012             var leftHandSideSymbol = getResolvedSymbol(leftHandSide);
48013             if (!leftHandSideSymbol) {
48014                 return false;
48015             }
48016             var globalESSymbol = getGlobalESSymbolConstructorSymbol(true);
48017             if (!globalESSymbol) {
48018                 return false;
48019             }
48020             if (leftHandSideSymbol !== globalESSymbol) {
48021                 if (reportError) {
48022                     error(leftHandSide, ts.Diagnostics.Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object);
48023                 }
48024                 return false;
48025             }
48026             return true;
48027         }
48028         function callLikeExpressionMayHaveTypeArguments(node) {
48029             return ts.isCallOrNewExpression(node) || ts.isTaggedTemplateExpression(node) || ts.isJsxOpeningLikeElement(node);
48030         }
48031         function resolveUntypedCall(node) {
48032             if (callLikeExpressionMayHaveTypeArguments(node)) {
48033                 ts.forEach(node.typeArguments, checkSourceElement);
48034             }
48035             if (node.kind === 198) {
48036                 checkExpression(node.template);
48037             }
48038             else if (ts.isJsxOpeningLikeElement(node)) {
48039                 checkExpression(node.attributes);
48040             }
48041             else if (node.kind !== 157) {
48042                 ts.forEach(node.arguments, function (argument) {
48043                     checkExpression(argument);
48044                 });
48045             }
48046             return anySignature;
48047         }
48048         function resolveErrorCall(node) {
48049             resolveUntypedCall(node);
48050             return unknownSignature;
48051         }
48052         function reorderCandidates(signatures, result, callChainFlags) {
48053             var lastParent;
48054             var lastSymbol;
48055             var cutoffIndex = 0;
48056             var index;
48057             var specializedIndex = -1;
48058             var spliceIndex;
48059             ts.Debug.assert(!result.length);
48060             for (var _i = 0, signatures_7 = signatures; _i < signatures_7.length; _i++) {
48061                 var signature = signatures_7[_i];
48062                 var symbol = signature.declaration && getSymbolOfNode(signature.declaration);
48063                 var parent = signature.declaration && signature.declaration.parent;
48064                 if (!lastSymbol || symbol === lastSymbol) {
48065                     if (lastParent && parent === lastParent) {
48066                         index = index + 1;
48067                     }
48068                     else {
48069                         lastParent = parent;
48070                         index = cutoffIndex;
48071                     }
48072                 }
48073                 else {
48074                     index = cutoffIndex = result.length;
48075                     lastParent = parent;
48076                 }
48077                 lastSymbol = symbol;
48078                 if (signatureHasLiteralTypes(signature)) {
48079                     specializedIndex++;
48080                     spliceIndex = specializedIndex;
48081                     cutoffIndex++;
48082                 }
48083                 else {
48084                     spliceIndex = index;
48085                 }
48086                 result.splice(spliceIndex, 0, callChainFlags ? getOptionalCallSignature(signature, callChainFlags) : signature);
48087             }
48088         }
48089         function isSpreadArgument(arg) {
48090             return !!arg && (arg.kind === 213 || arg.kind === 220 && arg.isSpread);
48091         }
48092         function getSpreadArgumentIndex(args) {
48093             return ts.findIndex(args, isSpreadArgument);
48094         }
48095         function acceptsVoid(t) {
48096             return !!(t.flags & 16384);
48097         }
48098         function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) {
48099             if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; }
48100             var argCount;
48101             var callIsIncomplete = false;
48102             var effectiveParameterCount = getParameterCount(signature);
48103             var effectiveMinimumArguments = getMinArgumentCount(signature);
48104             if (node.kind === 198) {
48105                 argCount = args.length;
48106                 if (node.template.kind === 211) {
48107                     var lastSpan = ts.last(node.template.templateSpans);
48108                     callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated;
48109                 }
48110                 else {
48111                     var templateLiteral = node.template;
48112                     ts.Debug.assert(templateLiteral.kind === 14);
48113                     callIsIncomplete = !!templateLiteral.isUnterminated;
48114                 }
48115             }
48116             else if (node.kind === 157) {
48117                 argCount = getDecoratorArgumentCount(node, signature);
48118             }
48119             else if (ts.isJsxOpeningLikeElement(node)) {
48120                 callIsIncomplete = node.attributes.end === node.end;
48121                 if (callIsIncomplete) {
48122                     return true;
48123                 }
48124                 argCount = effectiveMinimumArguments === 0 ? args.length : 1;
48125                 effectiveParameterCount = args.length === 0 ? effectiveParameterCount : 1;
48126                 effectiveMinimumArguments = Math.min(effectiveMinimumArguments, 1);
48127             }
48128             else {
48129                 if (!node.arguments) {
48130                     ts.Debug.assert(node.kind === 197);
48131                     return getMinArgumentCount(signature) === 0;
48132                 }
48133                 argCount = signatureHelpTrailingComma ? args.length + 1 : args.length;
48134                 callIsIncomplete = node.arguments.end === node.end;
48135                 var spreadArgIndex = getSpreadArgumentIndex(args);
48136                 if (spreadArgIndex >= 0) {
48137                     return spreadArgIndex >= getMinArgumentCount(signature) && (hasEffectiveRestParameter(signature) || spreadArgIndex < getParameterCount(signature));
48138                 }
48139             }
48140             if (!hasEffectiveRestParameter(signature) && argCount > effectiveParameterCount) {
48141                 return false;
48142             }
48143             if (callIsIncomplete || argCount >= effectiveMinimumArguments) {
48144                 return true;
48145             }
48146             for (var i = argCount; i < effectiveMinimumArguments; i++) {
48147                 var type = getTypeAtPosition(signature, i);
48148                 if (filterType(type, acceptsVoid).flags & 131072) {
48149                     return false;
48150                 }
48151             }
48152             return true;
48153         }
48154         function hasCorrectTypeArgumentArity(signature, typeArguments) {
48155             var numTypeParameters = ts.length(signature.typeParameters);
48156             var minTypeArgumentCount = getMinTypeArgumentCount(signature.typeParameters);
48157             return !ts.some(typeArguments) ||
48158                 (typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters);
48159         }
48160         function getSingleCallSignature(type) {
48161             return getSingleSignature(type, 0, false);
48162         }
48163         function getSingleCallOrConstructSignature(type) {
48164             return getSingleSignature(type, 0, false) ||
48165                 getSingleSignature(type, 1, false);
48166         }
48167         function getSingleSignature(type, kind, allowMembers) {
48168             if (type.flags & 524288) {
48169                 var resolved = resolveStructuredTypeMembers(type);
48170                 if (allowMembers || resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) {
48171                     if (kind === 0 && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) {
48172                         return resolved.callSignatures[0];
48173                     }
48174                     if (kind === 1 && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) {
48175                         return resolved.constructSignatures[0];
48176                     }
48177                 }
48178             }
48179             return undefined;
48180         }
48181         function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes) {
48182             var context = createInferenceContext(signature.typeParameters, signature, 0, compareTypes);
48183             var restType = getEffectiveRestType(contextualSignature);
48184             var mapper = inferenceContext && (restType && restType.flags & 262144 ? inferenceContext.nonFixingMapper : inferenceContext.mapper);
48185             var sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature;
48186             applyToParameterTypes(sourceSignature, signature, function (source, target) {
48187                 inferTypes(context.inferences, source, target);
48188             });
48189             if (!inferenceContext) {
48190                 applyToReturnTypes(contextualSignature, signature, function (source, target) {
48191                     inferTypes(context.inferences, source, target, 32);
48192                 });
48193             }
48194             return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration));
48195         }
48196         function inferJsxTypeArguments(node, signature, checkMode, context) {
48197             var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node);
48198             var checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, context, checkMode);
48199             inferTypes(context.inferences, checkAttrType, paramType);
48200             return getInferredTypes(context);
48201         }
48202         function inferTypeArguments(node, signature, args, checkMode, context) {
48203             if (ts.isJsxOpeningLikeElement(node)) {
48204                 return inferJsxTypeArguments(node, signature, checkMode, context);
48205             }
48206             if (node.kind !== 157) {
48207                 var contextualType = getContextualType(node);
48208                 if (contextualType) {
48209                     var outerContext = getInferenceContext(node);
48210                     var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1));
48211                     var instantiatedType = instantiateType(contextualType, outerMapper);
48212                     var contextualSignature = getSingleCallSignature(instantiatedType);
48213                     var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
48214                         getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
48215                         instantiatedType;
48216                     var inferenceTargetType = getReturnTypeOfSignature(signature);
48217                     inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 32);
48218                     var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
48219                     var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
48220                     inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
48221                     context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined;
48222                 }
48223             }
48224             var thisType = getThisTypeOfSignature(signature);
48225             if (thisType) {
48226                 var thisArgumentNode = getThisArgumentOfCall(node);
48227                 var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType;
48228                 inferTypes(context.inferences, thisArgumentType, thisType);
48229             }
48230             var restType = getNonArrayRestType(signature);
48231             var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length;
48232             for (var i = 0; i < argCount; i++) {
48233                 var arg = args[i];
48234                 if (arg.kind !== 215) {
48235                     var paramType = getTypeAtPosition(signature, i);
48236                     var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
48237                     inferTypes(context.inferences, argType, paramType);
48238                 }
48239             }
48240             if (restType) {
48241                 var spreadType = getSpreadArgumentType(args, argCount, args.length, restType, context);
48242                 inferTypes(context.inferences, spreadType, restType);
48243             }
48244             return getInferredTypes(context);
48245         }
48246         function getArrayifiedType(type) {
48247             return type.flags & 1048576 ? mapType(type, getArrayifiedType) :
48248                 type.flags & (1 | 63176704) || isMutableArrayOrTuple(type) ? type :
48249                     isTupleType(type) ? createTupleType(getTypeArguments(type), type.target.minLength, type.target.hasRestElement, false, type.target.associatedNames) :
48250                         createArrayType(getIndexedAccessType(type, numberType));
48251         }
48252         function getSpreadArgumentType(args, index, argCount, restType, context) {
48253             if (index >= argCount - 1) {
48254                 var arg = args[argCount - 1];
48255                 if (isSpreadArgument(arg)) {
48256                     return arg.kind === 220 ?
48257                         createArrayType(arg.type) :
48258                         getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context, 0));
48259                 }
48260             }
48261             var types = [];
48262             var spreadIndex = -1;
48263             for (var i = index; i < argCount; i++) {
48264                 var contextualType = getIndexedAccessType(restType, getLiteralType(i - index));
48265                 var argType = checkExpressionWithContextualType(args[i], contextualType, context, 0);
48266                 if (spreadIndex < 0 && isSpreadArgument(args[i])) {
48267                     spreadIndex = i - index;
48268                 }
48269                 var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 | 4194304);
48270                 types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType));
48271             }
48272             return spreadIndex < 0 ?
48273                 createTupleType(types) :
48274                 createTupleType(ts.append(types.slice(0, spreadIndex), getUnionType(types.slice(spreadIndex))), spreadIndex, true);
48275         }
48276         function checkTypeArguments(signature, typeArgumentNodes, reportErrors, headMessage) {
48277             var isJavascript = ts.isInJSFile(signature.declaration);
48278             var typeParameters = signature.typeParameters;
48279             var typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), isJavascript);
48280             var mapper;
48281             for (var i = 0; i < typeArgumentNodes.length; i++) {
48282                 ts.Debug.assert(typeParameters[i] !== undefined, "Should not call checkTypeArguments with too many type arguments");
48283                 var constraint = getConstraintOfTypeParameter(typeParameters[i]);
48284                 if (constraint) {
48285                     var errorInfo = reportErrors && headMessage ? (function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); }) : undefined;
48286                     var typeArgumentHeadMessage = headMessage || ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1;
48287                     if (!mapper) {
48288                         mapper = createTypeMapper(typeParameters, typeArgumentTypes);
48289                     }
48290                     var typeArgument = typeArgumentTypes[i];
48291                     if (!checkTypeAssignableTo(typeArgument, getTypeWithThisArgument(instantiateType(constraint, mapper), typeArgument), reportErrors ? typeArgumentNodes[i] : undefined, typeArgumentHeadMessage, errorInfo)) {
48292                         return undefined;
48293                     }
48294                 }
48295             }
48296             return typeArgumentTypes;
48297         }
48298         function getJsxReferenceKind(node) {
48299             if (isJsxIntrinsicIdentifier(node.tagName)) {
48300                 return 2;
48301             }
48302             var tagType = getApparentType(checkExpression(node.tagName));
48303             if (ts.length(getSignaturesOfType(tagType, 1))) {
48304                 return 0;
48305             }
48306             if (ts.length(getSignaturesOfType(tagType, 0))) {
48307                 return 1;
48308             }
48309             return 2;
48310         }
48311         function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer) {
48312             var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node);
48313             var attributesType = checkExpressionWithContextualType(node.attributes, paramType, undefined, checkMode);
48314             return checkTagNameDoesNotExpectTooManyArguments() && checkTypeRelatedToAndOptionallyElaborate(attributesType, paramType, relation, reportErrors ? node.tagName : undefined, node.attributes, undefined, containingMessageChain, errorOutputContainer);
48315             function checkTagNameDoesNotExpectTooManyArguments() {
48316                 var _a;
48317                 var tagType = ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node) && !isJsxIntrinsicIdentifier(node.tagName) ? checkExpression(node.tagName) : undefined;
48318                 if (!tagType) {
48319                     return true;
48320                 }
48321                 var tagCallSignatures = getSignaturesOfType(tagType, 0);
48322                 if (!ts.length(tagCallSignatures)) {
48323                     return true;
48324                 }
48325                 var factory = getJsxFactoryEntity(node);
48326                 if (!factory) {
48327                     return true;
48328                 }
48329                 var factorySymbol = resolveEntityName(factory, 111551, true, false, node);
48330                 if (!factorySymbol) {
48331                     return true;
48332                 }
48333                 var factoryType = getTypeOfSymbol(factorySymbol);
48334                 var callSignatures = getSignaturesOfType(factoryType, 0);
48335                 if (!ts.length(callSignatures)) {
48336                     return true;
48337                 }
48338                 var hasFirstParamSignatures = false;
48339                 var maxParamCount = 0;
48340                 for (var _i = 0, callSignatures_1 = callSignatures; _i < callSignatures_1.length; _i++) {
48341                     var sig = callSignatures_1[_i];
48342                     var firstparam = getTypeAtPosition(sig, 0);
48343                     var signaturesOfParam = getSignaturesOfType(firstparam, 0);
48344                     if (!ts.length(signaturesOfParam))
48345                         continue;
48346                     for (var _b = 0, signaturesOfParam_1 = signaturesOfParam; _b < signaturesOfParam_1.length; _b++) {
48347                         var paramSig = signaturesOfParam_1[_b];
48348                         hasFirstParamSignatures = true;
48349                         if (hasEffectiveRestParameter(paramSig)) {
48350                             return true;
48351                         }
48352                         var paramCount = getParameterCount(paramSig);
48353                         if (paramCount > maxParamCount) {
48354                             maxParamCount = paramCount;
48355                         }
48356                     }
48357                 }
48358                 if (!hasFirstParamSignatures) {
48359                     return true;
48360                 }
48361                 var absoluteMinArgCount = Infinity;
48362                 for (var _c = 0, tagCallSignatures_1 = tagCallSignatures; _c < tagCallSignatures_1.length; _c++) {
48363                     var tagSig = tagCallSignatures_1[_c];
48364                     var tagRequiredArgCount = getMinArgumentCount(tagSig);
48365                     if (tagRequiredArgCount < absoluteMinArgCount) {
48366                         absoluteMinArgCount = tagRequiredArgCount;
48367                     }
48368                 }
48369                 if (absoluteMinArgCount <= maxParamCount) {
48370                     return true;
48371                 }
48372                 if (reportErrors) {
48373                     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);
48374                     var tagNameDeclaration = (_a = getSymbolAtLocation(node.tagName)) === null || _a === void 0 ? void 0 : _a.valueDeclaration;
48375                     if (tagNameDeclaration) {
48376                         ts.addRelatedInfo(diag, ts.createDiagnosticForNode(tagNameDeclaration, ts.Diagnostics._0_is_declared_here, ts.entityNameToString(node.tagName)));
48377                     }
48378                     if (errorOutputContainer && errorOutputContainer.skipLogging) {
48379                         (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
48380                     }
48381                     if (!errorOutputContainer.skipLogging) {
48382                         diagnostics.add(diag);
48383                     }
48384                 }
48385                 return false;
48386             }
48387         }
48388         function getSignatureApplicabilityError(node, args, signature, relation, checkMode, reportErrors, containingMessageChain) {
48389             var errorOutputContainer = { errors: undefined, skipLogging: true };
48390             if (ts.isJsxOpeningLikeElement(node)) {
48391                 if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) {
48392                     ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors");
48393                     return errorOutputContainer.errors || ts.emptyArray;
48394                 }
48395                 return undefined;
48396             }
48397             var thisType = getThisTypeOfSignature(signature);
48398             if (thisType && thisType !== voidType && node.kind !== 197) {
48399                 var thisArgumentNode = getThisArgumentOfCall(node);
48400                 var thisArgumentType = void 0;
48401                 if (thisArgumentNode) {
48402                     thisArgumentType = checkExpression(thisArgumentNode);
48403                     if (ts.isOptionalChainRoot(thisArgumentNode.parent)) {
48404                         thisArgumentType = getNonNullableType(thisArgumentType);
48405                     }
48406                     else if (ts.isOptionalChain(thisArgumentNode.parent)) {
48407                         thisArgumentType = removeOptionalTypeMarker(thisArgumentType);
48408                     }
48409                 }
48410                 else {
48411                     thisArgumentType = voidType;
48412                 }
48413                 var errorNode = reportErrors ? (thisArgumentNode || node) : undefined;
48414                 var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1;
48415                 if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) {
48416                     ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors");
48417                     return errorOutputContainer.errors || ts.emptyArray;
48418                 }
48419             }
48420             var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1;
48421             var restType = getNonArrayRestType(signature);
48422             var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length;
48423             for (var i = 0; i < argCount; i++) {
48424                 var arg = args[i];
48425                 if (arg.kind !== 215) {
48426                     var paramType = getTypeAtPosition(signature, i);
48427                     var argType = checkExpressionWithContextualType(arg, paramType, undefined, checkMode);
48428                     var checkArgType = checkMode & 4 ? getRegularTypeOfObjectLiteral(argType) : argType;
48429                     if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) {
48430                         ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors");
48431                         maybeAddMissingAwaitInfo(arg, checkArgType, paramType);
48432                         return errorOutputContainer.errors || ts.emptyArray;
48433                     }
48434                 }
48435             }
48436             if (restType) {
48437                 var spreadType = getSpreadArgumentType(args, argCount, args.length, restType, undefined);
48438                 var errorNode = reportErrors ? argCount < args.length ? args[argCount] : node : undefined;
48439                 if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, undefined, errorOutputContainer)) {
48440                     ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors");
48441                     maybeAddMissingAwaitInfo(errorNode, spreadType, restType);
48442                     return errorOutputContainer.errors || ts.emptyArray;
48443                 }
48444             }
48445             return undefined;
48446             function maybeAddMissingAwaitInfo(errorNode, source, target) {
48447                 if (errorNode && reportErrors && errorOutputContainer.errors && errorOutputContainer.errors.length) {
48448                     if (getAwaitedTypeOfPromise(target)) {
48449                         return;
48450                     }
48451                     var awaitedTypeOfSource = getAwaitedTypeOfPromise(source);
48452                     if (awaitedTypeOfSource && isTypeRelatedTo(awaitedTypeOfSource, target, relation)) {
48453                         ts.addRelatedInfo(errorOutputContainer.errors[0], ts.createDiagnosticForNode(errorNode, ts.Diagnostics.Did_you_forget_to_use_await));
48454                     }
48455                 }
48456             }
48457         }
48458         function getThisArgumentOfCall(node) {
48459             if (node.kind === 196) {
48460                 var callee = ts.skipOuterExpressions(node.expression);
48461                 if (ts.isAccessExpression(callee)) {
48462                     return callee.expression;
48463                 }
48464             }
48465         }
48466         function createSyntheticExpression(parent, type, isSpread) {
48467             var result = ts.createNode(220, parent.pos, parent.end);
48468             result.parent = parent;
48469             result.type = type;
48470             result.isSpread = isSpread || false;
48471             return result;
48472         }
48473         function getEffectiveCallArguments(node) {
48474             if (node.kind === 198) {
48475                 var template = node.template;
48476                 var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())];
48477                 if (template.kind === 211) {
48478                     ts.forEach(template.templateSpans, function (span) {
48479                         args_3.push(span.expression);
48480                     });
48481                 }
48482                 return args_3;
48483             }
48484             if (node.kind === 157) {
48485                 return getEffectiveDecoratorArguments(node);
48486             }
48487             if (ts.isJsxOpeningLikeElement(node)) {
48488                 return node.attributes.properties.length > 0 || (ts.isJsxOpeningElement(node) && node.parent.children.length > 0) ? [node.attributes] : ts.emptyArray;
48489             }
48490             var args = node.arguments || ts.emptyArray;
48491             var length = args.length;
48492             if (length && isSpreadArgument(args[length - 1]) && getSpreadArgumentIndex(args) === length - 1) {
48493                 var spreadArgument_1 = args[length - 1];
48494                 var type = flowLoopCount ? checkExpression(spreadArgument_1.expression) : checkExpressionCached(spreadArgument_1.expression);
48495                 if (isTupleType(type)) {
48496                     var typeArguments = getTypeArguments(type);
48497                     var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1;
48498                     var syntheticArgs = ts.map(typeArguments, function (t, i) { return createSyntheticExpression(spreadArgument_1, t, i === restIndex_2); });
48499                     return ts.concatenate(args.slice(0, length - 1), syntheticArgs);
48500                 }
48501             }
48502             return args;
48503         }
48504         function getEffectiveDecoratorArguments(node) {
48505             var parent = node.parent;
48506             var expr = node.expression;
48507             switch (parent.kind) {
48508                 case 245:
48509                 case 214:
48510                     return [
48511                         createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent)))
48512                     ];
48513                 case 156:
48514                     var func = parent.parent;
48515                     return [
48516                         createSyntheticExpression(expr, parent.parent.kind === 162 ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType),
48517                         createSyntheticExpression(expr, anyType),
48518                         createSyntheticExpression(expr, numberType)
48519                     ];
48520                 case 159:
48521                 case 161:
48522                 case 163:
48523                 case 164:
48524                     var hasPropDesc = parent.kind !== 159 && languageVersion !== 0;
48525                     return [
48526                         createSyntheticExpression(expr, getParentTypeOfClassElement(parent)),
48527                         createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)),
48528                         createSyntheticExpression(expr, hasPropDesc ? createTypedPropertyDescriptorType(getTypeOfNode(parent)) : anyType)
48529                     ];
48530             }
48531             return ts.Debug.fail();
48532         }
48533         function getDecoratorArgumentCount(node, signature) {
48534             switch (node.parent.kind) {
48535                 case 245:
48536                 case 214:
48537                     return 1;
48538                 case 159:
48539                     return 2;
48540                 case 161:
48541                 case 163:
48542                 case 164:
48543                     return languageVersion === 0 || signature.parameters.length <= 2 ? 2 : 3;
48544                 case 156:
48545                     return 3;
48546                 default:
48547                     return ts.Debug.fail();
48548             }
48549         }
48550         function getDiagnosticSpanForCallNode(node, doNotIncludeArguments) {
48551             var start;
48552             var length;
48553             var sourceFile = ts.getSourceFileOfNode(node);
48554             if (ts.isPropertyAccessExpression(node.expression)) {
48555                 var nameSpan = ts.getErrorSpanForNode(sourceFile, node.expression.name);
48556                 start = nameSpan.start;
48557                 length = doNotIncludeArguments ? nameSpan.length : node.end - start;
48558             }
48559             else {
48560                 var expressionSpan = ts.getErrorSpanForNode(sourceFile, node.expression);
48561                 start = expressionSpan.start;
48562                 length = doNotIncludeArguments ? expressionSpan.length : node.end - start;
48563             }
48564             return { start: start, length: length, sourceFile: sourceFile };
48565         }
48566         function getDiagnosticForCallNode(node, message, arg0, arg1, arg2, arg3) {
48567             if (ts.isCallExpression(node)) {
48568                 var _a = getDiagnosticSpanForCallNode(node), sourceFile = _a.sourceFile, start = _a.start, length_5 = _a.length;
48569                 return ts.createFileDiagnostic(sourceFile, start, length_5, message, arg0, arg1, arg2, arg3);
48570             }
48571             else {
48572                 return ts.createDiagnosticForNode(node, message, arg0, arg1, arg2, arg3);
48573             }
48574         }
48575         function getArgumentArityError(node, signatures, args) {
48576             var min = Number.POSITIVE_INFINITY;
48577             var max = Number.NEGATIVE_INFINITY;
48578             var belowArgCount = Number.NEGATIVE_INFINITY;
48579             var aboveArgCount = Number.POSITIVE_INFINITY;
48580             var argCount = args.length;
48581             var closestSignature;
48582             for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) {
48583                 var sig = signatures_8[_i];
48584                 var minCount = getMinArgumentCount(sig);
48585                 var maxCount = getParameterCount(sig);
48586                 if (minCount < argCount && minCount > belowArgCount)
48587                     belowArgCount = minCount;
48588                 if (argCount < maxCount && maxCount < aboveArgCount)
48589                     aboveArgCount = maxCount;
48590                 if (minCount < min) {
48591                     min = minCount;
48592                     closestSignature = sig;
48593                 }
48594                 max = Math.max(max, maxCount);
48595             }
48596             var hasRestParameter = ts.some(signatures, hasEffectiveRestParameter);
48597             var paramRange = hasRestParameter ? min :
48598                 min < max ? min + "-" + max :
48599                     min;
48600             var hasSpreadArgument = getSpreadArgumentIndex(args) > -1;
48601             if (argCount <= max && hasSpreadArgument) {
48602                 argCount--;
48603             }
48604             var spanArray;
48605             var related;
48606             var error = hasRestParameter || hasSpreadArgument ? hasRestParameter && hasSpreadArgument ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more :
48607                 hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 :
48608                     ts.Diagnostics.Expected_0_arguments_but_got_1_or_more : ts.Diagnostics.Expected_0_arguments_but_got_1;
48609             if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) {
48610                 var paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount];
48611                 if (paramDecl) {
48612                     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);
48613                 }
48614             }
48615             if (min < argCount && argCount < max) {
48616                 return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, argCount, belowArgCount, aboveArgCount);
48617             }
48618             if (!hasSpreadArgument && argCount < min) {
48619                 var diagnostic_1 = getDiagnosticForCallNode(node, error, paramRange, argCount);
48620                 return related ? ts.addRelatedInfo(diagnostic_1, related) : diagnostic_1;
48621             }
48622             if (hasRestParameter || hasSpreadArgument) {
48623                 spanArray = ts.createNodeArray(args);
48624                 if (hasSpreadArgument && argCount) {
48625                     var nextArg = ts.elementAt(args, getSpreadArgumentIndex(args) + 1) || undefined;
48626                     spanArray = ts.createNodeArray(args.slice(max > argCount && nextArg ? args.indexOf(nextArg) : Math.min(max, args.length - 1)));
48627                 }
48628             }
48629             else {
48630                 spanArray = ts.createNodeArray(args.slice(max));
48631             }
48632             spanArray.pos = ts.first(spanArray).pos;
48633             spanArray.end = ts.last(spanArray).end;
48634             if (spanArray.end === spanArray.pos) {
48635                 spanArray.end++;
48636             }
48637             var diagnostic = ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), spanArray, error, paramRange, argCount);
48638             return related ? ts.addRelatedInfo(diagnostic, related) : diagnostic;
48639         }
48640         function getTypeArgumentArityError(node, signatures, typeArguments) {
48641             var argCount = typeArguments.length;
48642             if (signatures.length === 1) {
48643                 var sig = signatures[0];
48644                 var min_1 = getMinTypeArgumentCount(sig.typeParameters);
48645                 var max = ts.length(sig.typeParameters);
48646                 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);
48647             }
48648             var belowArgCount = -Infinity;
48649             var aboveArgCount = Infinity;
48650             for (var _i = 0, signatures_9 = signatures; _i < signatures_9.length; _i++) {
48651                 var sig = signatures_9[_i];
48652                 var min_2 = getMinTypeArgumentCount(sig.typeParameters);
48653                 var max = ts.length(sig.typeParameters);
48654                 if (min_2 > argCount) {
48655                     aboveArgCount = Math.min(aboveArgCount, min_2);
48656                 }
48657                 else if (max < argCount) {
48658                     belowArgCount = Math.max(belowArgCount, max);
48659                 }
48660             }
48661             if (belowArgCount !== -Infinity && aboveArgCount !== Infinity) {
48662                 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);
48663             }
48664             return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
48665         }
48666         function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) {
48667             var isTaggedTemplate = node.kind === 198;
48668             var isDecorator = node.kind === 157;
48669             var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
48670             var reportErrors = !candidatesOutArray;
48671             var typeArguments;
48672             if (!isDecorator) {
48673                 typeArguments = node.typeArguments;
48674                 if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 102) {
48675                     ts.forEach(typeArguments, checkSourceElement);
48676                 }
48677             }
48678             var candidates = candidatesOutArray || [];
48679             reorderCandidates(signatures, candidates, callChainFlags);
48680             if (!candidates.length) {
48681                 if (reportErrors) {
48682                     diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures));
48683                 }
48684                 return resolveErrorCall(node);
48685             }
48686             var args = getEffectiveCallArguments(node);
48687             var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
48688             var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 : 0;
48689             var candidatesForArgumentError;
48690             var candidateForArgumentArityError;
48691             var candidateForTypeArgumentError;
48692             var result;
48693             var signatureHelpTrailingComma = !!(checkMode & 16) && node.kind === 196 && node.arguments.hasTrailingComma;
48694             if (candidates.length > 1) {
48695                 result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma);
48696             }
48697             if (!result) {
48698                 result = chooseOverload(candidates, assignableRelation, signatureHelpTrailingComma);
48699             }
48700             if (result) {
48701                 return result;
48702             }
48703             if (reportErrors) {
48704                 if (candidatesForArgumentError) {
48705                     if (candidatesForArgumentError.length === 1 || candidatesForArgumentError.length > 3) {
48706                         var last_2 = candidatesForArgumentError[candidatesForArgumentError.length - 1];
48707                         var chain_1;
48708                         if (candidatesForArgumentError.length > 3) {
48709                             chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.The_last_overload_gave_the_following_error);
48710                             chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.No_overload_matches_this_call);
48711                         }
48712                         var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0, true, function () { return chain_1; });
48713                         if (diags) {
48714                             for (var _i = 0, diags_1 = diags; _i < diags_1.length; _i++) {
48715                                 var d = diags_1[_i];
48716                                 if (last_2.declaration && candidatesForArgumentError.length > 3) {
48717                                     ts.addRelatedInfo(d, ts.createDiagnosticForNode(last_2.declaration, ts.Diagnostics.The_last_overload_is_declared_here));
48718                                 }
48719                                 diagnostics.add(d);
48720                             }
48721                         }
48722                         else {
48723                             ts.Debug.fail("No error for last overload signature");
48724                         }
48725                     }
48726                     else {
48727                         var allDiagnostics = [];
48728                         var max = 0;
48729                         var min_3 = Number.MAX_VALUE;
48730                         var minIndex = 0;
48731                         var i_1 = 0;
48732                         var _loop_17 = function (c) {
48733                             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)); };
48734                             var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0, true, chain_2);
48735                             if (diags_2) {
48736                                 if (diags_2.length <= min_3) {
48737                                     min_3 = diags_2.length;
48738                                     minIndex = i_1;
48739                                 }
48740                                 max = Math.max(max, diags_2.length);
48741                                 allDiagnostics.push(diags_2);
48742                             }
48743                             else {
48744                                 ts.Debug.fail("No error for 3 or fewer overload signatures");
48745                             }
48746                             i_1++;
48747                         };
48748                         for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
48749                             var c = candidatesForArgumentError_1[_a];
48750                             _loop_17(c);
48751                         }
48752                         var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
48753                         ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
48754                         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);
48755                         var related = ts.flatMap(diags_3, function (d) { return d.relatedInformation; });
48756                         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; })) {
48757                             var _b = diags_3[0], file = _b.file, start = _b.start, length_6 = _b.length;
48758                             diagnostics.add({ file: file, start: start, length: length_6, code: chain.code, category: chain.category, messageText: chain, relatedInformation: related });
48759                         }
48760                         else {
48761                             diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, chain, related));
48762                         }
48763                     }
48764                 }
48765                 else if (candidateForArgumentArityError) {
48766                     diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args));
48767                 }
48768                 else if (candidateForTypeArgumentError) {
48769                     checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, true, fallbackError);
48770                 }
48771                 else {
48772                     var signaturesWithCorrectTypeArgumentArity = ts.filter(signatures, function (s) { return hasCorrectTypeArgumentArity(s, typeArguments); });
48773                     if (signaturesWithCorrectTypeArgumentArity.length === 0) {
48774                         diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments));
48775                     }
48776                     else if (!isDecorator) {
48777                         diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args));
48778                     }
48779                     else if (fallbackError) {
48780                         diagnostics.add(getDiagnosticForCallNode(node, fallbackError));
48781                     }
48782                 }
48783             }
48784             return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
48785             function chooseOverload(candidates, relation, signatureHelpTrailingComma) {
48786                 if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; }
48787                 candidatesForArgumentError = undefined;
48788                 candidateForArgumentArityError = undefined;
48789                 candidateForTypeArgumentError = undefined;
48790                 if (isSingleNonGenericCandidate) {
48791                     var candidate = candidates[0];
48792                     if (ts.some(typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) {
48793                         return undefined;
48794                     }
48795                     if (getSignatureApplicabilityError(node, args, candidate, relation, 0, false, undefined)) {
48796                         candidatesForArgumentError = [candidate];
48797                         return undefined;
48798                     }
48799                     return candidate;
48800                 }
48801                 for (var candidateIndex = 0; candidateIndex < candidates.length; candidateIndex++) {
48802                     var candidate = candidates[candidateIndex];
48803                     if (!hasCorrectTypeArgumentArity(candidate, typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) {
48804                         continue;
48805                     }
48806                     var checkCandidate = void 0;
48807                     var inferenceContext = void 0;
48808                     if (candidate.typeParameters) {
48809                         var typeArgumentTypes = void 0;
48810                         if (ts.some(typeArguments)) {
48811                             typeArgumentTypes = checkTypeArguments(candidate, typeArguments, false);
48812                             if (!typeArgumentTypes) {
48813                                 candidateForTypeArgumentError = candidate;
48814                                 continue;
48815                             }
48816                         }
48817                         else {
48818                             inferenceContext = createInferenceContext(candidate.typeParameters, candidate, ts.isInJSFile(node) ? 2 : 0);
48819                             typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8, inferenceContext);
48820                             argCheckMode |= inferenceContext.flags & 4 ? 8 : 0;
48821                         }
48822                         checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
48823                         if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
48824                             candidateForArgumentArityError = checkCandidate;
48825                             continue;
48826                         }
48827                     }
48828                     else {
48829                         checkCandidate = candidate;
48830                     }
48831                     if (getSignatureApplicabilityError(node, args, checkCandidate, relation, argCheckMode, false, undefined)) {
48832                         (candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate);
48833                         continue;
48834                     }
48835                     if (argCheckMode) {
48836                         argCheckMode = 0;
48837                         if (inferenceContext) {
48838                             var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
48839                             checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
48840                             if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
48841                                 candidateForArgumentArityError = checkCandidate;
48842                                 continue;
48843                             }
48844                         }
48845                         if (getSignatureApplicabilityError(node, args, checkCandidate, relation, argCheckMode, false, undefined)) {
48846                             (candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate);
48847                             continue;
48848                         }
48849                     }
48850                     candidates[candidateIndex] = checkCandidate;
48851                     return checkCandidate;
48852                 }
48853                 return undefined;
48854             }
48855         }
48856         function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray) {
48857             ts.Debug.assert(candidates.length > 0);
48858             checkNodeDeferred(node);
48859             return hasCandidatesOutArray || candidates.length === 1 || candidates.some(function (c) { return !!c.typeParameters; })
48860                 ? pickLongestCandidateSignature(node, candidates, args)
48861                 : createUnionOfSignaturesForOverloadFailure(candidates);
48862         }
48863         function createUnionOfSignaturesForOverloadFailure(candidates) {
48864             var thisParameters = ts.mapDefined(candidates, function (c) { return c.thisParameter; });
48865             var thisParameter;
48866             if (thisParameters.length) {
48867                 thisParameter = createCombinedSymbolFromTypes(thisParameters, thisParameters.map(getTypeOfParameter));
48868             }
48869             var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
48870             var parameters = [];
48871             var _loop_18 = function (i) {
48872                 var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
48873                     i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
48874                     i < s.parameters.length ? s.parameters[i] : undefined; });
48875                 ts.Debug.assert(symbols.length !== 0);
48876                 parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
48877             };
48878             for (var i = 0; i < maxNonRestParam; i++) {
48879                 _loop_18(i);
48880             }
48881             var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
48882             var flags = 0;
48883             if (restParameterSymbols.length !== 0) {
48884                 var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2));
48885                 parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type));
48886                 flags |= 1;
48887             }
48888             if (candidates.some(signatureHasLiteralTypes)) {
48889                 flags |= 2;
48890             }
48891             return createSignature(candidates[0].declaration, undefined, thisParameter, parameters, getIntersectionType(candidates.map(getReturnTypeOfSignature)), undefined, minArgumentCount, flags);
48892         }
48893         function getNumNonRestParameters(signature) {
48894             var numParams = signature.parameters.length;
48895             return signatureHasRestParameter(signature) ? numParams - 1 : numParams;
48896         }
48897         function createCombinedSymbolFromTypes(sources, types) {
48898             return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2));
48899         }
48900         function createCombinedSymbolForOverloadFailure(sources, type) {
48901             return createSymbolWithType(ts.first(sources), type);
48902         }
48903         function pickLongestCandidateSignature(node, candidates, args) {
48904             var bestIndex = getLongestCandidateIndex(candidates, apparentArgumentCount === undefined ? args.length : apparentArgumentCount);
48905             var candidate = candidates[bestIndex];
48906             var typeParameters = candidate.typeParameters;
48907             if (!typeParameters) {
48908                 return candidate;
48909             }
48910             var typeArgumentNodes = callLikeExpressionMayHaveTypeArguments(node) ? node.typeArguments : undefined;
48911             var instantiated = typeArgumentNodes
48912                 ? createSignatureInstantiation(candidate, getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, ts.isInJSFile(node)))
48913                 : inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args);
48914             candidates[bestIndex] = instantiated;
48915             return instantiated;
48916         }
48917         function getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, isJs) {
48918             var typeArguments = typeArgumentNodes.map(getTypeOfNode);
48919             while (typeArguments.length > typeParameters.length) {
48920                 typeArguments.pop();
48921             }
48922             while (typeArguments.length < typeParameters.length) {
48923                 typeArguments.push(getConstraintOfTypeParameter(typeParameters[typeArguments.length]) || getDefaultTypeArgumentType(isJs));
48924             }
48925             return typeArguments;
48926         }
48927         function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args) {
48928             var inferenceContext = createInferenceContext(typeParameters, candidate, ts.isInJSFile(node) ? 2 : 0);
48929             var typeArgumentTypes = inferTypeArguments(node, candidate, args, 4 | 8, inferenceContext);
48930             return createSignatureInstantiation(candidate, typeArgumentTypes);
48931         }
48932         function getLongestCandidateIndex(candidates, argsCount) {
48933             var maxParamsIndex = -1;
48934             var maxParams = -1;
48935             for (var i = 0; i < candidates.length; i++) {
48936                 var candidate = candidates[i];
48937                 var paramCount = getParameterCount(candidate);
48938                 if (hasEffectiveRestParameter(candidate) || paramCount >= argsCount) {
48939                     return i;
48940                 }
48941                 if (paramCount > maxParams) {
48942                     maxParams = paramCount;
48943                     maxParamsIndex = i;
48944                 }
48945             }
48946             return maxParamsIndex;
48947         }
48948         function resolveCallExpression(node, candidatesOutArray, checkMode) {
48949             if (node.expression.kind === 102) {
48950                 var superType = checkSuperExpression(node.expression);
48951                 if (isTypeAny(superType)) {
48952                     for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) {
48953                         var arg = _a[_i];
48954                         checkExpression(arg);
48955                     }
48956                     return anySignature;
48957                 }
48958                 if (superType !== errorType) {
48959                     var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node));
48960                     if (baseTypeNode) {
48961                         var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode);
48962                         return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0);
48963                     }
48964                 }
48965                 return resolveUntypedCall(node);
48966             }
48967             var callChainFlags;
48968             var funcType = checkExpression(node.expression);
48969             if (ts.isCallChain(node)) {
48970                 var nonOptionalType = getOptionalExpressionType(funcType, node.expression);
48971                 callChainFlags = nonOptionalType === funcType ? 0 :
48972                     ts.isOutermostOptionalChain(node) ? 8 :
48973                         4;
48974                 funcType = nonOptionalType;
48975             }
48976             else {
48977                 callChainFlags = 0;
48978             }
48979             funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError);
48980             if (funcType === silentNeverType) {
48981                 return silentNeverSignature;
48982             }
48983             var apparentType = getApparentType(funcType);
48984             if (apparentType === errorType) {
48985                 return resolveErrorCall(node);
48986             }
48987             var callSignatures = getSignaturesOfType(apparentType, 0);
48988             var numConstructSignatures = getSignaturesOfType(apparentType, 1).length;
48989             if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) {
48990                 if (funcType !== errorType && node.typeArguments) {
48991                     error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
48992                 }
48993                 return resolveUntypedCall(node);
48994             }
48995             if (!callSignatures.length) {
48996                 if (numConstructSignatures) {
48997                     error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
48998                 }
48999                 else {
49000                     var relatedInformation = void 0;
49001                     if (node.arguments.length === 1) {
49002                         var text = ts.getSourceFileOfNode(node).text;
49003                         if (ts.isLineBreak(text.charCodeAt(ts.skipTrivia(text, node.expression.end, true) - 1))) {
49004                             relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.Are_you_missing_a_semicolon);
49005                         }
49006                     }
49007                     invocationError(node.expression, apparentType, 0, relatedInformation);
49008                 }
49009                 return resolveErrorCall(node);
49010             }
49011             if (checkMode & 8 && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
49012                 skippedGenericFunction(node, checkMode);
49013                 return resolvingSignature;
49014             }
49015             if (callSignatures.some(function (sig) { return ts.isInJSFile(sig.declaration) && !!ts.getJSDocClassTag(sig.declaration); })) {
49016                 error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
49017                 return resolveErrorCall(node);
49018             }
49019             return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
49020         }
49021         function isGenericFunctionReturningFunction(signature) {
49022             return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
49023         }
49024         function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
49025             return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144) ||
49026                 !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (1048576 | 131072)) && isTypeAssignableTo(funcType, globalFunctionType);
49027         }
49028         function resolveNewExpression(node, candidatesOutArray, checkMode) {
49029             if (node.arguments && languageVersion < 1) {
49030                 var spreadIndex = getSpreadArgumentIndex(node.arguments);
49031                 if (spreadIndex >= 0) {
49032                     error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher);
49033                 }
49034             }
49035             var expressionType = checkNonNullExpression(node.expression);
49036             if (expressionType === silentNeverType) {
49037                 return silentNeverSignature;
49038             }
49039             expressionType = getApparentType(expressionType);
49040             if (expressionType === errorType) {
49041                 return resolveErrorCall(node);
49042             }
49043             if (isTypeAny(expressionType)) {
49044                 if (node.typeArguments) {
49045                     error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
49046                 }
49047                 return resolveUntypedCall(node);
49048             }
49049             var constructSignatures = getSignaturesOfType(expressionType, 1);
49050             if (constructSignatures.length) {
49051                 if (!isConstructorAccessible(node, constructSignatures[0])) {
49052                     return resolveErrorCall(node);
49053                 }
49054                 var valueDecl = expressionType.symbol && ts.getClassLikeDeclarationOfSymbol(expressionType.symbol);
49055                 if (valueDecl && ts.hasModifier(valueDecl, 128)) {
49056                     error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class);
49057                     return resolveErrorCall(node);
49058                 }
49059                 return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0);
49060             }
49061             var callSignatures = getSignaturesOfType(expressionType, 0);
49062             if (callSignatures.length) {
49063                 var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0);
49064                 if (!noImplicitAny) {
49065                     if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) {
49066                         error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword);
49067                     }
49068                     if (getThisTypeOfSignature(signature) === voidType) {
49069                         error(node, ts.Diagnostics.A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void);
49070                     }
49071                 }
49072                 return signature;
49073             }
49074             invocationError(node.expression, expressionType, 1);
49075             return resolveErrorCall(node);
49076         }
49077         function typeHasProtectedAccessibleBase(target, type) {
49078             var baseTypes = getBaseTypes(type);
49079             if (!ts.length(baseTypes)) {
49080                 return false;
49081             }
49082             var firstBase = baseTypes[0];
49083             if (firstBase.flags & 2097152) {
49084                 var types = firstBase.types;
49085                 var mixinFlags = findMixins(types);
49086                 var i = 0;
49087                 for (var _i = 0, _a = firstBase.types; _i < _a.length; _i++) {
49088                     var intersectionMember = _a[_i];
49089                     if (!mixinFlags[i]) {
49090                         if (ts.getObjectFlags(intersectionMember) & (1 | 2)) {
49091                             if (intersectionMember.symbol === target) {
49092                                 return true;
49093                             }
49094                             if (typeHasProtectedAccessibleBase(target, intersectionMember)) {
49095                                 return true;
49096                             }
49097                         }
49098                     }
49099                     i++;
49100                 }
49101                 return false;
49102             }
49103             if (firstBase.symbol === target) {
49104                 return true;
49105             }
49106             return typeHasProtectedAccessibleBase(target, firstBase);
49107         }
49108         function isConstructorAccessible(node, signature) {
49109             if (!signature || !signature.declaration) {
49110                 return true;
49111             }
49112             var declaration = signature.declaration;
49113             var modifiers = ts.getSelectedModifierFlags(declaration, 24);
49114             if (!modifiers || declaration.kind !== 162) {
49115                 return true;
49116             }
49117             var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol);
49118             var declaringClass = getDeclaredTypeOfSymbol(declaration.parent.symbol);
49119             if (!isNodeWithinClass(node, declaringClassDeclaration)) {
49120                 var containingClass = ts.getContainingClass(node);
49121                 if (containingClass && modifiers & 16) {
49122                     var containingType = getTypeOfNode(containingClass);
49123                     if (typeHasProtectedAccessibleBase(declaration.parent.symbol, containingType)) {
49124                         return true;
49125                     }
49126                 }
49127                 if (modifiers & 8) {
49128                     error(node, ts.Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass));
49129                 }
49130                 if (modifiers & 16) {
49131                     error(node, ts.Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass));
49132                 }
49133                 return false;
49134             }
49135             return true;
49136         }
49137         function invocationErrorDetails(apparentType, kind) {
49138             var errorInfo;
49139             var isCall = kind === 0;
49140             var awaitedType = getAwaitedType(apparentType);
49141             var maybeMissingAwait = awaitedType && getSignaturesOfType(awaitedType, kind).length > 0;
49142             if (apparentType.flags & 1048576) {
49143                 var types = apparentType.types;
49144                 var hasSignatures = false;
49145                 for (var _i = 0, types_18 = types; _i < types_18.length; _i++) {
49146                     var constituent = types_18[_i];
49147                     var signatures = getSignaturesOfType(constituent, kind);
49148                     if (signatures.length !== 0) {
49149                         hasSignatures = true;
49150                         if (errorInfo) {
49151                             break;
49152                         }
49153                     }
49154                     else {
49155                         if (!errorInfo) {
49156                             errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
49157                                 ts.Diagnostics.Type_0_has_no_call_signatures :
49158                                 ts.Diagnostics.Type_0_has_no_construct_signatures, typeToString(constituent));
49159                             errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
49160                                 ts.Diagnostics.Not_all_constituents_of_type_0_are_callable :
49161                                 ts.Diagnostics.Not_all_constituents_of_type_0_are_constructable, typeToString(apparentType));
49162                         }
49163                         if (hasSignatures) {
49164                             break;
49165                         }
49166                     }
49167                 }
49168                 if (!hasSignatures) {
49169                     errorInfo = ts.chainDiagnosticMessages(undefined, isCall ?
49170                         ts.Diagnostics.No_constituent_of_type_0_is_callable :
49171                         ts.Diagnostics.No_constituent_of_type_0_is_constructable, typeToString(apparentType));
49172                 }
49173                 if (!errorInfo) {
49174                     errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
49175                         ts.Diagnostics.Each_member_of_the_union_type_0_has_signatures_but_none_of_those_signatures_are_compatible_with_each_other :
49176                         ts.Diagnostics.Each_member_of_the_union_type_0_has_construct_signatures_but_none_of_those_signatures_are_compatible_with_each_other, typeToString(apparentType));
49177                 }
49178             }
49179             else {
49180                 errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
49181                     ts.Diagnostics.Type_0_has_no_call_signatures :
49182                     ts.Diagnostics.Type_0_has_no_construct_signatures, typeToString(apparentType));
49183             }
49184             return {
49185                 messageChain: ts.chainDiagnosticMessages(errorInfo, isCall ? ts.Diagnostics.This_expression_is_not_callable : ts.Diagnostics.This_expression_is_not_constructable),
49186                 relatedMessage: maybeMissingAwait ? ts.Diagnostics.Did_you_forget_to_use_await : undefined,
49187             };
49188         }
49189         function invocationError(errorTarget, apparentType, kind, relatedInformation) {
49190             var _a = invocationErrorDetails(apparentType, kind), messageChain = _a.messageChain, relatedInfo = _a.relatedMessage;
49191             var diagnostic = ts.createDiagnosticForNodeFromMessageChain(errorTarget, messageChain);
49192             if (relatedInfo) {
49193                 ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(errorTarget, relatedInfo));
49194             }
49195             if (ts.isCallExpression(errorTarget.parent)) {
49196                 var _b = getDiagnosticSpanForCallNode(errorTarget.parent, true), start = _b.start, length_7 = _b.length;
49197                 diagnostic.start = start;
49198                 diagnostic.length = length_7;
49199             }
49200             diagnostics.add(diagnostic);
49201             invocationErrorRecovery(apparentType, kind, relatedInformation ? ts.addRelatedInfo(diagnostic, relatedInformation) : diagnostic);
49202         }
49203         function invocationErrorRecovery(apparentType, kind, diagnostic) {
49204             if (!apparentType.symbol) {
49205                 return;
49206             }
49207             var importNode = getSymbolLinks(apparentType.symbol).originatingImport;
49208             if (importNode && !ts.isImportCall(importNode)) {
49209                 var sigs = getSignaturesOfType(getTypeOfSymbol(getSymbolLinks(apparentType.symbol).target), kind);
49210                 if (!sigs || !sigs.length)
49211                     return;
49212                 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));
49213             }
49214         }
49215         function resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode) {
49216             var tagType = checkExpression(node.tag);
49217             var apparentType = getApparentType(tagType);
49218             if (apparentType === errorType) {
49219                 return resolveErrorCall(node);
49220             }
49221             var callSignatures = getSignaturesOfType(apparentType, 0);
49222             var numConstructSignatures = getSignaturesOfType(apparentType, 1).length;
49223             if (isUntypedFunctionCall(tagType, apparentType, callSignatures.length, numConstructSignatures)) {
49224                 return resolveUntypedCall(node);
49225             }
49226             if (!callSignatures.length) {
49227                 invocationError(node.tag, apparentType, 0);
49228                 return resolveErrorCall(node);
49229             }
49230             return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0);
49231         }
49232         function getDiagnosticHeadMessageForDecoratorResolution(node) {
49233             switch (node.parent.kind) {
49234                 case 245:
49235                 case 214:
49236                     return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression;
49237                 case 156:
49238                     return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression;
49239                 case 159:
49240                     return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression;
49241                 case 161:
49242                 case 163:
49243                 case 164:
49244                     return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression;
49245                 default:
49246                     return ts.Debug.fail();
49247             }
49248         }
49249         function resolveDecorator(node, candidatesOutArray, checkMode) {
49250             var funcType = checkExpression(node.expression);
49251             var apparentType = getApparentType(funcType);
49252             if (apparentType === errorType) {
49253                 return resolveErrorCall(node);
49254             }
49255             var callSignatures = getSignaturesOfType(apparentType, 0);
49256             var numConstructSignatures = getSignaturesOfType(apparentType, 1).length;
49257             if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) {
49258                 return resolveUntypedCall(node);
49259             }
49260             if (isPotentiallyUncalledDecorator(node, callSignatures)) {
49261                 var nodeStr = ts.getTextOfNode(node.expression, false);
49262                 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);
49263                 return resolveErrorCall(node);
49264             }
49265             var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
49266             if (!callSignatures.length) {
49267                 var errorDetails = invocationErrorDetails(apparentType, 0);
49268                 var messageChain = ts.chainDiagnosticMessages(errorDetails.messageChain, headMessage);
49269                 var diag = ts.createDiagnosticForNodeFromMessageChain(node.expression, messageChain);
49270                 if (errorDetails.relatedMessage) {
49271                     ts.addRelatedInfo(diag, ts.createDiagnosticForNode(node.expression, errorDetails.relatedMessage));
49272                 }
49273                 diagnostics.add(diag);
49274                 invocationErrorRecovery(apparentType, 0, diag);
49275                 return resolveErrorCall(node);
49276             }
49277             return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0, headMessage);
49278         }
49279         function createSignatureForJSXIntrinsic(node, result) {
49280             var namespace = getJsxNamespaceAt(node);
49281             var exports = namespace && getExportsOfSymbol(namespace);
49282             var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968);
49283             var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968, node);
49284             var declaration = ts.createFunctionTypeNode(undefined, [ts.createParameter(undefined, undefined, undefined, "props", undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, undefined) : ts.createKeywordTypeNode(125));
49285             var parameterSymbol = createSymbol(1, "props");
49286             parameterSymbol.type = result;
49287             return createSignature(declaration, undefined, undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, undefined, 1, 0);
49288         }
49289         function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) {
49290             if (isJsxIntrinsicIdentifier(node.tagName)) {
49291                 var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node);
49292                 var fakeSignature = createSignatureForJSXIntrinsic(node, result);
49293                 checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), undefined, 0), result, node.tagName, node.attributes);
49294                 return fakeSignature;
49295             }
49296             var exprTypes = checkExpression(node.tagName);
49297             var apparentType = getApparentType(exprTypes);
49298             if (apparentType === errorType) {
49299                 return resolveErrorCall(node);
49300             }
49301             var signatures = getUninstantiatedJsxSignaturesOfType(exprTypes, node);
49302             if (isUntypedFunctionCall(exprTypes, apparentType, signatures.length, 0)) {
49303                 return resolveUntypedCall(node);
49304             }
49305             if (signatures.length === 0) {
49306                 error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName));
49307                 return resolveErrorCall(node);
49308             }
49309             return resolveCall(node, signatures, candidatesOutArray, checkMode, 0);
49310         }
49311         function isPotentiallyUncalledDecorator(decorator, signatures) {
49312             return signatures.length && ts.every(signatures, function (signature) {
49313                 return signature.minArgumentCount === 0 &&
49314                     !signatureHasRestParameter(signature) &&
49315                     signature.parameters.length < getDecoratorArgumentCount(decorator, signature);
49316             });
49317         }
49318         function resolveSignature(node, candidatesOutArray, checkMode) {
49319             switch (node.kind) {
49320                 case 196:
49321                     return resolveCallExpression(node, candidatesOutArray, checkMode);
49322                 case 197:
49323                     return resolveNewExpression(node, candidatesOutArray, checkMode);
49324                 case 198:
49325                     return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode);
49326                 case 157:
49327                     return resolveDecorator(node, candidatesOutArray, checkMode);
49328                 case 268:
49329                 case 267:
49330                     return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode);
49331             }
49332             throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable.");
49333         }
49334         function getResolvedSignature(node, candidatesOutArray, checkMode) {
49335             var links = getNodeLinks(node);
49336             var cached = links.resolvedSignature;
49337             if (cached && cached !== resolvingSignature && !candidatesOutArray) {
49338                 return cached;
49339             }
49340             links.resolvedSignature = resolvingSignature;
49341             var result = resolveSignature(node, candidatesOutArray, checkMode || 0);
49342             if (result !== resolvingSignature) {
49343                 links.resolvedSignature = flowLoopStart === flowLoopCount ? result : cached;
49344             }
49345             return result;
49346         }
49347         function isJSConstructor(node) {
49348             if (!node || !ts.isInJSFile(node)) {
49349                 return false;
49350             }
49351             var func = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) ? node :
49352                 ts.isVariableDeclaration(node) && node.initializer && ts.isFunctionExpression(node.initializer) ? node.initializer :
49353                     undefined;
49354             if (func) {
49355                 if (ts.getJSDocClassTag(node))
49356                     return true;
49357                 var symbol = getSymbolOfNode(func);
49358                 return !!symbol && ts.hasEntries(symbol.members);
49359             }
49360             return false;
49361         }
49362         function mergeJSSymbols(target, source) {
49363             if (source) {
49364                 var links = getSymbolLinks(source);
49365                 if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) {
49366                     var inferred = ts.isTransientSymbol(target) ? target : cloneSymbol(target);
49367                     inferred.exports = inferred.exports || ts.createSymbolTable();
49368                     inferred.members = inferred.members || ts.createSymbolTable();
49369                     inferred.flags |= source.flags & 32;
49370                     if (ts.hasEntries(source.exports)) {
49371                         mergeSymbolTable(inferred.exports, source.exports);
49372                     }
49373                     if (ts.hasEntries(source.members)) {
49374                         mergeSymbolTable(inferred.members, source.members);
49375                     }
49376                     (links.inferredClassSymbol || (links.inferredClassSymbol = ts.createMap())).set("" + getSymbolId(inferred), inferred);
49377                     return inferred;
49378                 }
49379                 return links.inferredClassSymbol.get("" + getSymbolId(target));
49380             }
49381         }
49382         function getAssignedClassSymbol(decl) {
49383             var assignmentSymbol = decl && decl.parent &&
49384                 (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) ||
49385                     ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) ||
49386                     ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent));
49387             var prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype");
49388             var init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration);
49389             return init ? getSymbolOfNode(init) : undefined;
49390         }
49391         function getAssignedJSPrototype(node) {
49392             if (!node.parent) {
49393                 return false;
49394             }
49395             var parent = node.parent;
49396             while (parent && parent.kind === 194) {
49397                 parent = parent.parent;
49398             }
49399             if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62) {
49400                 var right = ts.getInitializerOfBinaryExpression(parent);
49401                 return ts.isObjectLiteralExpression(right) && right;
49402             }
49403         }
49404         function checkCallExpression(node, checkMode) {
49405             if (!checkGrammarTypeArguments(node, node.typeArguments))
49406                 checkGrammarArguments(node.arguments);
49407             var signature = getResolvedSignature(node, undefined, checkMode);
49408             if (signature === resolvingSignature) {
49409                 return nonInferrableType;
49410             }
49411             if (node.expression.kind === 102) {
49412                 return voidType;
49413             }
49414             if (node.kind === 197) {
49415                 var declaration = signature.declaration;
49416                 if (declaration &&
49417                     declaration.kind !== 162 &&
49418                     declaration.kind !== 166 &&
49419                     declaration.kind !== 171 &&
49420                     !ts.isJSDocConstructSignature(declaration) &&
49421                     !isJSConstructor(declaration)) {
49422                     if (noImplicitAny) {
49423                         error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type);
49424                     }
49425                     return anyType;
49426                 }
49427             }
49428             if (ts.isInJSFile(node) && isCommonJsRequire(node)) {
49429                 return resolveExternalModuleTypeByLiteral(node.arguments[0]);
49430             }
49431             var returnType = getReturnTypeOfSignature(signature);
49432             if (returnType.flags & 12288 && isSymbolOrSymbolForCall(node)) {
49433                 return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent));
49434             }
49435             if (node.kind === 196 && node.parent.kind === 226 &&
49436                 returnType.flags & 16384 && getTypePredicateOfSignature(signature)) {
49437                 if (!ts.isDottedName(node.expression)) {
49438                     error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name);
49439                 }
49440                 else if (!getEffectsSignature(node)) {
49441                     var diagnostic = error(node.expression, ts.Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation);
49442                     getTypeOfDottedName(node.expression, diagnostic);
49443                 }
49444             }
49445             if (ts.isInJSFile(node)) {
49446                 var decl = ts.getDeclarationOfExpando(node);
49447                 if (decl) {
49448                     var jsSymbol = getSymbolOfNode(decl);
49449                     if (jsSymbol && ts.hasEntries(jsSymbol.exports)) {
49450                         var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined);
49451                         jsAssignmentType.objectFlags |= 16384;
49452                         return getIntersectionType([returnType, jsAssignmentType]);
49453                     }
49454                 }
49455             }
49456             return returnType;
49457         }
49458         function isSymbolOrSymbolForCall(node) {
49459             if (!ts.isCallExpression(node))
49460                 return false;
49461             var left = node.expression;
49462             if (ts.isPropertyAccessExpression(left) && left.name.escapedText === "for") {
49463                 left = left.expression;
49464             }
49465             if (!ts.isIdentifier(left) || left.escapedText !== "Symbol") {
49466                 return false;
49467             }
49468             var globalESSymbol = getGlobalESSymbolConstructorSymbol(false);
49469             if (!globalESSymbol) {
49470                 return false;
49471             }
49472             return globalESSymbol === resolveName(left, "Symbol", 111551, undefined, undefined, false);
49473         }
49474         function checkImportCallExpression(node) {
49475             if (!checkGrammarArguments(node.arguments))
49476                 checkGrammarImportCallExpression(node);
49477             if (node.arguments.length === 0) {
49478                 return createPromiseReturnType(node, anyType);
49479             }
49480             var specifier = node.arguments[0];
49481             var specifierType = checkExpressionCached(specifier);
49482             for (var i = 1; i < node.arguments.length; ++i) {
49483                 checkExpressionCached(node.arguments[i]);
49484             }
49485             if (specifierType.flags & 32768 || specifierType.flags & 65536 || !isTypeAssignableTo(specifierType, stringType)) {
49486                 error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType));
49487             }
49488             var moduleSymbol = resolveExternalModuleName(node, specifier);
49489             if (moduleSymbol) {
49490                 var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, true, false);
49491                 if (esModuleSymbol) {
49492                     return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol));
49493                 }
49494             }
49495             return createPromiseReturnType(node, anyType);
49496         }
49497         function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) {
49498             if (allowSyntheticDefaultImports && type && type !== errorType) {
49499                 var synthType = type;
49500                 if (!synthType.syntheticType) {
49501                     var file = ts.find(originalSymbol.declarations, ts.isSourceFile);
49502                     var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, false);
49503                     if (hasSyntheticDefault) {
49504                         var memberTable = ts.createSymbolTable();
49505                         var newSymbol = createSymbol(2097152, "default");
49506                         newSymbol.nameType = getLiteralType("default");
49507                         newSymbol.target = resolveSymbol(symbol);
49508                         memberTable.set("default", newSymbol);
49509                         var anonymousSymbol = createSymbol(2048, "__type");
49510                         var defaultContainingObject = createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, undefined, undefined);
49511                         anonymousSymbol.type = defaultContainingObject;
49512                         synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, 0, false) : defaultContainingObject;
49513                     }
49514                     else {
49515                         synthType.syntheticType = type;
49516                     }
49517                 }
49518                 return synthType.syntheticType;
49519             }
49520             return type;
49521         }
49522         function isCommonJsRequire(node) {
49523             if (!ts.isRequireCall(node, true)) {
49524                 return false;
49525             }
49526             if (!ts.isIdentifier(node.expression))
49527                 return ts.Debug.fail();
49528             var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551, undefined, undefined, true);
49529             if (resolvedRequire === requireSymbol) {
49530                 return true;
49531             }
49532             if (resolvedRequire.flags & 2097152) {
49533                 return false;
49534             }
49535             var targetDeclarationKind = resolvedRequire.flags & 16
49536                 ? 244
49537                 : resolvedRequire.flags & 3
49538                     ? 242
49539                     : 0;
49540             if (targetDeclarationKind !== 0) {
49541                 var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind);
49542                 return !!decl && !!(decl.flags & 8388608);
49543             }
49544             return false;
49545         }
49546         function checkTaggedTemplateExpression(node) {
49547             if (!checkGrammarTaggedTemplateChain(node))
49548                 checkGrammarTypeArguments(node, node.typeArguments);
49549             if (languageVersion < 2) {
49550                 checkExternalEmitHelpers(node, 131072);
49551             }
49552             return getReturnTypeOfSignature(getResolvedSignature(node));
49553         }
49554         function checkAssertion(node) {
49555             return checkAssertionWorker(node, node.type, node.expression);
49556         }
49557         function isValidConstAssertionArgument(node) {
49558             switch (node.kind) {
49559                 case 10:
49560                 case 14:
49561                 case 8:
49562                 case 9:
49563                 case 106:
49564                 case 91:
49565                 case 192:
49566                 case 193:
49567                     return true;
49568                 case 200:
49569                     return isValidConstAssertionArgument(node.expression);
49570                 case 207:
49571                     var op = node.operator;
49572                     var arg = node.operand;
49573                     return op === 40 && (arg.kind === 8 || arg.kind === 9) ||
49574                         op === 39 && arg.kind === 8;
49575                 case 194:
49576                 case 195:
49577                     var expr = node.expression;
49578                     if (ts.isIdentifier(expr)) {
49579                         var symbol = getSymbolAtLocation(expr);
49580                         if (symbol && symbol.flags & 2097152) {
49581                             symbol = resolveAlias(symbol);
49582                         }
49583                         return !!(symbol && (symbol.flags & 384) && getEnumKind(symbol) === 1);
49584                     }
49585             }
49586             return false;
49587         }
49588         function checkAssertionWorker(errNode, type, expression, checkMode) {
49589             var exprType = checkExpression(expression, checkMode);
49590             if (ts.isConstTypeReference(type)) {
49591                 if (!isValidConstAssertionArgument(expression)) {
49592                     error(expression, ts.Diagnostics.A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals);
49593                 }
49594                 return getRegularTypeOfLiteralType(exprType);
49595             }
49596             checkSourceElement(type);
49597             exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(exprType));
49598             var targetType = getTypeFromTypeNode(type);
49599             if (produceDiagnostics && targetType !== errorType) {
49600                 var widenedType = getWidenedType(exprType);
49601                 if (!isTypeComparableTo(targetType, widenedType)) {
49602                     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);
49603                 }
49604             }
49605             return targetType;
49606         }
49607         function checkNonNullChain(node) {
49608             var leftType = checkExpression(node.expression);
49609             var nonOptionalType = getOptionalExpressionType(leftType, node.expression);
49610             return propagateOptionalTypeMarker(getNonNullableType(nonOptionalType), node, nonOptionalType !== leftType);
49611         }
49612         function checkNonNullAssertion(node) {
49613             return node.flags & 32 ? checkNonNullChain(node) :
49614                 getNonNullableType(checkExpression(node.expression));
49615         }
49616         function checkMetaProperty(node) {
49617             checkGrammarMetaProperty(node);
49618             if (node.keywordToken === 99) {
49619                 return checkNewTargetMetaProperty(node);
49620             }
49621             if (node.keywordToken === 96) {
49622                 return checkImportMetaProperty(node);
49623             }
49624             return ts.Debug.assertNever(node.keywordToken);
49625         }
49626         function checkNewTargetMetaProperty(node) {
49627             var container = ts.getNewTargetContainer(node);
49628             if (!container) {
49629                 error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target");
49630                 return errorType;
49631             }
49632             else if (container.kind === 162) {
49633                 var symbol = getSymbolOfNode(container.parent);
49634                 return getTypeOfSymbol(symbol);
49635             }
49636             else {
49637                 var symbol = getSymbolOfNode(container);
49638                 return getTypeOfSymbol(symbol);
49639             }
49640         }
49641         function checkImportMetaProperty(node) {
49642             if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) {
49643                 error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system);
49644             }
49645             var file = ts.getSourceFileOfNode(node);
49646             ts.Debug.assert(!!(file.flags & 2097152), "Containing file is missing import meta node flag.");
49647             ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module.");
49648             return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType;
49649         }
49650         function getTypeOfParameter(symbol) {
49651             var type = getTypeOfSymbol(symbol);
49652             if (strictNullChecks) {
49653                 var declaration = symbol.valueDeclaration;
49654                 if (declaration && ts.hasInitializer(declaration)) {
49655                     return getOptionalType(type);
49656                 }
49657             }
49658             return type;
49659         }
49660         function getParameterNameAtPosition(signature, pos) {
49661             var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
49662             if (pos < paramCount) {
49663                 return signature.parameters[pos].escapedName;
49664             }
49665             var restParameter = signature.parameters[paramCount] || unknownSymbol;
49666             var restType = getTypeOfSymbol(restParameter);
49667             if (isTupleType(restType)) {
49668                 var associatedNames = restType.target.associatedNames;
49669                 var index = pos - paramCount;
49670                 return associatedNames && associatedNames[index] || restParameter.escapedName + "_" + index;
49671             }
49672             return restParameter.escapedName;
49673         }
49674         function getTypeAtPosition(signature, pos) {
49675             return tryGetTypeAtPosition(signature, pos) || anyType;
49676         }
49677         function tryGetTypeAtPosition(signature, pos) {
49678             var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
49679             if (pos < paramCount) {
49680                 return getTypeOfParameter(signature.parameters[pos]);
49681             }
49682             if (signatureHasRestParameter(signature)) {
49683                 var restType = getTypeOfSymbol(signature.parameters[paramCount]);
49684                 var index = pos - paramCount;
49685                 if (!isTupleType(restType) || restType.target.hasRestElement || index < getTypeArguments(restType).length) {
49686                     return getIndexedAccessType(restType, getLiteralType(index));
49687                 }
49688             }
49689             return undefined;
49690         }
49691         function getRestTypeAtPosition(source, pos) {
49692             var paramCount = getParameterCount(source);
49693             var restType = getEffectiveRestType(source);
49694             var nonRestCount = paramCount - (restType ? 1 : 0);
49695             if (restType && pos === nonRestCount) {
49696                 return restType;
49697             }
49698             var types = [];
49699             var names = [];
49700             for (var i = pos; i < nonRestCount; i++) {
49701                 types.push(getTypeAtPosition(source, i));
49702                 names.push(getParameterNameAtPosition(source, i));
49703             }
49704             if (restType) {
49705                 types.push(getIndexedAccessType(restType, numberType));
49706                 names.push(getParameterNameAtPosition(source, nonRestCount));
49707             }
49708             var minArgumentCount = getMinArgumentCount(source);
49709             var minLength = minArgumentCount < pos ? 0 : minArgumentCount - pos;
49710             return createTupleType(types, minLength, !!restType, false, names);
49711         }
49712         function getParameterCount(signature) {
49713             var length = signature.parameters.length;
49714             if (signatureHasRestParameter(signature)) {
49715                 var restType = getTypeOfSymbol(signature.parameters[length - 1]);
49716                 if (isTupleType(restType)) {
49717                     return length + getTypeArguments(restType).length - 1;
49718                 }
49719             }
49720             return length;
49721         }
49722         function getMinArgumentCount(signature, strongArityForUntypedJS) {
49723             if (signatureHasRestParameter(signature)) {
49724                 var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
49725                 if (isTupleType(restType)) {
49726                     var minLength = restType.target.minLength;
49727                     if (minLength > 0) {
49728                         return signature.parameters.length - 1 + minLength;
49729                     }
49730                 }
49731             }
49732             if (!strongArityForUntypedJS && signature.flags & 16) {
49733                 return 0;
49734             }
49735             return signature.minArgumentCount;
49736         }
49737         function hasEffectiveRestParameter(signature) {
49738             if (signatureHasRestParameter(signature)) {
49739                 var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
49740                 return !isTupleType(restType) || restType.target.hasRestElement;
49741             }
49742             return false;
49743         }
49744         function getEffectiveRestType(signature) {
49745             if (signatureHasRestParameter(signature)) {
49746                 var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
49747                 return isTupleType(restType) ? getRestArrayTypeOfTupleType(restType) : restType;
49748             }
49749             return undefined;
49750         }
49751         function getNonArrayRestType(signature) {
49752             var restType = getEffectiveRestType(signature);
49753             return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072) === 0 ? restType : undefined;
49754         }
49755         function getTypeOfFirstParameterOfSignature(signature) {
49756             return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType);
49757         }
49758         function getTypeOfFirstParameterOfSignatureWithFallback(signature, fallbackType) {
49759             return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : fallbackType;
49760         }
49761         function inferFromAnnotatedParameters(signature, context, inferenceContext) {
49762             var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
49763             for (var i = 0; i < len; i++) {
49764                 var declaration = signature.parameters[i].valueDeclaration;
49765                 if (declaration.type) {
49766                     var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
49767                     if (typeNode) {
49768                         inferTypes(inferenceContext.inferences, getTypeFromTypeNode(typeNode), getTypeAtPosition(context, i));
49769                     }
49770                 }
49771             }
49772             var restType = getEffectiveRestType(context);
49773             if (restType && restType.flags & 262144) {
49774                 var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper);
49775                 assignContextualParameterTypes(signature, instantiatedContext);
49776                 var restPos = getParameterCount(context) - 1;
49777                 inferTypes(inferenceContext.inferences, getRestTypeAtPosition(signature, restPos), restType);
49778             }
49779         }
49780         function assignContextualParameterTypes(signature, context) {
49781             signature.typeParameters = context.typeParameters;
49782             if (context.thisParameter) {
49783                 var parameter = signature.thisParameter;
49784                 if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) {
49785                     if (!parameter) {
49786                         signature.thisParameter = createSymbolWithType(context.thisParameter, undefined);
49787                     }
49788                     assignParameterType(signature.thisParameter, getTypeOfSymbol(context.thisParameter));
49789                 }
49790             }
49791             var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
49792             for (var i = 0; i < len; i++) {
49793                 var parameter = signature.parameters[i];
49794                 if (!ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) {
49795                     var contextualParameterType = tryGetTypeAtPosition(context, i);
49796                     assignParameterType(parameter, contextualParameterType);
49797                 }
49798             }
49799             if (signatureHasRestParameter(signature)) {
49800                 var parameter = ts.last(signature.parameters);
49801                 if (ts.isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) {
49802                     var contextualParameterType = getRestTypeAtPosition(context, len);
49803                     assignParameterType(parameter, contextualParameterType);
49804                 }
49805             }
49806         }
49807         function assignNonContextualParameterTypes(signature) {
49808             if (signature.thisParameter) {
49809                 assignParameterType(signature.thisParameter);
49810             }
49811             for (var _i = 0, _a = signature.parameters; _i < _a.length; _i++) {
49812                 var parameter = _a[_i];
49813                 assignParameterType(parameter);
49814             }
49815         }
49816         function assignParameterType(parameter, type) {
49817             var links = getSymbolLinks(parameter);
49818             if (!links.type) {
49819                 var declaration = parameter.valueDeclaration;
49820                 links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, true);
49821                 if (declaration.name.kind !== 75) {
49822                     if (links.type === unknownType) {
49823                         links.type = getTypeFromBindingPattern(declaration.name);
49824                     }
49825                     assignBindingElementTypes(declaration.name);
49826                 }
49827             }
49828         }
49829         function assignBindingElementTypes(pattern) {
49830             for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
49831                 var element = _a[_i];
49832                 if (!ts.isOmittedExpression(element)) {
49833                     if (element.name.kind === 75) {
49834                         getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element);
49835                     }
49836                     else {
49837                         assignBindingElementTypes(element.name);
49838                     }
49839                 }
49840             }
49841         }
49842         function createPromiseType(promisedType) {
49843             var globalPromiseType = getGlobalPromiseType(true);
49844             if (globalPromiseType !== emptyGenericType) {
49845                 promisedType = getAwaitedType(promisedType) || unknownType;
49846                 return createTypeReference(globalPromiseType, [promisedType]);
49847             }
49848             return unknownType;
49849         }
49850         function createPromiseLikeType(promisedType) {
49851             var globalPromiseLikeType = getGlobalPromiseLikeType(true);
49852             if (globalPromiseLikeType !== emptyGenericType) {
49853                 promisedType = getAwaitedType(promisedType) || unknownType;
49854                 return createTypeReference(globalPromiseLikeType, [promisedType]);
49855             }
49856             return unknownType;
49857         }
49858         function createPromiseReturnType(func, promisedType) {
49859             var promiseType = createPromiseType(promisedType);
49860             if (promiseType === unknownType) {
49861                 error(func, ts.isImportCall(func) ?
49862                     ts.Diagnostics.A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option :
49863                     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);
49864                 return errorType;
49865             }
49866             else if (!getGlobalPromiseConstructorSymbol(true)) {
49867                 error(func, ts.isImportCall(func) ?
49868                     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 :
49869                     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);
49870             }
49871             return promiseType;
49872         }
49873         function getReturnTypeFromBody(func, checkMode) {
49874             if (!func.body) {
49875                 return errorType;
49876             }
49877             var functionFlags = ts.getFunctionFlags(func);
49878             var isAsync = (functionFlags & 2) !== 0;
49879             var isGenerator = (functionFlags & 1) !== 0;
49880             var returnType;
49881             var yieldType;
49882             var nextType;
49883             var fallbackReturnType = voidType;
49884             if (func.body.kind !== 223) {
49885                 returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8);
49886                 if (isAsync) {
49887                     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);
49888                 }
49889             }
49890             else if (isGenerator) {
49891                 var returnTypes = checkAndAggregateReturnExpressionTypes(func, checkMode);
49892                 if (!returnTypes) {
49893                     fallbackReturnType = neverType;
49894                 }
49895                 else if (returnTypes.length > 0) {
49896                     returnType = getUnionType(returnTypes, 2);
49897                 }
49898                 var _a = checkAndAggregateYieldOperandTypes(func, checkMode), yieldTypes = _a.yieldTypes, nextTypes = _a.nextTypes;
49899                 yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2) : undefined;
49900                 nextType = ts.some(nextTypes) ? getIntersectionType(nextTypes) : undefined;
49901             }
49902             else {
49903                 var types = checkAndAggregateReturnExpressionTypes(func, checkMode);
49904                 if (!types) {
49905                     return functionFlags & 2
49906                         ? createPromiseReturnType(func, neverType)
49907                         : neverType;
49908                 }
49909                 if (types.length === 0) {
49910                     return functionFlags & 2
49911                         ? createPromiseReturnType(func, voidType)
49912                         : voidType;
49913                 }
49914                 returnType = getUnionType(types, 2);
49915             }
49916             if (returnType || yieldType || nextType) {
49917                 if (yieldType)
49918                     reportErrorsFromWidening(func, yieldType, 3);
49919                 if (returnType)
49920                     reportErrorsFromWidening(func, returnType, 1);
49921                 if (nextType)
49922                     reportErrorsFromWidening(func, nextType, 2);
49923                 if (returnType && isUnitType(returnType) ||
49924                     yieldType && isUnitType(yieldType) ||
49925                     nextType && isUnitType(nextType)) {
49926                     var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
49927                     var contextualType = !contextualSignature ? undefined :
49928                         contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType :
49929                             instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func);
49930                     if (isGenerator) {
49931                         yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0, isAsync);
49932                         returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1, isAsync);
49933                         nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2, isAsync);
49934                     }
49935                     else {
49936                         returnType = getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(returnType, contextualType, isAsync);
49937                     }
49938                 }
49939                 if (yieldType)
49940                     yieldType = getWidenedType(yieldType);
49941                 if (returnType)
49942                     returnType = getWidenedType(returnType);
49943                 if (nextType)
49944                     nextType = getWidenedType(nextType);
49945             }
49946             if (isGenerator) {
49947                 return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2, func) || unknownType, isAsync);
49948             }
49949             else {
49950                 return isAsync
49951                     ? createPromiseType(returnType || fallbackReturnType)
49952                     : returnType || fallbackReturnType;
49953             }
49954         }
49955         function createGeneratorReturnType(yieldType, returnType, nextType, isAsyncGenerator) {
49956             var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
49957             var globalGeneratorType = resolver.getGlobalGeneratorType(false);
49958             yieldType = resolver.resolveIterationType(yieldType, undefined) || unknownType;
49959             returnType = resolver.resolveIterationType(returnType, undefined) || unknownType;
49960             nextType = resolver.resolveIterationType(nextType, undefined) || unknownType;
49961             if (globalGeneratorType === emptyGenericType) {
49962                 var globalType = resolver.getGlobalIterableIteratorType(false);
49963                 var iterationTypes = globalType !== emptyGenericType ? getIterationTypesOfGlobalIterableType(globalType, resolver) : undefined;
49964                 var iterableIteratorReturnType = iterationTypes ? iterationTypes.returnType : anyType;
49965                 var iterableIteratorNextType = iterationTypes ? iterationTypes.nextType : undefinedType;
49966                 if (isTypeAssignableTo(returnType, iterableIteratorReturnType) &&
49967                     isTypeAssignableTo(iterableIteratorNextType, nextType)) {
49968                     if (globalType !== emptyGenericType) {
49969                         return createTypeFromGenericGlobalType(globalType, [yieldType]);
49970                     }
49971                     resolver.getGlobalIterableIteratorType(true);
49972                     return emptyObjectType;
49973                 }
49974                 resolver.getGlobalGeneratorType(true);
49975                 return emptyObjectType;
49976             }
49977             return createTypeFromGenericGlobalType(globalGeneratorType, [yieldType, returnType, nextType]);
49978         }
49979         function checkAndAggregateYieldOperandTypes(func, checkMode) {
49980             var yieldTypes = [];
49981             var nextTypes = [];
49982             var isAsync = (ts.getFunctionFlags(func) & 2) !== 0;
49983             ts.forEachYieldExpression(func.body, function (yieldExpression) {
49984                 var yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType;
49985                 ts.pushIfUnique(yieldTypes, getYieldedTypeOfYieldExpression(yieldExpression, yieldExpressionType, anyType, isAsync));
49986                 var nextType;
49987                 if (yieldExpression.asteriskToken) {
49988                     var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 : 17, yieldExpression.expression);
49989                     nextType = iterationTypes && iterationTypes.nextType;
49990                 }
49991                 else {
49992                     nextType = getContextualType(yieldExpression);
49993                 }
49994                 if (nextType)
49995                     ts.pushIfUnique(nextTypes, nextType);
49996             });
49997             return { yieldTypes: yieldTypes, nextTypes: nextTypes };
49998         }
49999         function getYieldedTypeOfYieldExpression(node, expressionType, sentType, isAsync) {
50000             var errorNode = node.expression || node;
50001             var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 : 17, expressionType, sentType, errorNode) : expressionType;
50002             return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken
50003                 ? 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
50004                 : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
50005         }
50006         function getFactsFromTypeofSwitch(start, end, witnesses, hasDefault) {
50007             var facts = 0;
50008             if (hasDefault) {
50009                 for (var i = end; i < witnesses.length; i++) {
50010                     facts |= typeofNEFacts.get(witnesses[i]) || 32768;
50011                 }
50012                 for (var i = start; i < end; i++) {
50013                     facts &= ~(typeofNEFacts.get(witnesses[i]) || 0);
50014                 }
50015                 for (var i = 0; i < start; i++) {
50016                     facts |= typeofNEFacts.get(witnesses[i]) || 32768;
50017                 }
50018             }
50019             else {
50020                 for (var i = start; i < end; i++) {
50021                     facts |= typeofEQFacts.get(witnesses[i]) || 128;
50022                 }
50023                 for (var i = 0; i < start; i++) {
50024                     facts &= ~(typeofEQFacts.get(witnesses[i]) || 0);
50025                 }
50026             }
50027             return facts;
50028         }
50029         function isExhaustiveSwitchStatement(node) {
50030             var links = getNodeLinks(node);
50031             return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node));
50032         }
50033         function computeExhaustiveSwitchStatement(node) {
50034             if (node.expression.kind === 204) {
50035                 var operandType = getTypeOfExpression(node.expression.expression);
50036                 var witnesses = getSwitchClauseTypeOfWitnesses(node, false);
50037                 var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, true);
50038                 var type_3 = getBaseConstraintOfType(operandType) || operandType;
50039                 return !!(filterType(type_3, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072);
50040             }
50041             var type = getTypeOfExpression(node.expression);
50042             if (!isLiteralType(type)) {
50043                 return false;
50044             }
50045             var switchTypes = getSwitchClauseTypes(node);
50046             if (!switchTypes.length || ts.some(switchTypes, isNeitherUnitTypeNorNever)) {
50047                 return false;
50048             }
50049             return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralType), switchTypes);
50050         }
50051         function functionHasImplicitReturn(func) {
50052             return func.endFlowNode && isReachableFlowNode(func.endFlowNode);
50053         }
50054         function checkAndAggregateReturnExpressionTypes(func, checkMode) {
50055             var functionFlags = ts.getFunctionFlags(func);
50056             var aggregatedTypes = [];
50057             var hasReturnWithNoExpression = functionHasImplicitReturn(func);
50058             var hasReturnOfTypeNever = false;
50059             ts.forEachReturnStatement(func.body, function (returnStatement) {
50060                 var expr = returnStatement.expression;
50061                 if (expr) {
50062                     var type = checkExpressionCached(expr, checkMode && checkMode & ~8);
50063                     if (functionFlags & 2) {
50064                         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);
50065                     }
50066                     if (type.flags & 131072) {
50067                         hasReturnOfTypeNever = true;
50068                     }
50069                     ts.pushIfUnique(aggregatedTypes, type);
50070                 }
50071                 else {
50072                     hasReturnWithNoExpression = true;
50073                 }
50074             });
50075             if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || mayReturnNever(func))) {
50076                 return undefined;
50077             }
50078             if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression &&
50079                 !(isJSConstructor(func) && aggregatedTypes.some(function (t) { return t.symbol === func.symbol; }))) {
50080                 ts.pushIfUnique(aggregatedTypes, undefinedType);
50081             }
50082             return aggregatedTypes;
50083         }
50084         function mayReturnNever(func) {
50085             switch (func.kind) {
50086                 case 201:
50087                 case 202:
50088                     return true;
50089                 case 161:
50090                     return func.parent.kind === 193;
50091                 default:
50092                     return false;
50093             }
50094         }
50095         function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
50096             if (!produceDiagnostics) {
50097                 return;
50098             }
50099             var functionFlags = ts.getFunctionFlags(func);
50100             var type = returnType && unwrapReturnType(returnType, functionFlags);
50101             if (type && maybeTypeOfKind(type, 1 | 16384)) {
50102                 return;
50103             }
50104             if (func.kind === 160 || ts.nodeIsMissing(func.body) || func.body.kind !== 223 || !functionHasImplicitReturn(func)) {
50105                 return;
50106             }
50107             var hasExplicitReturn = func.flags & 512;
50108             if (type && type.flags & 131072) {
50109                 error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
50110             }
50111             else if (type && !hasExplicitReturn) {
50112                 error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
50113             }
50114             else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
50115                 error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
50116             }
50117             else if (compilerOptions.noImplicitReturns) {
50118                 if (!type) {
50119                     if (!hasExplicitReturn) {
50120                         return;
50121                     }
50122                     var inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
50123                     if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
50124                         return;
50125                     }
50126                 }
50127                 error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Not_all_code_paths_return_a_value);
50128             }
50129         }
50130         function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) {
50131             ts.Debug.assert(node.kind !== 161 || ts.isObjectLiteralMethod(node));
50132             checkNodeDeferred(node);
50133             if (checkMode && checkMode & 4 && isContextSensitive(node)) {
50134                 if (!ts.getEffectiveReturnTypeNode(node) && !hasContextSensitiveParameters(node)) {
50135                     var contextualSignature = getContextualSignature(node);
50136                     if (contextualSignature && couldContainTypeVariables(getReturnTypeOfSignature(contextualSignature))) {
50137                         var links = getNodeLinks(node);
50138                         if (links.contextFreeType) {
50139                             return links.contextFreeType;
50140                         }
50141                         var returnType = getReturnTypeFromBody(node, checkMode);
50142                         var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, undefined, 0, 0);
50143                         var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, undefined, undefined);
50144                         returnOnlyType.objectFlags |= 2097152;
50145                         return links.contextFreeType = returnOnlyType;
50146                     }
50147                 }
50148                 return anyFunctionType;
50149             }
50150             var hasGrammarError = checkGrammarFunctionLikeDeclaration(node);
50151             if (!hasGrammarError && node.kind === 201) {
50152                 checkGrammarForGenerator(node);
50153             }
50154             contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode);
50155             return getTypeOfSymbol(getSymbolOfNode(node));
50156         }
50157         function contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode) {
50158             var links = getNodeLinks(node);
50159             if (!(links.flags & 1024)) {
50160                 var contextualSignature = getContextualSignature(node);
50161                 if (!(links.flags & 1024)) {
50162                     links.flags |= 1024;
50163                     var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0));
50164                     if (!signature) {
50165                         return;
50166                     }
50167                     if (isContextSensitive(node)) {
50168                         if (contextualSignature) {
50169                             var inferenceContext = getInferenceContext(node);
50170                             if (checkMode && checkMode & 2) {
50171                                 inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
50172                             }
50173                             var instantiatedContextualSignature = inferenceContext ?
50174                                 instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature;
50175                             assignContextualParameterTypes(signature, instantiatedContextualSignature);
50176                         }
50177                         else {
50178                             assignNonContextualParameterTypes(signature);
50179                         }
50180                     }
50181                     if (contextualSignature && !getReturnTypeFromAnnotation(node) && !signature.resolvedReturnType) {
50182                         var returnType = getReturnTypeFromBody(node, checkMode);
50183                         if (!signature.resolvedReturnType) {
50184                             signature.resolvedReturnType = returnType;
50185                         }
50186                     }
50187                     checkSignatureDeclaration(node);
50188                 }
50189             }
50190         }
50191         function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) {
50192             ts.Debug.assert(node.kind !== 161 || ts.isObjectLiteralMethod(node));
50193             var functionFlags = ts.getFunctionFlags(node);
50194             var returnType = getReturnTypeFromAnnotation(node);
50195             checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType);
50196             if (node.body) {
50197                 if (!ts.getEffectiveReturnTypeNode(node)) {
50198                     getReturnTypeOfSignature(getSignatureFromDeclaration(node));
50199                 }
50200                 if (node.body.kind === 223) {
50201                     checkSourceElement(node.body);
50202                 }
50203                 else {
50204                     var exprType = checkExpression(node.body);
50205                     var returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags);
50206                     if (returnOrPromisedType) {
50207                         if ((functionFlags & 3) === 2) {
50208                             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);
50209                             checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body);
50210                         }
50211                         else {
50212                             checkTypeAssignableToAndOptionallyElaborate(exprType, returnOrPromisedType, node.body, node.body);
50213                         }
50214                     }
50215                 }
50216             }
50217         }
50218         function checkArithmeticOperandType(operand, type, diagnostic, isAwaitValid) {
50219             if (isAwaitValid === void 0) { isAwaitValid = false; }
50220             if (!isTypeAssignableTo(type, numberOrBigIntType)) {
50221                 var awaitedType = isAwaitValid && getAwaitedTypeOfPromise(type);
50222                 errorAndMaybeSuggestAwait(operand, !!awaitedType && isTypeAssignableTo(awaitedType, numberOrBigIntType), diagnostic);
50223                 return false;
50224             }
50225             return true;
50226         }
50227         function isReadonlyAssignmentDeclaration(d) {
50228             if (!ts.isCallExpression(d)) {
50229                 return false;
50230             }
50231             if (!ts.isBindableObjectDefinePropertyCall(d)) {
50232                 return false;
50233             }
50234             var objectLitType = checkExpressionCached(d.arguments[2]);
50235             var valueType = getTypeOfPropertyOfType(objectLitType, "value");
50236             if (valueType) {
50237                 var writableProp = getPropertyOfType(objectLitType, "writable");
50238                 var writableType = writableProp && getTypeOfSymbol(writableProp);
50239                 if (!writableType || writableType === falseType || writableType === regularFalseType) {
50240                     return true;
50241                 }
50242                 if (writableProp && writableProp.valueDeclaration && ts.isPropertyAssignment(writableProp.valueDeclaration)) {
50243                     var initializer = writableProp.valueDeclaration.initializer;
50244                     var rawOriginalType = checkExpression(initializer);
50245                     if (rawOriginalType === falseType || rawOriginalType === regularFalseType) {
50246                         return true;
50247                     }
50248                 }
50249                 return false;
50250             }
50251             var setProp = getPropertyOfType(objectLitType, "set");
50252             return !setProp;
50253         }
50254         function isReadonlySymbol(symbol) {
50255             return !!(ts.getCheckFlags(symbol) & 8 ||
50256                 symbol.flags & 4 && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 ||
50257                 symbol.flags & 3 && getDeclarationNodeFlagsFromSymbol(symbol) & 2 ||
50258                 symbol.flags & 98304 && !(symbol.flags & 65536) ||
50259                 symbol.flags & 8 ||
50260                 ts.some(symbol.declarations, isReadonlyAssignmentDeclaration));
50261         }
50262         function isAssignmentToReadonlyEntity(expr, symbol, assignmentKind) {
50263             var _a, _b;
50264             if (assignmentKind === 0) {
50265                 return false;
50266             }
50267             if (isReadonlySymbol(symbol)) {
50268                 if (symbol.flags & 4 &&
50269                     ts.isAccessExpression(expr) &&
50270                     expr.expression.kind === 104) {
50271                     var ctor = ts.getContainingFunction(expr);
50272                     if (!(ctor && ctor.kind === 162)) {
50273                         return true;
50274                     }
50275                     if (symbol.valueDeclaration) {
50276                         var isAssignmentDeclaration_1 = ts.isBinaryExpression(symbol.valueDeclaration);
50277                         var isLocalPropertyDeclaration = ctor.parent === symbol.valueDeclaration.parent;
50278                         var isLocalParameterProperty = ctor === symbol.valueDeclaration.parent;
50279                         var isLocalThisPropertyAssignment = isAssignmentDeclaration_1 && ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) === ctor.parent;
50280                         var isLocalThisPropertyAssignmentConstructorFunction = isAssignmentDeclaration_1 && ((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration) === ctor;
50281                         var isWriteableSymbol = isLocalPropertyDeclaration
50282                             || isLocalParameterProperty
50283                             || isLocalThisPropertyAssignment
50284                             || isLocalThisPropertyAssignmentConstructorFunction;
50285                         return !isWriteableSymbol;
50286                     }
50287                 }
50288                 return true;
50289             }
50290             if (ts.isAccessExpression(expr)) {
50291                 var node = ts.skipParentheses(expr.expression);
50292                 if (node.kind === 75) {
50293                     var symbol_2 = getNodeLinks(node).resolvedSymbol;
50294                     if (symbol_2.flags & 2097152) {
50295                         var declaration = getDeclarationOfAliasSymbol(symbol_2);
50296                         return !!declaration && declaration.kind === 256;
50297                     }
50298                 }
50299             }
50300             return false;
50301         }
50302         function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) {
50303             var node = ts.skipOuterExpressions(expr, 6 | 1);
50304             if (node.kind !== 75 && !ts.isAccessExpression(node)) {
50305                 error(expr, invalidReferenceMessage);
50306                 return false;
50307             }
50308             if (node.flags & 32) {
50309                 error(expr, invalidOptionalChainMessage);
50310                 return false;
50311             }
50312             return true;
50313         }
50314         function checkDeleteExpression(node) {
50315             checkExpression(node.expression);
50316             var expr = ts.skipParentheses(node.expression);
50317             if (!ts.isAccessExpression(expr)) {
50318                 error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference);
50319                 return booleanType;
50320             }
50321             if (expr.kind === 194 && ts.isPrivateIdentifier(expr.name)) {
50322                 error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_private_identifier);
50323             }
50324             var links = getNodeLinks(expr);
50325             var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol);
50326             if (symbol && isReadonlySymbol(symbol)) {
50327                 error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property);
50328             }
50329             return booleanType;
50330         }
50331         function checkTypeOfExpression(node) {
50332             checkExpression(node.expression);
50333             return typeofType;
50334         }
50335         function checkVoidExpression(node) {
50336             checkExpression(node.expression);
50337             return undefinedWideningType;
50338         }
50339         function isTopLevelAwait(node) {
50340             var container = ts.getThisContainer(node, true);
50341             return ts.isSourceFile(container);
50342         }
50343         function checkAwaitExpression(node) {
50344             if (produceDiagnostics) {
50345                 if (!(node.flags & 32768)) {
50346                     if (isTopLevelAwait(node)) {
50347                         var sourceFile = ts.getSourceFileOfNode(node);
50348                         if (!hasParseDiagnostics(sourceFile)) {
50349                             var span = void 0;
50350                             if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
50351                                 if (!span)
50352                                     span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
50353                                 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);
50354                                 diagnostics.add(diagnostic);
50355                             }
50356                             if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4) {
50357                                 span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
50358                                 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);
50359                                 diagnostics.add(diagnostic);
50360                             }
50361                         }
50362                     }
50363                     else {
50364                         var sourceFile = ts.getSourceFileOfNode(node);
50365                         if (!hasParseDiagnostics(sourceFile)) {
50366                             var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
50367                             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);
50368                             var func = ts.getContainingFunction(node);
50369                             if (func && func.kind !== 162 && (ts.getFunctionFlags(func) & 2) === 0) {
50370                                 var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
50371                                 ts.addRelatedInfo(diagnostic, relatedInfo);
50372                             }
50373                             diagnostics.add(diagnostic);
50374                         }
50375                     }
50376                 }
50377                 if (isInParameterInitializerBeforeContainingFunction(node)) {
50378                     error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer);
50379                 }
50380             }
50381             var operandType = checkExpression(node.expression);
50382             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);
50383             if (awaitedType === operandType && awaitedType !== errorType && !(operandType.flags & 3)) {
50384                 addErrorOrSuggestion(false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression));
50385             }
50386             return awaitedType;
50387         }
50388         function checkPrefixUnaryExpression(node) {
50389             var operandType = checkExpression(node.operand);
50390             if (operandType === silentNeverType) {
50391                 return silentNeverType;
50392             }
50393             switch (node.operand.kind) {
50394                 case 8:
50395                     switch (node.operator) {
50396                         case 40:
50397                             return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text));
50398                         case 39:
50399                             return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text));
50400                     }
50401                     break;
50402                 case 9:
50403                     if (node.operator === 40) {
50404                         return getFreshTypeOfLiteralType(getLiteralType({
50405                             negative: true,
50406                             base10Value: ts.parsePseudoBigInt(node.operand.text)
50407                         }));
50408                     }
50409             }
50410             switch (node.operator) {
50411                 case 39:
50412                 case 40:
50413                 case 54:
50414                     checkNonNullType(operandType, node.operand);
50415                     if (maybeTypeOfKind(operandType, 12288)) {
50416                         error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator));
50417                     }
50418                     if (node.operator === 39) {
50419                         if (maybeTypeOfKind(operandType, 2112)) {
50420                             error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType)));
50421                         }
50422                         return numberType;
50423                     }
50424                     return getUnaryResultType(operandType);
50425                 case 53:
50426                     checkTruthinessExpression(node.operand);
50427                     var facts = getTypeFacts(operandType) & (4194304 | 8388608);
50428                     return facts === 4194304 ? falseType :
50429                         facts === 8388608 ? trueType :
50430                             booleanType;
50431                 case 45:
50432                 case 46:
50433                     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);
50434                     if (ok) {
50435                         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);
50436                     }
50437                     return getUnaryResultType(operandType);
50438             }
50439             return errorType;
50440         }
50441         function checkPostfixUnaryExpression(node) {
50442             var operandType = checkExpression(node.operand);
50443             if (operandType === silentNeverType) {
50444                 return silentNeverType;
50445             }
50446             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);
50447             if (ok) {
50448                 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);
50449             }
50450             return getUnaryResultType(operandType);
50451         }
50452         function getUnaryResultType(operandType) {
50453             if (maybeTypeOfKind(operandType, 2112)) {
50454                 return isTypeAssignableToKind(operandType, 3) || maybeTypeOfKind(operandType, 296)
50455                     ? numberOrBigIntType
50456                     : bigintType;
50457             }
50458             return numberType;
50459         }
50460         function maybeTypeOfKind(type, kind) {
50461             if (type.flags & kind) {
50462                 return true;
50463             }
50464             if (type.flags & 3145728) {
50465                 var types = type.types;
50466                 for (var _i = 0, types_19 = types; _i < types_19.length; _i++) {
50467                     var t = types_19[_i];
50468                     if (maybeTypeOfKind(t, kind)) {
50469                         return true;
50470                     }
50471                 }
50472             }
50473             return false;
50474         }
50475         function isTypeAssignableToKind(source, kind, strict) {
50476             if (source.flags & kind) {
50477                 return true;
50478             }
50479             if (strict && source.flags & (3 | 16384 | 32768 | 65536)) {
50480                 return false;
50481             }
50482             return !!(kind & 296) && isTypeAssignableTo(source, numberType) ||
50483                 !!(kind & 2112) && isTypeAssignableTo(source, bigintType) ||
50484                 !!(kind & 132) && isTypeAssignableTo(source, stringType) ||
50485                 !!(kind & 528) && isTypeAssignableTo(source, booleanType) ||
50486                 !!(kind & 16384) && isTypeAssignableTo(source, voidType) ||
50487                 !!(kind & 131072) && isTypeAssignableTo(source, neverType) ||
50488                 !!(kind & 65536) && isTypeAssignableTo(source, nullType) ||
50489                 !!(kind & 32768) && isTypeAssignableTo(source, undefinedType) ||
50490                 !!(kind & 4096) && isTypeAssignableTo(source, esSymbolType) ||
50491                 !!(kind & 67108864) && isTypeAssignableTo(source, nonPrimitiveType);
50492         }
50493         function allTypesAssignableToKind(source, kind, strict) {
50494             return source.flags & 1048576 ?
50495                 ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) :
50496                 isTypeAssignableToKind(source, kind, strict);
50497         }
50498         function isConstEnumObjectType(type) {
50499             return !!(ts.getObjectFlags(type) & 16) && !!type.symbol && isConstEnumSymbol(type.symbol);
50500         }
50501         function isConstEnumSymbol(symbol) {
50502             return (symbol.flags & 128) !== 0;
50503         }
50504         function checkInstanceOfExpression(left, right, leftType, rightType) {
50505             if (leftType === silentNeverType || rightType === silentNeverType) {
50506                 return silentNeverType;
50507             }
50508             if (!isTypeAny(leftType) &&
50509                 allTypesAssignableToKind(leftType, 131068)) {
50510                 error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
50511             }
50512             if (!(isTypeAny(rightType) || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
50513                 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);
50514             }
50515             return booleanType;
50516         }
50517         function checkInExpression(left, right, leftType, rightType) {
50518             if (leftType === silentNeverType || rightType === silentNeverType) {
50519                 return silentNeverType;
50520             }
50521             leftType = checkNonNullType(leftType, left);
50522             rightType = checkNonNullType(rightType, right);
50523             if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 296 | 12288))) {
50524                 error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
50525             }
50526             if (!allTypesAssignableToKind(rightType, 67108864 | 58982400)) {
50527                 error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
50528             }
50529             return booleanType;
50530         }
50531         function checkObjectLiteralAssignment(node, sourceType, rightIsThis) {
50532             var properties = node.properties;
50533             if (strictNullChecks && properties.length === 0) {
50534                 return checkNonNullType(sourceType, node);
50535             }
50536             for (var i = 0; i < properties.length; i++) {
50537                 checkObjectLiteralDestructuringPropertyAssignment(node, sourceType, i, properties, rightIsThis);
50538             }
50539             return sourceType;
50540         }
50541         function checkObjectLiteralDestructuringPropertyAssignment(node, objectLiteralType, propertyIndex, allProperties, rightIsThis) {
50542             if (rightIsThis === void 0) { rightIsThis = false; }
50543             var properties = node.properties;
50544             var property = properties[propertyIndex];
50545             if (property.kind === 281 || property.kind === 282) {
50546                 var name = property.name;
50547                 var exprType = getLiteralTypeFromPropertyName(name);
50548                 if (isTypeUsableAsPropertyName(exprType)) {
50549                     var text = getPropertyNameFromType(exprType);
50550                     var prop = getPropertyOfType(objectLiteralType, text);
50551                     if (prop) {
50552                         markPropertyAsReferenced(prop, property, rightIsThis);
50553                         checkPropertyAccessibility(property, false, objectLiteralType, prop);
50554                     }
50555                 }
50556                 var elementType = getIndexedAccessType(objectLiteralType, exprType, name);
50557                 var type = getFlowTypeOfDestructuring(property, elementType);
50558                 return checkDestructuringAssignment(property.kind === 282 ? property : property.initializer, type);
50559             }
50560             else if (property.kind === 283) {
50561                 if (propertyIndex < properties.length - 1) {
50562                     error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
50563                 }
50564                 else {
50565                     if (languageVersion < 99) {
50566                         checkExternalEmitHelpers(property, 4);
50567                     }
50568                     var nonRestNames = [];
50569                     if (allProperties) {
50570                         for (var _i = 0, allProperties_1 = allProperties; _i < allProperties_1.length; _i++) {
50571                             var otherProperty = allProperties_1[_i];
50572                             if (!ts.isSpreadAssignment(otherProperty)) {
50573                                 nonRestNames.push(otherProperty.name);
50574                             }
50575                         }
50576                     }
50577                     var type = getRestType(objectLiteralType, nonRestNames, objectLiteralType.symbol);
50578                     checkGrammarForDisallowedTrailingComma(allProperties, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
50579                     return checkDestructuringAssignment(property.expression, type);
50580                 }
50581             }
50582             else {
50583                 error(property, ts.Diagnostics.Property_assignment_expected);
50584             }
50585         }
50586         function checkArrayLiteralAssignment(node, sourceType, checkMode) {
50587             var elements = node.elements;
50588             if (languageVersion < 2 && compilerOptions.downlevelIteration) {
50589                 checkExternalEmitHelpers(node, 512);
50590             }
50591             var elementType = checkIteratedTypeOrElementType(65, sourceType, undefinedType, node) || errorType;
50592             for (var i = 0; i < elements.length; i++) {
50593                 checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, checkMode);
50594             }
50595             return sourceType;
50596         }
50597         function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) {
50598             var elements = node.elements;
50599             var element = elements[elementIndex];
50600             if (element.kind !== 215) {
50601                 if (element.kind !== 213) {
50602                     var indexType = getLiteralType(elementIndex);
50603                     if (isArrayLikeType(sourceType)) {
50604                         var accessFlags = hasDefaultValue(element) ? 8 : 0;
50605                         var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, createSyntheticExpression(element, indexType), accessFlags) || errorType;
50606                         var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288) : elementType_2;
50607                         var type = getFlowTypeOfDestructuring(element, assignedType);
50608                         return checkDestructuringAssignment(element, type, checkMode);
50609                     }
50610                     return checkDestructuringAssignment(element, elementType, checkMode);
50611                 }
50612                 if (elementIndex < elements.length - 1) {
50613                     error(element, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
50614                 }
50615                 else {
50616                     var restExpression = element.expression;
50617                     if (restExpression.kind === 209 && restExpression.operatorToken.kind === 62) {
50618                         error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer);
50619                     }
50620                     else {
50621                         checkGrammarForDisallowedTrailingComma(node.elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
50622                         var type = everyType(sourceType, isTupleType) ?
50623                             mapType(sourceType, function (t) { return sliceTupleType(t, elementIndex); }) :
50624                             createArrayType(elementType);
50625                         return checkDestructuringAssignment(restExpression, type, checkMode);
50626                     }
50627                 }
50628             }
50629             return undefined;
50630         }
50631         function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) {
50632             var target;
50633             if (exprOrAssignment.kind === 282) {
50634                 var prop = exprOrAssignment;
50635                 if (prop.objectAssignmentInitializer) {
50636                     if (strictNullChecks &&
50637                         !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768)) {
50638                         sourceType = getTypeWithFacts(sourceType, 524288);
50639                     }
50640                     checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode);
50641                 }
50642                 target = exprOrAssignment.name;
50643             }
50644             else {
50645                 target = exprOrAssignment;
50646             }
50647             if (target.kind === 209 && target.operatorToken.kind === 62) {
50648                 checkBinaryExpression(target, checkMode);
50649                 target = target.left;
50650             }
50651             if (target.kind === 193) {
50652                 return checkObjectLiteralAssignment(target, sourceType, rightIsThis);
50653             }
50654             if (target.kind === 192) {
50655                 return checkArrayLiteralAssignment(target, sourceType, checkMode);
50656             }
50657             return checkReferenceAssignment(target, sourceType, checkMode);
50658         }
50659         function checkReferenceAssignment(target, sourceType, checkMode) {
50660             var targetType = checkExpression(target, checkMode);
50661             var error = target.parent.kind === 283 ?
50662                 ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access :
50663                 ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access;
50664             var optionalError = target.parent.kind === 283 ?
50665                 ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access :
50666                 ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access;
50667             if (checkReferenceExpression(target, error, optionalError)) {
50668                 checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target);
50669             }
50670             if (ts.isPrivateIdentifierPropertyAccessExpression(target)) {
50671                 checkExternalEmitHelpers(target.parent, 524288);
50672             }
50673             return sourceType;
50674         }
50675         function isSideEffectFree(node) {
50676             node = ts.skipParentheses(node);
50677             switch (node.kind) {
50678                 case 75:
50679                 case 10:
50680                 case 13:
50681                 case 198:
50682                 case 211:
50683                 case 14:
50684                 case 8:
50685                 case 9:
50686                 case 106:
50687                 case 91:
50688                 case 100:
50689                 case 146:
50690                 case 201:
50691                 case 214:
50692                 case 202:
50693                 case 192:
50694                 case 193:
50695                 case 204:
50696                 case 218:
50697                 case 267:
50698                 case 266:
50699                     return true;
50700                 case 210:
50701                     return isSideEffectFree(node.whenTrue) &&
50702                         isSideEffectFree(node.whenFalse);
50703                 case 209:
50704                     if (ts.isAssignmentOperator(node.operatorToken.kind)) {
50705                         return false;
50706                     }
50707                     return isSideEffectFree(node.left) &&
50708                         isSideEffectFree(node.right);
50709                 case 207:
50710                 case 208:
50711                     switch (node.operator) {
50712                         case 53:
50713                         case 39:
50714                         case 40:
50715                         case 54:
50716                             return true;
50717                     }
50718                     return false;
50719                 case 205:
50720                 case 199:
50721                 case 217:
50722                 default:
50723                     return false;
50724             }
50725         }
50726         function isTypeEqualityComparableTo(source, target) {
50727             return (target.flags & 98304) !== 0 || isTypeComparableTo(source, target);
50728         }
50729         function checkBinaryExpression(node, checkMode) {
50730             var workStacks = {
50731                 expr: [node],
50732                 state: [0],
50733                 leftType: [undefined]
50734             };
50735             var stackIndex = 0;
50736             var lastResult;
50737             while (stackIndex >= 0) {
50738                 node = workStacks.expr[stackIndex];
50739                 switch (workStacks.state[stackIndex]) {
50740                     case 0: {
50741                         if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) {
50742                             finishInvocation(checkExpression(node.right, checkMode));
50743                             break;
50744                         }
50745                         checkGrammarNullishCoalesceWithLogicalExpression(node);
50746                         var operator = node.operatorToken.kind;
50747                         if (operator === 62 && (node.left.kind === 193 || node.left.kind === 192)) {
50748                             finishInvocation(checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 104));
50749                             break;
50750                         }
50751                         advanceState(1);
50752                         maybeCheckExpression(node.left);
50753                         break;
50754                     }
50755                     case 1: {
50756                         var leftType = lastResult;
50757                         workStacks.leftType[stackIndex] = leftType;
50758                         var operator = node.operatorToken.kind;
50759                         if (operator === 55 || operator === 56 || operator === 60) {
50760                             checkTruthinessOfType(leftType, node.left);
50761                         }
50762                         advanceState(2);
50763                         maybeCheckExpression(node.right);
50764                         break;
50765                     }
50766                     case 2: {
50767                         var leftType = workStacks.leftType[stackIndex];
50768                         var rightType = lastResult;
50769                         finishInvocation(checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node));
50770                         break;
50771                     }
50772                     default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for checkBinaryExpression");
50773                 }
50774             }
50775             return lastResult;
50776             function finishInvocation(result) {
50777                 lastResult = result;
50778                 stackIndex--;
50779             }
50780             function advanceState(nextState) {
50781                 workStacks.state[stackIndex] = nextState;
50782             }
50783             function maybeCheckExpression(node) {
50784                 if (ts.isBinaryExpression(node)) {
50785                     stackIndex++;
50786                     workStacks.expr[stackIndex] = node;
50787                     workStacks.state[stackIndex] = 0;
50788                     workStacks.leftType[stackIndex] = undefined;
50789                 }
50790                 else {
50791                     lastResult = checkExpression(node, checkMode);
50792                 }
50793             }
50794         }
50795         function checkGrammarNullishCoalesceWithLogicalExpression(node) {
50796             var left = node.left, operatorToken = node.operatorToken, right = node.right;
50797             if (operatorToken.kind === 60) {
50798                 if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 || left.operatorToken.kind === 55)) {
50799                     grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind));
50800                 }
50801                 if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 || right.operatorToken.kind === 55)) {
50802                     grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind));
50803                 }
50804             }
50805         }
50806         function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) {
50807             var operator = operatorToken.kind;
50808             if (operator === 62 && (left.kind === 193 || left.kind === 192)) {
50809                 return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 104);
50810             }
50811             var leftType;
50812             if (operator === 55 || operator === 56 || operator === 60) {
50813                 leftType = checkTruthinessExpression(left, checkMode);
50814             }
50815             else {
50816                 leftType = checkExpression(left, checkMode);
50817             }
50818             var rightType = checkExpression(right, checkMode);
50819             return checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode);
50820         }
50821         function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode) {
50822             var operator = operatorToken.kind;
50823             switch (operator) {
50824                 case 41:
50825                 case 42:
50826                 case 65:
50827                 case 66:
50828                 case 43:
50829                 case 67:
50830                 case 44:
50831                 case 68:
50832                 case 40:
50833                 case 64:
50834                 case 47:
50835                 case 69:
50836                 case 48:
50837                 case 70:
50838                 case 49:
50839                 case 71:
50840                 case 51:
50841                 case 73:
50842                 case 52:
50843                 case 74:
50844                 case 50:
50845                 case 72:
50846                     if (leftType === silentNeverType || rightType === silentNeverType) {
50847                         return silentNeverType;
50848                     }
50849                     leftType = checkNonNullType(leftType, left);
50850                     rightType = checkNonNullType(rightType, right);
50851                     var suggestedOperator = void 0;
50852                     if ((leftType.flags & 528) &&
50853                         (rightType.flags & 528) &&
50854                         (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) {
50855                         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));
50856                         return numberType;
50857                     }
50858                     else {
50859                         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);
50860                         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);
50861                         var resultType_1;
50862                         if ((isTypeAssignableToKind(leftType, 3) && isTypeAssignableToKind(rightType, 3)) ||
50863                             !(maybeTypeOfKind(leftType, 2112) || maybeTypeOfKind(rightType, 2112))) {
50864                             resultType_1 = numberType;
50865                         }
50866                         else if (bothAreBigIntLike(leftType, rightType)) {
50867                             switch (operator) {
50868                                 case 49:
50869                                 case 71:
50870                                     reportOperatorError();
50871                             }
50872                             resultType_1 = bigintType;
50873                         }
50874                         else {
50875                             reportOperatorError(bothAreBigIntLike);
50876                             resultType_1 = errorType;
50877                         }
50878                         if (leftOk && rightOk) {
50879                             checkAssignmentOperator(resultType_1);
50880                         }
50881                         return resultType_1;
50882                     }
50883                 case 39:
50884                 case 63:
50885                     if (leftType === silentNeverType || rightType === silentNeverType) {
50886                         return silentNeverType;
50887                     }
50888                     if (!isTypeAssignableToKind(leftType, 132) && !isTypeAssignableToKind(rightType, 132)) {
50889                         leftType = checkNonNullType(leftType, left);
50890                         rightType = checkNonNullType(rightType, right);
50891                     }
50892                     var resultType = void 0;
50893                     if (isTypeAssignableToKind(leftType, 296, true) && isTypeAssignableToKind(rightType, 296, true)) {
50894                         resultType = numberType;
50895                     }
50896                     else if (isTypeAssignableToKind(leftType, 2112, true) && isTypeAssignableToKind(rightType, 2112, true)) {
50897                         resultType = bigintType;
50898                     }
50899                     else if (isTypeAssignableToKind(leftType, 132, true) || isTypeAssignableToKind(rightType, 132, true)) {
50900                         resultType = stringType;
50901                     }
50902                     else if (isTypeAny(leftType) || isTypeAny(rightType)) {
50903                         resultType = leftType === errorType || rightType === errorType ? errorType : anyType;
50904                     }
50905                     if (resultType && !checkForDisallowedESSymbolOperand(operator)) {
50906                         return resultType;
50907                     }
50908                     if (!resultType) {
50909                         var closeEnoughKind_1 = 296 | 2112 | 132 | 3;
50910                         reportOperatorError(function (left, right) {
50911                             return isTypeAssignableToKind(left, closeEnoughKind_1) &&
50912                                 isTypeAssignableToKind(right, closeEnoughKind_1);
50913                         });
50914                         return anyType;
50915                     }
50916                     if (operator === 63) {
50917                         checkAssignmentOperator(resultType);
50918                     }
50919                     return resultType;
50920                 case 29:
50921                 case 31:
50922                 case 32:
50923                 case 33:
50924                     if (checkForDisallowedESSymbolOperand(operator)) {
50925                         leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left));
50926                         rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right));
50927                         reportOperatorErrorUnless(function (left, right) {
50928                             return isTypeComparableTo(left, right) || isTypeComparableTo(right, left) || (isTypeAssignableTo(left, numberOrBigIntType) && isTypeAssignableTo(right, numberOrBigIntType));
50929                         });
50930                     }
50931                     return booleanType;
50932                 case 34:
50933                 case 35:
50934                 case 36:
50935                 case 37:
50936                     reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); });
50937                     return booleanType;
50938                 case 98:
50939                     return checkInstanceOfExpression(left, right, leftType, rightType);
50940                 case 97:
50941                     return checkInExpression(left, right, leftType, rightType);
50942                 case 55:
50943                     return getTypeFacts(leftType) & 4194304 ?
50944                         getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) :
50945                         leftType;
50946                 case 56:
50947                     return getTypeFacts(leftType) & 8388608 ?
50948                         getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2) :
50949                         leftType;
50950                 case 60:
50951                     return getTypeFacts(leftType) & 262144 ?
50952                         getUnionType([getNonNullableType(leftType), rightType], 2) :
50953                         leftType;
50954                 case 62:
50955                     var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0;
50956                     checkAssignmentDeclaration(declKind, rightType);
50957                     if (isAssignmentDeclaration(declKind)) {
50958                         if (!(rightType.flags & 524288) ||
50959                             declKind !== 2 &&
50960                                 declKind !== 6 &&
50961                                 !isEmptyObjectType(rightType) &&
50962                                 !isFunctionObjectType(rightType) &&
50963                                 !(ts.getObjectFlags(rightType) & 1)) {
50964                             checkAssignmentOperator(rightType);
50965                         }
50966                         return leftType;
50967                     }
50968                     else {
50969                         checkAssignmentOperator(rightType);
50970                         return getRegularTypeOfObjectLiteral(rightType);
50971                     }
50972                 case 27:
50973                     if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) {
50974                         error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects);
50975                     }
50976                     return rightType;
50977                 default:
50978                     return ts.Debug.fail();
50979             }
50980             function bothAreBigIntLike(left, right) {
50981                 return isTypeAssignableToKind(left, 2112) && isTypeAssignableToKind(right, 2112);
50982             }
50983             function checkAssignmentDeclaration(kind, rightType) {
50984                 if (kind === 2) {
50985                     for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) {
50986                         var prop = _a[_i];
50987                         var propType = getTypeOfSymbol(prop);
50988                         if (propType.symbol && propType.symbol.flags & 32) {
50989                             var name = prop.escapedName;
50990                             var symbol = resolveName(prop.valueDeclaration, name, 788968, undefined, name, false);
50991                             if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) {
50992                                 addDuplicateDeclarationErrorsForSymbols(symbol, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), prop);
50993                                 addDuplicateDeclarationErrorsForSymbols(prop, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), symbol);
50994                             }
50995                         }
50996                     }
50997                 }
50998             }
50999             function isEvalNode(node) {
51000                 return node.kind === 75 && node.escapedText === "eval";
51001             }
51002             function checkForDisallowedESSymbolOperand(operator) {
51003                 var offendingSymbolOperand = maybeTypeOfKind(leftType, 12288) ? left :
51004                     maybeTypeOfKind(rightType, 12288) ? right :
51005                         undefined;
51006                 if (offendingSymbolOperand) {
51007                     error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator));
51008                     return false;
51009                 }
51010                 return true;
51011             }
51012             function getSuggestedBooleanOperator(operator) {
51013                 switch (operator) {
51014                     case 51:
51015                     case 73:
51016                         return 56;
51017                     case 52:
51018                     case 74:
51019                         return 37;
51020                     case 50:
51021                     case 72:
51022                         return 55;
51023                     default:
51024                         return undefined;
51025                 }
51026             }
51027             function checkAssignmentOperator(valueType) {
51028                 if (produceDiagnostics && ts.isAssignmentOperator(operator)) {
51029                     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)
51030                         && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) {
51031                         checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right);
51032                     }
51033                 }
51034             }
51035             function isAssignmentDeclaration(kind) {
51036                 switch (kind) {
51037                     case 2:
51038                         return true;
51039                     case 1:
51040                     case 5:
51041                     case 6:
51042                     case 3:
51043                     case 4:
51044                         var symbol = getSymbolOfNode(left);
51045                         var init = ts.getAssignedExpandoInitializer(right);
51046                         return init && ts.isObjectLiteralExpression(init) &&
51047                             symbol && ts.hasEntries(symbol.exports);
51048                     default:
51049                         return false;
51050                 }
51051             }
51052             function reportOperatorErrorUnless(typesAreCompatible) {
51053                 if (!typesAreCompatible(leftType, rightType)) {
51054                     reportOperatorError(typesAreCompatible);
51055                     return true;
51056                 }
51057                 return false;
51058             }
51059             function reportOperatorError(isRelated) {
51060                 var _a;
51061                 var wouldWorkWithAwait = false;
51062                 var errNode = errorNode || operatorToken;
51063                 if (isRelated) {
51064                     var awaitedLeftType = getAwaitedType(leftType);
51065                     var awaitedRightType = getAwaitedType(rightType);
51066                     wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType)
51067                         && !!(awaitedLeftType && awaitedRightType)
51068                         && isRelated(awaitedLeftType, awaitedRightType);
51069                 }
51070                 var effectiveLeft = leftType;
51071                 var effectiveRight = rightType;
51072                 if (!wouldWorkWithAwait && isRelated) {
51073                     _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1];
51074                 }
51075                 var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1];
51076                 if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) {
51077                     errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr);
51078                 }
51079             }
51080             function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) {
51081                 var typeName;
51082                 switch (operatorToken.kind) {
51083                     case 36:
51084                     case 34:
51085                         typeName = "false";
51086                         break;
51087                     case 37:
51088                     case 35:
51089                         typeName = "true";
51090                 }
51091                 if (typeName) {
51092                     return errorAndMaybeSuggestAwait(errNode, maybeMissingAwait, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, typeName, leftStr, rightStr);
51093                 }
51094                 return undefined;
51095             }
51096         }
51097         function getBaseTypesIfUnrelated(leftType, rightType, isRelated) {
51098             var effectiveLeft = leftType;
51099             var effectiveRight = rightType;
51100             var leftBase = getBaseTypeOfLiteralType(leftType);
51101             var rightBase = getBaseTypeOfLiteralType(rightType);
51102             if (!isRelated(leftBase, rightBase)) {
51103                 effectiveLeft = leftBase;
51104                 effectiveRight = rightBase;
51105             }
51106             return [effectiveLeft, effectiveRight];
51107         }
51108         function checkYieldExpression(node) {
51109             if (produceDiagnostics) {
51110                 if (!(node.flags & 8192)) {
51111                     grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body);
51112                 }
51113                 if (isInParameterInitializerBeforeContainingFunction(node)) {
51114                     error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer);
51115                 }
51116             }
51117             var func = ts.getContainingFunction(node);
51118             if (!func)
51119                 return anyType;
51120             var functionFlags = ts.getFunctionFlags(func);
51121             if (!(functionFlags & 1)) {
51122                 return anyType;
51123             }
51124             var isAsync = (functionFlags & 2) !== 0;
51125             if (node.asteriskToken) {
51126                 if (isAsync && languageVersion < 99) {
51127                     checkExternalEmitHelpers(node, 53248);
51128                 }
51129                 if (!isAsync && languageVersion < 2 && compilerOptions.downlevelIteration) {
51130                     checkExternalEmitHelpers(node, 256);
51131                 }
51132             }
51133             var returnType = getReturnTypeFromAnnotation(func);
51134             var iterationTypes = returnType && getIterationTypesOfGeneratorFunctionReturnType(returnType, isAsync);
51135             var signatureYieldType = iterationTypes && iterationTypes.yieldType || anyType;
51136             var signatureNextType = iterationTypes && iterationTypes.nextType || anyType;
51137             var resolvedSignatureNextType = isAsync ? getAwaitedType(signatureNextType) || anyType : signatureNextType;
51138             var yieldExpressionType = node.expression ? checkExpression(node.expression) : undefinedWideningType;
51139             var yieldedType = getYieldedTypeOfYieldExpression(node, yieldExpressionType, resolvedSignatureNextType, isAsync);
51140             if (returnType && yieldedType) {
51141                 checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureYieldType, node.expression || node, node.expression);
51142             }
51143             if (node.asteriskToken) {
51144                 var use = isAsync ? 19 : 17;
51145                 return getIterationTypeOfIterable(use, 1, yieldExpressionType, node.expression)
51146                     || anyType;
51147             }
51148             else if (returnType) {
51149                 return getIterationTypeOfGeneratorFunctionReturnType(2, returnType, isAsync)
51150                     || anyType;
51151             }
51152             return getContextualIterationType(2, func) || anyType;
51153         }
51154         function checkConditionalExpression(node, checkMode) {
51155             var type = checkTruthinessExpression(node.condition);
51156             checkTestingKnownTruthyCallableType(node.condition, node.whenTrue, type);
51157             var type1 = checkExpression(node.whenTrue, checkMode);
51158             var type2 = checkExpression(node.whenFalse, checkMode);
51159             return getUnionType([type1, type2], 2);
51160         }
51161         function checkTemplateExpression(node) {
51162             ts.forEach(node.templateSpans, function (templateSpan) {
51163                 if (maybeTypeOfKind(checkExpression(templateSpan.expression), 12288)) {
51164                     error(templateSpan.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String);
51165                 }
51166             });
51167             return stringType;
51168         }
51169         function getContextNode(node) {
51170             if (node.kind === 274 && !ts.isJsxSelfClosingElement(node.parent)) {
51171                 return node.parent.parent;
51172             }
51173             return node;
51174         }
51175         function checkExpressionWithContextualType(node, contextualType, inferenceContext, checkMode) {
51176             var context = getContextNode(node);
51177             var saveContextualType = context.contextualType;
51178             var saveInferenceContext = context.inferenceContext;
51179             try {
51180                 context.contextualType = contextualType;
51181                 context.inferenceContext = inferenceContext;
51182                 var type = checkExpression(node, checkMode | 1 | (inferenceContext ? 2 : 0));
51183                 var result = maybeTypeOfKind(type, 2944) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ?
51184                     getRegularTypeOfLiteralType(type) : type;
51185                 return result;
51186             }
51187             finally {
51188                 context.contextualType = saveContextualType;
51189                 context.inferenceContext = saveInferenceContext;
51190             }
51191         }
51192         function checkExpressionCached(node, checkMode) {
51193             var links = getNodeLinks(node);
51194             if (!links.resolvedType) {
51195                 if (checkMode && checkMode !== 0) {
51196                     return checkExpression(node, checkMode);
51197                 }
51198                 var saveFlowLoopStart = flowLoopStart;
51199                 var saveFlowTypeCache = flowTypeCache;
51200                 flowLoopStart = flowLoopCount;
51201                 flowTypeCache = undefined;
51202                 links.resolvedType = checkExpression(node, checkMode);
51203                 flowTypeCache = saveFlowTypeCache;
51204                 flowLoopStart = saveFlowLoopStart;
51205             }
51206             return links.resolvedType;
51207         }
51208         function isTypeAssertion(node) {
51209             node = ts.skipParentheses(node);
51210             return node.kind === 199 || node.kind === 217;
51211         }
51212         function checkDeclarationInitializer(declaration, contextualType) {
51213             var initializer = ts.getEffectiveInitializer(declaration);
51214             var type = getQuickTypeOfExpression(initializer) ||
51215                 (contextualType ? checkExpressionWithContextualType(initializer, contextualType, undefined, 0) : checkExpressionCached(initializer));
51216             return ts.isParameter(declaration) && declaration.name.kind === 190 &&
51217                 isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ?
51218                 padTupleType(type, declaration.name) : type;
51219         }
51220         function padTupleType(type, pattern) {
51221             var patternElements = pattern.elements;
51222             var arity = getTypeReferenceArity(type);
51223             var elementTypes = arity ? getTypeArguments(type).slice() : [];
51224             for (var i = arity; i < patternElements.length; i++) {
51225                 var e = patternElements[i];
51226                 if (i < patternElements.length - 1 || !(e.kind === 191 && e.dotDotDotToken)) {
51227                     elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, false, false) : anyType);
51228                     if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) {
51229                         reportImplicitAny(e, anyType);
51230                     }
51231                 }
51232             }
51233             return createTupleType(elementTypes, type.target.minLength, false, type.target.readonly);
51234         }
51235         function widenTypeInferredFromInitializer(declaration, type) {
51236             var widened = ts.getCombinedNodeFlags(declaration) & 2 || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type);
51237             if (ts.isInJSFile(declaration)) {
51238                 if (widened.flags & 98304) {
51239                     reportImplicitAny(declaration, anyType);
51240                     return anyType;
51241                 }
51242                 else if (isEmptyArrayLiteralType(widened)) {
51243                     reportImplicitAny(declaration, anyArrayType);
51244                     return anyArrayType;
51245                 }
51246             }
51247             return widened;
51248         }
51249         function isLiteralOfContextualType(candidateType, contextualType) {
51250             if (contextualType) {
51251                 if (contextualType.flags & 3145728) {
51252                     var types = contextualType.types;
51253                     return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); });
51254                 }
51255                 if (contextualType.flags & 58982400) {
51256                     var constraint = getBaseConstraintOfType(contextualType) || unknownType;
51257                     return maybeTypeOfKind(constraint, 4) && maybeTypeOfKind(candidateType, 128) ||
51258                         maybeTypeOfKind(constraint, 8) && maybeTypeOfKind(candidateType, 256) ||
51259                         maybeTypeOfKind(constraint, 64) && maybeTypeOfKind(candidateType, 2048) ||
51260                         maybeTypeOfKind(constraint, 4096) && maybeTypeOfKind(candidateType, 8192) ||
51261                         isLiteralOfContextualType(candidateType, constraint);
51262                 }
51263                 return !!(contextualType.flags & (128 | 4194304) && maybeTypeOfKind(candidateType, 128) ||
51264                     contextualType.flags & 256 && maybeTypeOfKind(candidateType, 256) ||
51265                     contextualType.flags & 2048 && maybeTypeOfKind(candidateType, 2048) ||
51266                     contextualType.flags & 512 && maybeTypeOfKind(candidateType, 512) ||
51267                     contextualType.flags & 8192 && maybeTypeOfKind(candidateType, 8192));
51268             }
51269             return false;
51270         }
51271         function isConstContext(node) {
51272             var parent = node.parent;
51273             return ts.isAssertionExpression(parent) && ts.isConstTypeReference(parent.type) ||
51274                 (ts.isParenthesizedExpression(parent) || ts.isArrayLiteralExpression(parent) || ts.isSpreadElement(parent)) && isConstContext(parent) ||
51275                 (ts.isPropertyAssignment(parent) || ts.isShorthandPropertyAssignment(parent)) && isConstContext(parent.parent);
51276         }
51277         function checkExpressionForMutableLocation(node, checkMode, contextualType, forceTuple) {
51278             var type = checkExpression(node, checkMode, forceTuple);
51279             return isConstContext(node) ? getRegularTypeOfLiteralType(type) :
51280                 isTypeAssertion(node) ? type :
51281                     getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node));
51282         }
51283         function checkPropertyAssignment(node, checkMode) {
51284             if (node.name.kind === 154) {
51285                 checkComputedPropertyName(node.name);
51286             }
51287             return checkExpressionForMutableLocation(node.initializer, checkMode);
51288         }
51289         function checkObjectLiteralMethod(node, checkMode) {
51290             checkGrammarMethod(node);
51291             if (node.name.kind === 154) {
51292                 checkComputedPropertyName(node.name);
51293             }
51294             var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode);
51295             return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode);
51296         }
51297         function instantiateTypeWithSingleGenericCallSignature(node, type, checkMode) {
51298             if (checkMode && checkMode & (2 | 8)) {
51299                 var callSignature = getSingleSignature(type, 0, true);
51300                 var constructSignature = getSingleSignature(type, 1, true);
51301                 var signature = callSignature || constructSignature;
51302                 if (signature && signature.typeParameters) {
51303                     var contextualType = getApparentTypeOfContextualType(node, 2);
51304                     if (contextualType) {
51305                         var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 : 1, false);
51306                         if (contextualSignature && !contextualSignature.typeParameters) {
51307                             if (checkMode & 8) {
51308                                 skippedGenericFunction(node, checkMode);
51309                                 return anyFunctionType;
51310                             }
51311                             var context = getInferenceContext(node);
51312                             var returnType = context.signature && getReturnTypeOfSignature(context.signature);
51313                             var returnSignature = returnType && getSingleCallOrConstructSignature(returnType);
51314                             if (returnSignature && !returnSignature.typeParameters && !ts.every(context.inferences, hasInferenceCandidates)) {
51315                                 var uniqueTypeParameters = getUniqueTypeParameters(context, signature.typeParameters);
51316                                 var instantiatedSignature = getSignatureInstantiationWithoutFillingInTypeArguments(signature, uniqueTypeParameters);
51317                                 var inferences_3 = ts.map(context.inferences, function (info) { return createInferenceInfo(info.typeParameter); });
51318                                 applyToParameterTypes(instantiatedSignature, contextualSignature, function (source, target) {
51319                                     inferTypes(inferences_3, source, target, 0, true);
51320                                 });
51321                                 if (ts.some(inferences_3, hasInferenceCandidates)) {
51322                                     applyToReturnTypes(instantiatedSignature, contextualSignature, function (source, target) {
51323                                         inferTypes(inferences_3, source, target);
51324                                     });
51325                                     if (!hasOverlappingInferences(context.inferences, inferences_3)) {
51326                                         mergeInferences(context.inferences, inferences_3);
51327                                         context.inferredTypeParameters = ts.concatenate(context.inferredTypeParameters, uniqueTypeParameters);
51328                                         return getOrCreateTypeFromSignature(instantiatedSignature);
51329                                     }
51330                                 }
51331                             }
51332                             return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, context));
51333                         }
51334                     }
51335                 }
51336             }
51337             return type;
51338         }
51339         function skippedGenericFunction(node, checkMode) {
51340             if (checkMode & 2) {
51341                 var context = getInferenceContext(node);
51342                 context.flags |= 4;
51343             }
51344         }
51345         function hasInferenceCandidates(info) {
51346             return !!(info.candidates || info.contraCandidates);
51347         }
51348         function hasOverlappingInferences(a, b) {
51349             for (var i = 0; i < a.length; i++) {
51350                 if (hasInferenceCandidates(a[i]) && hasInferenceCandidates(b[i])) {
51351                     return true;
51352                 }
51353             }
51354             return false;
51355         }
51356         function mergeInferences(target, source) {
51357             for (var i = 0; i < target.length; i++) {
51358                 if (!hasInferenceCandidates(target[i]) && hasInferenceCandidates(source[i])) {
51359                     target[i] = source[i];
51360                 }
51361             }
51362         }
51363         function getUniqueTypeParameters(context, typeParameters) {
51364             var result = [];
51365             var oldTypeParameters;
51366             var newTypeParameters;
51367             for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
51368                 var tp = typeParameters_2[_i];
51369                 var name = tp.symbol.escapedName;
51370                 if (hasTypeParameterByName(context.inferredTypeParameters, name) || hasTypeParameterByName(result, name)) {
51371                     var newName = getUniqueTypeParameterName(ts.concatenate(context.inferredTypeParameters, result), name);
51372                     var symbol = createSymbol(262144, newName);
51373                     var newTypeParameter = createTypeParameter(symbol);
51374                     newTypeParameter.target = tp;
51375                     oldTypeParameters = ts.append(oldTypeParameters, tp);
51376                     newTypeParameters = ts.append(newTypeParameters, newTypeParameter);
51377                     result.push(newTypeParameter);
51378                 }
51379                 else {
51380                     result.push(tp);
51381                 }
51382             }
51383             if (newTypeParameters) {
51384                 var mapper = createTypeMapper(oldTypeParameters, newTypeParameters);
51385                 for (var _a = 0, newTypeParameters_1 = newTypeParameters; _a < newTypeParameters_1.length; _a++) {
51386                     var tp = newTypeParameters_1[_a];
51387                     tp.mapper = mapper;
51388                 }
51389             }
51390             return result;
51391         }
51392         function hasTypeParameterByName(typeParameters, name) {
51393             return ts.some(typeParameters, function (tp) { return tp.symbol.escapedName === name; });
51394         }
51395         function getUniqueTypeParameterName(typeParameters, baseName) {
51396             var len = baseName.length;
51397             while (len > 1 && baseName.charCodeAt(len - 1) >= 48 && baseName.charCodeAt(len - 1) <= 57)
51398                 len--;
51399             var s = baseName.slice(0, len);
51400             for (var index = 1; true; index++) {
51401                 var augmentedName = (s + index);
51402                 if (!hasTypeParameterByName(typeParameters, augmentedName)) {
51403                     return augmentedName;
51404                 }
51405             }
51406         }
51407         function getReturnTypeOfSingleNonGenericCallSignature(funcType) {
51408             var signature = getSingleCallSignature(funcType);
51409             if (signature && !signature.typeParameters) {
51410                 return getReturnTypeOfSignature(signature);
51411             }
51412         }
51413         function getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) {
51414             var funcType = checkExpression(expr.expression);
51415             var nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
51416             var returnType = getReturnTypeOfSingleNonGenericCallSignature(funcType);
51417             return returnType && propagateOptionalTypeMarker(returnType, expr, nonOptionalType !== funcType);
51418         }
51419         function getTypeOfExpression(node) {
51420             var quickType = getQuickTypeOfExpression(node);
51421             if (quickType) {
51422                 return quickType;
51423             }
51424             if (node.flags & 67108864 && flowTypeCache) {
51425                 var cachedType = flowTypeCache[getNodeId(node)];
51426                 if (cachedType) {
51427                     return cachedType;
51428                 }
51429             }
51430             var startInvocationCount = flowInvocationCount;
51431             var type = checkExpression(node);
51432             if (flowInvocationCount !== startInvocationCount) {
51433                 var cache = flowTypeCache || (flowTypeCache = []);
51434                 cache[getNodeId(node)] = type;
51435                 node.flags |= 67108864;
51436             }
51437             return type;
51438         }
51439         function getQuickTypeOfExpression(node) {
51440             var expr = ts.skipParentheses(node);
51441             if (ts.isCallExpression(expr) && expr.expression.kind !== 102 && !ts.isRequireCall(expr, true) && !isSymbolOrSymbolForCall(expr)) {
51442                 var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
51443                     getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
51444                 if (type) {
51445                     return type;
51446                 }
51447             }
51448             else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) {
51449                 return getTypeFromTypeNode(expr.type);
51450             }
51451             else if (node.kind === 8 || node.kind === 10 ||
51452                 node.kind === 106 || node.kind === 91) {
51453                 return checkExpression(node);
51454             }
51455             return undefined;
51456         }
51457         function getContextFreeTypeOfExpression(node) {
51458             var links = getNodeLinks(node);
51459             if (links.contextFreeType) {
51460                 return links.contextFreeType;
51461             }
51462             var saveContextualType = node.contextualType;
51463             node.contextualType = anyType;
51464             try {
51465                 var type = links.contextFreeType = checkExpression(node, 4);
51466                 return type;
51467             }
51468             finally {
51469                 node.contextualType = saveContextualType;
51470             }
51471         }
51472         function checkExpression(node, checkMode, forceTuple) {
51473             var saveCurrentNode = currentNode;
51474             currentNode = node;
51475             instantiationCount = 0;
51476             var uninstantiatedType = checkExpressionWorker(node, checkMode, forceTuple);
51477             var type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode);
51478             if (isConstEnumObjectType(type)) {
51479                 checkConstEnumAccess(node, type);
51480             }
51481             currentNode = saveCurrentNode;
51482             return type;
51483         }
51484         function checkConstEnumAccess(node, type) {
51485             var ok = (node.parent.kind === 194 && node.parent.expression === node) ||
51486                 (node.parent.kind === 195 && node.parent.expression === node) ||
51487                 ((node.kind === 75 || node.kind === 153) && isInRightSideOfImportOrExportAssignment(node) ||
51488                     (node.parent.kind === 172 && node.parent.exprName === node)) ||
51489                 (node.parent.kind === 263);
51490             if (!ok) {
51491                 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);
51492             }
51493             if (compilerOptions.isolatedModules) {
51494                 ts.Debug.assert(!!(type.symbol.flags & 128));
51495                 var constEnumDeclaration = type.symbol.valueDeclaration;
51496                 if (constEnumDeclaration.flags & 8388608) {
51497                     error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided);
51498                 }
51499             }
51500         }
51501         function checkParenthesizedExpression(node, checkMode) {
51502             var tag = ts.isInJSFile(node) ? ts.getJSDocTypeTag(node) : undefined;
51503             if (tag) {
51504                 return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode);
51505             }
51506             return checkExpression(node.expression, checkMode);
51507         }
51508         function checkExpressionWorker(node, checkMode, forceTuple) {
51509             var kind = node.kind;
51510             if (cancellationToken) {
51511                 switch (kind) {
51512                     case 214:
51513                     case 201:
51514                     case 202:
51515                         cancellationToken.throwIfCancellationRequested();
51516                 }
51517             }
51518             switch (kind) {
51519                 case 75:
51520                     return checkIdentifier(node);
51521                 case 104:
51522                     return checkThisExpression(node);
51523                 case 102:
51524                     return checkSuperExpression(node);
51525                 case 100:
51526                     return nullWideningType;
51527                 case 14:
51528                 case 10:
51529                     return getFreshTypeOfLiteralType(getLiteralType(node.text));
51530                 case 8:
51531                     checkGrammarNumericLiteral(node);
51532                     return getFreshTypeOfLiteralType(getLiteralType(+node.text));
51533                 case 9:
51534                     checkGrammarBigIntLiteral(node);
51535                     return getFreshTypeOfLiteralType(getBigIntLiteralType(node));
51536                 case 106:
51537                     return trueType;
51538                 case 91:
51539                     return falseType;
51540                 case 211:
51541                     return checkTemplateExpression(node);
51542                 case 13:
51543                     return globalRegExpType;
51544                 case 192:
51545                     return checkArrayLiteral(node, checkMode, forceTuple);
51546                 case 193:
51547                     return checkObjectLiteral(node, checkMode);
51548                 case 194:
51549                     return checkPropertyAccessExpression(node);
51550                 case 153:
51551                     return checkQualifiedName(node);
51552                 case 195:
51553                     return checkIndexedAccess(node);
51554                 case 196:
51555                     if (node.expression.kind === 96) {
51556                         return checkImportCallExpression(node);
51557                     }
51558                 case 197:
51559                     return checkCallExpression(node, checkMode);
51560                 case 198:
51561                     return checkTaggedTemplateExpression(node);
51562                 case 200:
51563                     return checkParenthesizedExpression(node, checkMode);
51564                 case 214:
51565                     return checkClassExpression(node);
51566                 case 201:
51567                 case 202:
51568                     return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode);
51569                 case 204:
51570                     return checkTypeOfExpression(node);
51571                 case 199:
51572                 case 217:
51573                     return checkAssertion(node);
51574                 case 218:
51575                     return checkNonNullAssertion(node);
51576                 case 219:
51577                     return checkMetaProperty(node);
51578                 case 203:
51579                     return checkDeleteExpression(node);
51580                 case 205:
51581                     return checkVoidExpression(node);
51582                 case 206:
51583                     return checkAwaitExpression(node);
51584                 case 207:
51585                     return checkPrefixUnaryExpression(node);
51586                 case 208:
51587                     return checkPostfixUnaryExpression(node);
51588                 case 209:
51589                     return checkBinaryExpression(node, checkMode);
51590                 case 210:
51591                     return checkConditionalExpression(node, checkMode);
51592                 case 213:
51593                     return checkSpreadExpression(node, checkMode);
51594                 case 215:
51595                     return undefinedWideningType;
51596                 case 212:
51597                     return checkYieldExpression(node);
51598                 case 220:
51599                     return node.type;
51600                 case 276:
51601                     return checkJsxExpression(node, checkMode);
51602                 case 266:
51603                     return checkJsxElement(node, checkMode);
51604                 case 267:
51605                     return checkJsxSelfClosingElement(node, checkMode);
51606                 case 270:
51607                     return checkJsxFragment(node);
51608                 case 274:
51609                     return checkJsxAttributes(node, checkMode);
51610                 case 268:
51611                     ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement");
51612             }
51613             return errorType;
51614         }
51615         function checkTypeParameter(node) {
51616             if (node.expression) {
51617                 grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected);
51618             }
51619             checkSourceElement(node.constraint);
51620             checkSourceElement(node.default);
51621             var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node));
51622             getBaseConstraintOfType(typeParameter);
51623             if (!hasNonCircularTypeParameterDefault(typeParameter)) {
51624                 error(node.default, ts.Diagnostics.Type_parameter_0_has_a_circular_default, typeToString(typeParameter));
51625             }
51626             var constraintType = getConstraintOfTypeParameter(typeParameter);
51627             var defaultType = getDefaultFromTypeParameter(typeParameter);
51628             if (constraintType && defaultType) {
51629                 checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
51630             }
51631             if (produceDiagnostics) {
51632                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0);
51633             }
51634         }
51635         function checkParameter(node) {
51636             checkGrammarDecoratorsAndModifiers(node);
51637             checkVariableLikeDeclaration(node);
51638             var func = ts.getContainingFunction(node);
51639             if (ts.hasModifier(node, 92)) {
51640                 if (!(func.kind === 162 && ts.nodeIsPresent(func.body))) {
51641                     error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation);
51642                 }
51643                 if (func.kind === 162 && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") {
51644                     error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name);
51645                 }
51646             }
51647             if (node.questionToken && ts.isBindingPattern(node.name) && func.body) {
51648                 error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature);
51649             }
51650             if (node.name && ts.isIdentifier(node.name) && (node.name.escapedText === "this" || node.name.escapedText === "new")) {
51651                 if (func.parameters.indexOf(node) !== 0) {
51652                     error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText);
51653                 }
51654                 if (func.kind === 162 || func.kind === 166 || func.kind === 171) {
51655                     error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter);
51656                 }
51657                 if (func.kind === 202) {
51658                     error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter);
51659                 }
51660                 if (func.kind === 163 || func.kind === 164) {
51661                     error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters);
51662                 }
51663             }
51664             if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isTypeAssignableTo(getReducedType(getTypeOfSymbol(node.symbol)), anyReadonlyArrayType)) {
51665                 error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type);
51666             }
51667         }
51668         function checkTypePredicate(node) {
51669             var parent = getTypePredicateParent(node);
51670             if (!parent) {
51671                 error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods);
51672                 return;
51673             }
51674             var signature = getSignatureFromDeclaration(parent);
51675             var typePredicate = getTypePredicateOfSignature(signature);
51676             if (!typePredicate) {
51677                 return;
51678             }
51679             checkSourceElement(node.type);
51680             var parameterName = node.parameterName;
51681             if (typePredicate.kind === 0 || typePredicate.kind === 2) {
51682                 getTypeFromThisTypeNode(parameterName);
51683             }
51684             else {
51685                 if (typePredicate.parameterIndex >= 0) {
51686                     if (signatureHasRestParameter(signature) && typePredicate.parameterIndex === signature.parameters.length - 1) {
51687                         error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter);
51688                     }
51689                     else {
51690                         if (typePredicate.type) {
51691                             var leadingError = function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); };
51692                             checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, undefined, leadingError);
51693                         }
51694                     }
51695                 }
51696                 else if (parameterName) {
51697                     var hasReportedError = false;
51698                     for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) {
51699                         var name = _a[_i].name;
51700                         if (ts.isBindingPattern(name) &&
51701                             checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, parameterName, typePredicate.parameterName)) {
51702                             hasReportedError = true;
51703                             break;
51704                         }
51705                     }
51706                     if (!hasReportedError) {
51707                         error(node.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName);
51708                     }
51709                 }
51710             }
51711         }
51712         function getTypePredicateParent(node) {
51713             switch (node.parent.kind) {
51714                 case 202:
51715                 case 165:
51716                 case 244:
51717                 case 201:
51718                 case 170:
51719                 case 161:
51720                 case 160:
51721                     var parent = node.parent;
51722                     if (node === parent.type) {
51723                         return parent;
51724                     }
51725             }
51726         }
51727         function checkIfTypePredicateVariableIsDeclaredInBindingPattern(pattern, predicateVariableNode, predicateVariableName) {
51728             for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
51729                 var element = _a[_i];
51730                 if (ts.isOmittedExpression(element)) {
51731                     continue;
51732                 }
51733                 var name = element.name;
51734                 if (name.kind === 75 && name.escapedText === predicateVariableName) {
51735                     error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName);
51736                     return true;
51737                 }
51738                 else if (name.kind === 190 || name.kind === 189) {
51739                     if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) {
51740                         return true;
51741                     }
51742                 }
51743             }
51744         }
51745         function checkSignatureDeclaration(node) {
51746             if (node.kind === 167) {
51747                 checkGrammarIndexSignature(node);
51748             }
51749             else if (node.kind === 170 || node.kind === 244 || node.kind === 171 ||
51750                 node.kind === 165 || node.kind === 162 ||
51751                 node.kind === 166) {
51752                 checkGrammarFunctionLikeDeclaration(node);
51753             }
51754             var functionFlags = ts.getFunctionFlags(node);
51755             if (!(functionFlags & 4)) {
51756                 if ((functionFlags & 3) === 3 && languageVersion < 99) {
51757                     checkExternalEmitHelpers(node, 12288);
51758                 }
51759                 if ((functionFlags & 3) === 2 && languageVersion < 4) {
51760                     checkExternalEmitHelpers(node, 64);
51761                 }
51762                 if ((functionFlags & 3) !== 0 && languageVersion < 2) {
51763                     checkExternalEmitHelpers(node, 128);
51764                 }
51765             }
51766             checkTypeParameters(node.typeParameters);
51767             ts.forEach(node.parameters, checkParameter);
51768             if (node.type) {
51769                 checkSourceElement(node.type);
51770             }
51771             if (produceDiagnostics) {
51772                 checkCollisionWithArgumentsInGeneratedCode(node);
51773                 var returnTypeNode = ts.getEffectiveReturnTypeNode(node);
51774                 if (noImplicitAny && !returnTypeNode) {
51775                     switch (node.kind) {
51776                         case 166:
51777                             error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
51778                             break;
51779                         case 165:
51780                             error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
51781                             break;
51782                     }
51783                 }
51784                 if (returnTypeNode) {
51785                     var functionFlags_1 = ts.getFunctionFlags(node);
51786                     if ((functionFlags_1 & (4 | 1)) === 1) {
51787                         var returnType = getTypeFromTypeNode(returnTypeNode);
51788                         if (returnType === voidType) {
51789                             error(returnTypeNode, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation);
51790                         }
51791                         else {
51792                             var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0, returnType, (functionFlags_1 & 2) !== 0) || anyType;
51793                             var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1, returnType, (functionFlags_1 & 2) !== 0) || generatorYieldType;
51794                             var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2, returnType, (functionFlags_1 & 2) !== 0) || unknownType;
51795                             var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2));
51796                             checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeNode);
51797                         }
51798                     }
51799                     else if ((functionFlags_1 & 3) === 2) {
51800                         checkAsyncFunctionReturnType(node, returnTypeNode);
51801                     }
51802                 }
51803                 if (node.kind !== 167 && node.kind !== 300) {
51804                     registerForUnusedIdentifiersCheck(node);
51805                 }
51806             }
51807         }
51808         function checkClassForDuplicateDeclarations(node) {
51809             var instanceNames = ts.createUnderscoreEscapedMap();
51810             var staticNames = ts.createUnderscoreEscapedMap();
51811             var privateIdentifiers = ts.createUnderscoreEscapedMap();
51812             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
51813                 var member = _a[_i];
51814                 if (member.kind === 162) {
51815                     for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) {
51816                         var param = _c[_b];
51817                         if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) {
51818                             addName(instanceNames, param.name, param.name.escapedText, 3);
51819                         }
51820                     }
51821                 }
51822                 else {
51823                     var isStatic = ts.hasModifier(member, 32);
51824                     var name = member.name;
51825                     if (!name) {
51826                         return;
51827                     }
51828                     var names = ts.isPrivateIdentifier(name) ? privateIdentifiers :
51829                         isStatic ? staticNames :
51830                             instanceNames;
51831                     var memberName = name && ts.getPropertyNameForPropertyNameNode(name);
51832                     if (memberName) {
51833                         switch (member.kind) {
51834                             case 163:
51835                                 addName(names, name, memberName, 1);
51836                                 break;
51837                             case 164:
51838                                 addName(names, name, memberName, 2);
51839                                 break;
51840                             case 159:
51841                                 addName(names, name, memberName, 3);
51842                                 break;
51843                             case 161:
51844                                 addName(names, name, memberName, 8);
51845                                 break;
51846                         }
51847                     }
51848                 }
51849             }
51850             function addName(names, location, name, meaning) {
51851                 var prev = names.get(name);
51852                 if (prev) {
51853                     if (prev & 8) {
51854                         if (meaning !== 8) {
51855                             error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location));
51856                         }
51857                     }
51858                     else if (prev & meaning) {
51859                         error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location));
51860                     }
51861                     else {
51862                         names.set(name, prev | meaning);
51863                     }
51864                 }
51865                 else {
51866                     names.set(name, meaning);
51867                 }
51868             }
51869         }
51870         function checkClassForStaticPropertyNameConflicts(node) {
51871             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
51872                 var member = _a[_i];
51873                 var memberNameNode = member.name;
51874                 var isStatic = ts.hasModifier(member, 32);
51875                 if (isStatic && memberNameNode) {
51876                     var memberName = ts.getPropertyNameForPropertyNameNode(memberNameNode);
51877                     switch (memberName) {
51878                         case "name":
51879                         case "length":
51880                         case "caller":
51881                         case "arguments":
51882                         case "prototype":
51883                             var message = ts.Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1;
51884                             var className = getNameOfSymbolAsWritten(getSymbolOfNode(node));
51885                             error(memberNameNode, message, memberName, className);
51886                             break;
51887                     }
51888                 }
51889             }
51890         }
51891         function checkObjectTypeForDuplicateDeclarations(node) {
51892             var names = ts.createMap();
51893             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
51894                 var member = _a[_i];
51895                 if (member.kind === 158) {
51896                     var memberName = void 0;
51897                     var name = member.name;
51898                     switch (name.kind) {
51899                         case 10:
51900                         case 8:
51901                             memberName = name.text;
51902                             break;
51903                         case 75:
51904                             memberName = ts.idText(name);
51905                             break;
51906                         default:
51907                             continue;
51908                     }
51909                     if (names.get(memberName)) {
51910                         error(ts.getNameOfDeclaration(member.symbol.valueDeclaration), ts.Diagnostics.Duplicate_identifier_0, memberName);
51911                         error(member.name, ts.Diagnostics.Duplicate_identifier_0, memberName);
51912                     }
51913                     else {
51914                         names.set(memberName, true);
51915                     }
51916                 }
51917             }
51918         }
51919         function checkTypeForDuplicateIndexSignatures(node) {
51920             if (node.kind === 246) {
51921                 var nodeSymbol = getSymbolOfNode(node);
51922                 if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) {
51923                     return;
51924                 }
51925             }
51926             var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
51927             if (indexSymbol) {
51928                 var seenNumericIndexer = false;
51929                 var seenStringIndexer = false;
51930                 for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
51931                     var decl = _a[_i];
51932                     var declaration = decl;
51933                     if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
51934                         switch (declaration.parameters[0].type.kind) {
51935                             case 143:
51936                                 if (!seenStringIndexer) {
51937                                     seenStringIndexer = true;
51938                                 }
51939                                 else {
51940                                     error(declaration, ts.Diagnostics.Duplicate_string_index_signature);
51941                                 }
51942                                 break;
51943                             case 140:
51944                                 if (!seenNumericIndexer) {
51945                                     seenNumericIndexer = true;
51946                                 }
51947                                 else {
51948                                     error(declaration, ts.Diagnostics.Duplicate_number_index_signature);
51949                                 }
51950                                 break;
51951                         }
51952                     }
51953                 }
51954             }
51955         }
51956         function checkPropertyDeclaration(node) {
51957             if (!checkGrammarDecoratorsAndModifiers(node) && !checkGrammarProperty(node))
51958                 checkGrammarComputedPropertyName(node.name);
51959             checkVariableLikeDeclaration(node);
51960             if (ts.isPrivateIdentifier(node.name) && languageVersion < 99) {
51961                 for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) {
51962                     getNodeLinks(lexicalScope).flags |= 67108864;
51963                 }
51964             }
51965         }
51966         function checkPropertySignature(node) {
51967             if (ts.isPrivateIdentifier(node.name)) {
51968                 error(node, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
51969             }
51970             return checkPropertyDeclaration(node);
51971         }
51972         function checkMethodDeclaration(node) {
51973             if (!checkGrammarMethod(node))
51974                 checkGrammarComputedPropertyName(node.name);
51975             if (ts.isPrivateIdentifier(node.name)) {
51976                 error(node, ts.Diagnostics.A_method_cannot_be_named_with_a_private_identifier);
51977             }
51978             checkFunctionOrMethodDeclaration(node);
51979             if (ts.hasModifier(node, 128) && node.kind === 161 && node.body) {
51980                 error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name));
51981             }
51982         }
51983         function checkConstructorDeclaration(node) {
51984             checkSignatureDeclaration(node);
51985             if (!checkGrammarConstructorTypeParameters(node))
51986                 checkGrammarConstructorTypeAnnotation(node);
51987             checkSourceElement(node.body);
51988             var symbol = getSymbolOfNode(node);
51989             var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind);
51990             if (node === firstDeclaration) {
51991                 checkFunctionOrConstructorSymbol(symbol);
51992             }
51993             if (ts.nodeIsMissing(node.body)) {
51994                 return;
51995             }
51996             if (!produceDiagnostics) {
51997                 return;
51998             }
51999             function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) {
52000                 if (ts.isPrivateIdentifierPropertyDeclaration(n)) {
52001                     return true;
52002                 }
52003                 return n.kind === 159 &&
52004                     !ts.hasModifier(n, 32) &&
52005                     !!n.initializer;
52006             }
52007             var containingClassDecl = node.parent;
52008             if (ts.getClassExtendsHeritageElement(containingClassDecl)) {
52009                 captureLexicalThis(node.parent, containingClassDecl);
52010                 var classExtendsNull = classDeclarationExtendsNull(containingClassDecl);
52011                 var superCall = getSuperCallInConstructor(node);
52012                 if (superCall) {
52013                     if (classExtendsNull) {
52014                         error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
52015                     }
52016                     var superCallShouldBeFirst = (compilerOptions.target !== 99 || !compilerOptions.useDefineForClassFields) &&
52017                         (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
52018                             ts.some(node.parameters, function (p) { return ts.hasModifier(p, 92); }));
52019                     if (superCallShouldBeFirst) {
52020                         var statements = node.body.statements;
52021                         var superCallStatement = void 0;
52022                         for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) {
52023                             var statement = statements_3[_i];
52024                             if (statement.kind === 226 && ts.isSuperCall(statement.expression)) {
52025                                 superCallStatement = statement;
52026                                 break;
52027                             }
52028                             if (!ts.isPrologueDirective(statement)) {
52029                                 break;
52030                             }
52031                         }
52032                         if (!superCallStatement) {
52033                             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);
52034                         }
52035                     }
52036                 }
52037                 else if (!classExtendsNull) {
52038                     error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call);
52039                 }
52040             }
52041         }
52042         function checkAccessorDeclaration(node) {
52043             if (produceDiagnostics) {
52044                 if (!checkGrammarFunctionLikeDeclaration(node) && !checkGrammarAccessor(node))
52045                     checkGrammarComputedPropertyName(node.name);
52046                 checkDecorators(node);
52047                 checkSignatureDeclaration(node);
52048                 if (node.kind === 163) {
52049                     if (!(node.flags & 8388608) && ts.nodeIsPresent(node.body) && (node.flags & 256)) {
52050                         if (!(node.flags & 512)) {
52051                             error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value);
52052                         }
52053                     }
52054                 }
52055                 if (node.name.kind === 154) {
52056                     checkComputedPropertyName(node.name);
52057                 }
52058                 if (ts.isPrivateIdentifier(node.name)) {
52059                     error(node.name, ts.Diagnostics.An_accessor_cannot_be_named_with_a_private_identifier);
52060                 }
52061                 if (!hasNonBindableDynamicName(node)) {
52062                     var otherKind = node.kind === 163 ? 164 : 163;
52063                     var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind);
52064                     if (otherAccessor) {
52065                         var nodeFlags = ts.getModifierFlags(node);
52066                         var otherFlags = ts.getModifierFlags(otherAccessor);
52067                         if ((nodeFlags & 28) !== (otherFlags & 28)) {
52068                             error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility);
52069                         }
52070                         if ((nodeFlags & 128) !== (otherFlags & 128)) {
52071                             error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract);
52072                         }
52073                         checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type);
52074                         checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type);
52075                     }
52076                 }
52077                 var returnType = getTypeOfAccessors(getSymbolOfNode(node));
52078                 if (node.kind === 163) {
52079                     checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType);
52080                 }
52081             }
52082             checkSourceElement(node.body);
52083         }
52084         function checkAccessorDeclarationTypesIdentical(first, second, getAnnotatedType, message) {
52085             var firstType = getAnnotatedType(first);
52086             var secondType = getAnnotatedType(second);
52087             if (firstType && secondType && !isTypeIdenticalTo(firstType, secondType)) {
52088                 error(first, message);
52089             }
52090         }
52091         function checkMissingDeclaration(node) {
52092             checkDecorators(node);
52093         }
52094         function getEffectiveTypeArguments(node, typeParameters) {
52095             return fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(node));
52096         }
52097         function checkTypeArgumentConstraints(node, typeParameters) {
52098             var typeArguments;
52099             var mapper;
52100             var result = true;
52101             for (var i = 0; i < typeParameters.length; i++) {
52102                 var constraint = getConstraintOfTypeParameter(typeParameters[i]);
52103                 if (constraint) {
52104                     if (!typeArguments) {
52105                         typeArguments = getEffectiveTypeArguments(node, typeParameters);
52106                         mapper = createTypeMapper(typeParameters, typeArguments);
52107                     }
52108                     result = result && checkTypeAssignableTo(typeArguments[i], instantiateType(constraint, mapper), node.typeArguments[i], ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
52109                 }
52110             }
52111             return result;
52112         }
52113         function getTypeParametersForTypeReference(node) {
52114             var type = getTypeFromTypeReference(node);
52115             if (type !== errorType) {
52116                 var symbol = getNodeLinks(node).resolvedSymbol;
52117                 if (symbol) {
52118                     return symbol.flags & 524288 && getSymbolLinks(symbol).typeParameters ||
52119                         (ts.getObjectFlags(type) & 4 ? type.target.localTypeParameters : undefined);
52120                 }
52121             }
52122             return undefined;
52123         }
52124         function checkTypeReferenceNode(node) {
52125             checkGrammarTypeArguments(node, node.typeArguments);
52126             if (node.kind === 169 && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) {
52127                 grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments);
52128             }
52129             ts.forEach(node.typeArguments, checkSourceElement);
52130             var type = getTypeFromTypeReference(node);
52131             if (type !== errorType) {
52132                 if (node.typeArguments && produceDiagnostics) {
52133                     var typeParameters = getTypeParametersForTypeReference(node);
52134                     if (typeParameters) {
52135                         checkTypeArgumentConstraints(node, typeParameters);
52136                     }
52137                 }
52138                 if (type.flags & 32 && getNodeLinks(node).resolvedSymbol.flags & 8) {
52139                     error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type));
52140                 }
52141             }
52142         }
52143         function getTypeArgumentConstraint(node) {
52144             var typeReferenceNode = ts.tryCast(node.parent, ts.isTypeReferenceType);
52145             if (!typeReferenceNode)
52146                 return undefined;
52147             var typeParameters = getTypeParametersForTypeReference(typeReferenceNode);
52148             var constraint = getConstraintOfTypeParameter(typeParameters[typeReferenceNode.typeArguments.indexOf(node)]);
52149             return constraint && instantiateType(constraint, createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReferenceNode, typeParameters)));
52150         }
52151         function checkTypeQuery(node) {
52152             getTypeFromTypeQueryNode(node);
52153         }
52154         function checkTypeLiteral(node) {
52155             ts.forEach(node.members, checkSourceElement);
52156             if (produceDiagnostics) {
52157                 var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
52158                 checkIndexConstraints(type);
52159                 checkTypeForDuplicateIndexSignatures(node);
52160                 checkObjectTypeForDuplicateDeclarations(node);
52161             }
52162         }
52163         function checkArrayType(node) {
52164             checkSourceElement(node.elementType);
52165         }
52166         function checkTupleType(node) {
52167             var elementTypes = node.elementTypes;
52168             var seenOptionalElement = false;
52169             for (var i = 0; i < elementTypes.length; i++) {
52170                 var e = elementTypes[i];
52171                 if (e.kind === 177) {
52172                     if (i !== elementTypes.length - 1) {
52173                         grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type);
52174                         break;
52175                     }
52176                     if (!isArrayType(getTypeFromTypeNode(e.type))) {
52177                         error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type);
52178                     }
52179                 }
52180                 else if (e.kind === 176) {
52181                     seenOptionalElement = true;
52182                 }
52183                 else if (seenOptionalElement) {
52184                     grammarErrorOnNode(e, ts.Diagnostics.A_required_element_cannot_follow_an_optional_element);
52185                     break;
52186                 }
52187             }
52188             ts.forEach(node.elementTypes, checkSourceElement);
52189         }
52190         function checkUnionOrIntersectionType(node) {
52191             ts.forEach(node.types, checkSourceElement);
52192         }
52193         function checkIndexedAccessIndexType(type, accessNode) {
52194             if (!(type.flags & 8388608)) {
52195                 return type;
52196             }
52197             var objectType = type.objectType;
52198             var indexType = type.indexType;
52199             if (isTypeAssignableTo(indexType, getIndexType(objectType, false))) {
52200                 if (accessNode.kind === 195 && ts.isAssignmentTarget(accessNode) &&
52201                     ts.getObjectFlags(objectType) & 32 && getMappedTypeModifiers(objectType) & 1) {
52202                     error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
52203                 }
52204                 return type;
52205             }
52206             var apparentObjectType = getApparentType(objectType);
52207             if (getIndexInfoOfType(apparentObjectType, 1) && isTypeAssignableToKind(indexType, 296)) {
52208                 return type;
52209             }
52210             if (isGenericObjectType(objectType)) {
52211                 var propertyName_1 = getPropertyNameFromIndex(indexType, accessNode);
52212                 if (propertyName_1) {
52213                     var propertySymbol = forEachType(apparentObjectType, function (t) { return getPropertyOfType(t, propertyName_1); });
52214                     if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24) {
52215                         error(accessNode, ts.Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, ts.unescapeLeadingUnderscores(propertyName_1));
52216                         return errorType;
52217                     }
52218                 }
52219             }
52220             error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType));
52221             return errorType;
52222         }
52223         function checkIndexedAccessType(node) {
52224             checkSourceElement(node.objectType);
52225             checkSourceElement(node.indexType);
52226             checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node);
52227         }
52228         function checkMappedType(node) {
52229             checkSourceElement(node.typeParameter);
52230             checkSourceElement(node.type);
52231             if (!node.type) {
52232                 reportImplicitAny(node, anyType);
52233             }
52234             var type = getTypeFromMappedTypeNode(node);
52235             var constraintType = getConstraintTypeFromMappedType(type);
52236             checkTypeAssignableTo(constraintType, keyofConstraintType, ts.getEffectiveConstraintOfTypeParameter(node.typeParameter));
52237         }
52238         function checkThisType(node) {
52239             getTypeFromThisTypeNode(node);
52240         }
52241         function checkTypeOperator(node) {
52242             checkGrammarTypeOperatorNode(node);
52243             checkSourceElement(node.type);
52244         }
52245         function checkConditionalType(node) {
52246             ts.forEachChild(node, checkSourceElement);
52247         }
52248         function checkInferType(node) {
52249             if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 180 && n.parent.extendsType === n; })) {
52250                 grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type);
52251             }
52252             checkSourceElement(node.typeParameter);
52253             registerForUnusedIdentifiersCheck(node);
52254         }
52255         function checkImportType(node) {
52256             checkSourceElement(node.argument);
52257             getTypeFromTypeNode(node);
52258         }
52259         function isPrivateWithinAmbient(node) {
52260             return (ts.hasModifier(node, 8) || ts.isPrivateIdentifierPropertyDeclaration(node)) && !!(node.flags & 8388608);
52261         }
52262         function getEffectiveDeclarationFlags(n, flagsToCheck) {
52263             var flags = ts.getCombinedModifierFlags(n);
52264             if (n.parent.kind !== 246 &&
52265                 n.parent.kind !== 245 &&
52266                 n.parent.kind !== 214 &&
52267                 n.flags & 8388608) {
52268                 if (!(flags & 2) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) {
52269                     flags |= 1;
52270                 }
52271                 flags |= 2;
52272             }
52273             return flags & flagsToCheck;
52274         }
52275         function checkFunctionOrConstructorSymbol(symbol) {
52276             if (!produceDiagnostics) {
52277                 return;
52278             }
52279             function getCanonicalOverload(overloads, implementation) {
52280                 var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent;
52281                 return implementationSharesContainerWithFirstOverload ? implementation : overloads[0];
52282             }
52283             function checkFlagAgreementBetweenOverloads(overloads, implementation, flagsToCheck, someOverloadFlags, allOverloadFlags) {
52284                 var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags;
52285                 if (someButNotAllOverloadFlags !== 0) {
52286                     var canonicalFlags_1 = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck);
52287                     ts.forEach(overloads, function (o) {
52288                         var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags_1;
52289                         if (deviation & 1) {
52290                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported);
52291                         }
52292                         else if (deviation & 2) {
52293                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient);
52294                         }
52295                         else if (deviation & (8 | 16)) {
52296                             error(ts.getNameOfDeclaration(o) || o, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected);
52297                         }
52298                         else if (deviation & 128) {
52299                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract);
52300                         }
52301                     });
52302                 }
52303             }
52304             function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) {
52305                 if (someHaveQuestionToken !== allHaveQuestionToken) {
52306                     var canonicalHasQuestionToken_1 = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation));
52307                     ts.forEach(overloads, function (o) {
52308                         var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken_1;
52309                         if (deviation) {
52310                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required);
52311                         }
52312                     });
52313                 }
52314             }
52315             var flagsToCheck = 1 | 2 | 8 | 16 | 128;
52316             var someNodeFlags = 0;
52317             var allNodeFlags = flagsToCheck;
52318             var someHaveQuestionToken = false;
52319             var allHaveQuestionToken = true;
52320             var hasOverloads = false;
52321             var bodyDeclaration;
52322             var lastSeenNonAmbientDeclaration;
52323             var previousDeclaration;
52324             var declarations = symbol.declarations;
52325             var isConstructor = (symbol.flags & 16384) !== 0;
52326             function reportImplementationExpectedError(node) {
52327                 if (node.name && ts.nodeIsMissing(node.name)) {
52328                     return;
52329                 }
52330                 var seen = false;
52331                 var subsequentNode = ts.forEachChild(node.parent, function (c) {
52332                     if (seen) {
52333                         return c;
52334                     }
52335                     else {
52336                         seen = c === node;
52337                     }
52338                 });
52339                 if (subsequentNode && subsequentNode.pos === node.end) {
52340                     if (subsequentNode.kind === node.kind) {
52341                         var errorNode_1 = subsequentNode.name || subsequentNode;
52342                         var subsequentName = subsequentNode.name;
52343                         if (node.name && subsequentName && (ts.isPrivateIdentifier(node.name) && ts.isPrivateIdentifier(subsequentName) && node.name.escapedText === subsequentName.escapedText ||
52344                             ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) ||
52345                             ts.isPropertyNameLiteral(node.name) && ts.isPropertyNameLiteral(subsequentName) &&
52346                                 ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) {
52347                             var reportError = (node.kind === 161 || node.kind === 160) &&
52348                                 ts.hasModifier(node, 32) !== ts.hasModifier(subsequentNode, 32);
52349                             if (reportError) {
52350                                 var diagnostic = ts.hasModifier(node, 32) ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static;
52351                                 error(errorNode_1, diagnostic);
52352                             }
52353                             return;
52354                         }
52355                         if (ts.nodeIsPresent(subsequentNode.body)) {
52356                             error(errorNode_1, ts.Diagnostics.Function_implementation_name_must_be_0, ts.declarationNameToString(node.name));
52357                             return;
52358                         }
52359                     }
52360                 }
52361                 var errorNode = node.name || node;
52362                 if (isConstructor) {
52363                     error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing);
52364                 }
52365                 else {
52366                     if (ts.hasModifier(node, 128)) {
52367                         error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive);
52368                     }
52369                     else {
52370                         error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration);
52371                     }
52372                 }
52373             }
52374             var duplicateFunctionDeclaration = false;
52375             var multipleConstructorImplementation = false;
52376             var hasNonAmbientClass = false;
52377             for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
52378                 var current = declarations_4[_i];
52379                 var node = current;
52380                 var inAmbientContext = node.flags & 8388608;
52381                 var inAmbientContextOrInterface = node.parent.kind === 246 || node.parent.kind === 173 || inAmbientContext;
52382                 if (inAmbientContextOrInterface) {
52383                     previousDeclaration = undefined;
52384                 }
52385                 if ((node.kind === 245 || node.kind === 214) && !inAmbientContext) {
52386                     hasNonAmbientClass = true;
52387                 }
52388                 if (node.kind === 244 || node.kind === 161 || node.kind === 160 || node.kind === 162) {
52389                     var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck);
52390                     someNodeFlags |= currentNodeFlags;
52391                     allNodeFlags &= currentNodeFlags;
52392                     someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node);
52393                     allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node);
52394                     if (ts.nodeIsPresent(node.body) && bodyDeclaration) {
52395                         if (isConstructor) {
52396                             multipleConstructorImplementation = true;
52397                         }
52398                         else {
52399                             duplicateFunctionDeclaration = true;
52400                         }
52401                     }
52402                     else if (previousDeclaration && previousDeclaration.parent === node.parent && previousDeclaration.end !== node.pos) {
52403                         reportImplementationExpectedError(previousDeclaration);
52404                     }
52405                     if (ts.nodeIsPresent(node.body)) {
52406                         if (!bodyDeclaration) {
52407                             bodyDeclaration = node;
52408                         }
52409                     }
52410                     else {
52411                         hasOverloads = true;
52412                     }
52413                     previousDeclaration = node;
52414                     if (!inAmbientContextOrInterface) {
52415                         lastSeenNonAmbientDeclaration = node;
52416                     }
52417                 }
52418             }
52419             if (multipleConstructorImplementation) {
52420                 ts.forEach(declarations, function (declaration) {
52421                     error(declaration, ts.Diagnostics.Multiple_constructor_implementations_are_not_allowed);
52422                 });
52423             }
52424             if (duplicateFunctionDeclaration) {
52425                 ts.forEach(declarations, function (declaration) {
52426                     error(ts.getNameOfDeclaration(declaration), ts.Diagnostics.Duplicate_function_implementation);
52427                 });
52428             }
52429             if (hasNonAmbientClass && !isConstructor && symbol.flags & 16) {
52430                 ts.forEach(declarations, function (declaration) {
52431                     addDuplicateDeclarationError(declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), declarations);
52432                 });
52433             }
52434             if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body &&
52435                 !ts.hasModifier(lastSeenNonAmbientDeclaration, 128) && !lastSeenNonAmbientDeclaration.questionToken) {
52436                 reportImplementationExpectedError(lastSeenNonAmbientDeclaration);
52437             }
52438             if (hasOverloads) {
52439                 checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags);
52440                 checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken);
52441                 if (bodyDeclaration) {
52442                     var signatures = getSignaturesOfSymbol(symbol);
52443                     var bodySignature = getSignatureFromDeclaration(bodyDeclaration);
52444                     for (var _a = 0, signatures_10 = signatures; _a < signatures_10.length; _a++) {
52445                         var signature = signatures_10[_a];
52446                         if (!isImplementationCompatibleWithOverload(bodySignature, signature)) {
52447                             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));
52448                             break;
52449                         }
52450                     }
52451                 }
52452             }
52453         }
52454         function checkExportsOnMergedDeclarations(node) {
52455             if (!produceDiagnostics) {
52456                 return;
52457             }
52458             var symbol = node.localSymbol;
52459             if (!symbol) {
52460                 symbol = getSymbolOfNode(node);
52461                 if (!symbol.exportSymbol) {
52462                     return;
52463                 }
52464             }
52465             if (ts.getDeclarationOfKind(symbol, node.kind) !== node) {
52466                 return;
52467             }
52468             var exportedDeclarationSpaces = 0;
52469             var nonExportedDeclarationSpaces = 0;
52470             var defaultExportedDeclarationSpaces = 0;
52471             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
52472                 var d = _a[_i];
52473                 var declarationSpaces = getDeclarationSpaces(d);
52474                 var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 | 512);
52475                 if (effectiveDeclarationFlags & 1) {
52476                     if (effectiveDeclarationFlags & 512) {
52477                         defaultExportedDeclarationSpaces |= declarationSpaces;
52478                     }
52479                     else {
52480                         exportedDeclarationSpaces |= declarationSpaces;
52481                     }
52482                 }
52483                 else {
52484                     nonExportedDeclarationSpaces |= declarationSpaces;
52485                 }
52486             }
52487             var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces;
52488             var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces;
52489             var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces;
52490             if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) {
52491                 for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) {
52492                     var d = _c[_b];
52493                     var declarationSpaces = getDeclarationSpaces(d);
52494                     var name = ts.getNameOfDeclaration(d);
52495                     if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) {
52496                         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));
52497                     }
52498                     else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) {
52499                         error(name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(name));
52500                     }
52501                 }
52502             }
52503             function getDeclarationSpaces(decl) {
52504                 var d = decl;
52505                 switch (d.kind) {
52506                     case 246:
52507                     case 247:
52508                     case 322:
52509                     case 315:
52510                     case 316:
52511                         return 2;
52512                     case 249:
52513                         return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0
52514                             ? 4 | 1
52515                             : 4;
52516                     case 245:
52517                     case 248:
52518                     case 284:
52519                         return 2 | 1;
52520                     case 290:
52521                         return 2 | 1 | 4;
52522                     case 259:
52523                         if (!ts.isEntityNameExpression(d.expression)) {
52524                             return 1;
52525                         }
52526                         d = d.expression;
52527                     case 253:
52528                     case 256:
52529                     case 255:
52530                         var result_10 = 0;
52531                         var target = resolveAlias(getSymbolOfNode(d));
52532                         ts.forEach(target.declarations, function (d) { result_10 |= getDeclarationSpaces(d); });
52533                         return result_10;
52534                     case 242:
52535                     case 191:
52536                     case 244:
52537                     case 258:
52538                     case 75:
52539                         return 1;
52540                     default:
52541                         return ts.Debug.failBadSyntaxKind(d);
52542                 }
52543             }
52544         }
52545         function getAwaitedTypeOfPromise(type, errorNode, diagnosticMessage, arg0) {
52546             var promisedType = getPromisedTypeOfPromise(type, errorNode);
52547             return promisedType && getAwaitedType(promisedType, errorNode, diagnosticMessage, arg0);
52548         }
52549         function getPromisedTypeOfPromise(type, errorNode) {
52550             if (isTypeAny(type)) {
52551                 return undefined;
52552             }
52553             var typeAsPromise = type;
52554             if (typeAsPromise.promisedTypeOfPromise) {
52555                 return typeAsPromise.promisedTypeOfPromise;
52556             }
52557             if (isReferenceToType(type, getGlobalPromiseType(false))) {
52558                 return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0];
52559             }
52560             var thenFunction = getTypeOfPropertyOfType(type, "then");
52561             if (isTypeAny(thenFunction)) {
52562                 return undefined;
52563             }
52564             var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0) : ts.emptyArray;
52565             if (thenSignatures.length === 0) {
52566                 if (errorNode) {
52567                     error(errorNode, ts.Diagnostics.A_promise_must_have_a_then_method);
52568                 }
52569                 return undefined;
52570             }
52571             var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152);
52572             if (isTypeAny(onfulfilledParameterType)) {
52573                 return undefined;
52574             }
52575             var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0);
52576             if (onfulfilledParameterSignatures.length === 0) {
52577                 if (errorNode) {
52578                     error(errorNode, ts.Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback);
52579                 }
52580                 return undefined;
52581             }
52582             return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2);
52583         }
52584         function checkAwaitedType(type, errorNode, diagnosticMessage, arg0) {
52585             var awaitedType = getAwaitedType(type, errorNode, diagnosticMessage, arg0);
52586             return awaitedType || errorType;
52587         }
52588         function isThenableType(type) {
52589             var thenFunction = getTypeOfPropertyOfType(type, "then");
52590             return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152), 0).length > 0;
52591         }
52592         function getAwaitedType(type, errorNode, diagnosticMessage, arg0) {
52593             if (isTypeAny(type)) {
52594                 return type;
52595             }
52596             var typeAsAwaitable = type;
52597             if (typeAsAwaitable.awaitedTypeOfType) {
52598                 return typeAsAwaitable.awaitedTypeOfType;
52599             }
52600             return typeAsAwaitable.awaitedTypeOfType =
52601                 mapType(type, errorNode ? function (constituentType) { return getAwaitedTypeWorker(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeWorker);
52602         }
52603         function getAwaitedTypeWorker(type, errorNode, diagnosticMessage, arg0) {
52604             var typeAsAwaitable = type;
52605             if (typeAsAwaitable.awaitedTypeOfType) {
52606                 return typeAsAwaitable.awaitedTypeOfType;
52607             }
52608             var promisedType = getPromisedTypeOfPromise(type);
52609             if (promisedType) {
52610                 if (type.id === promisedType.id || awaitedTypeStack.lastIndexOf(promisedType.id) >= 0) {
52611                     if (errorNode) {
52612                         error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method);
52613                     }
52614                     return undefined;
52615                 }
52616                 awaitedTypeStack.push(type.id);
52617                 var awaitedType = getAwaitedType(promisedType, errorNode, diagnosticMessage, arg0);
52618                 awaitedTypeStack.pop();
52619                 if (!awaitedType) {
52620                     return undefined;
52621                 }
52622                 return typeAsAwaitable.awaitedTypeOfType = awaitedType;
52623             }
52624             if (isThenableType(type)) {
52625                 if (errorNode) {
52626                     if (!diagnosticMessage)
52627                         return ts.Debug.fail();
52628                     error(errorNode, diagnosticMessage, arg0);
52629                 }
52630                 return undefined;
52631             }
52632             return typeAsAwaitable.awaitedTypeOfType = type;
52633         }
52634         function checkAsyncFunctionReturnType(node, returnTypeNode) {
52635             var returnType = getTypeFromTypeNode(returnTypeNode);
52636             if (languageVersion >= 2) {
52637                 if (returnType === errorType) {
52638                     return;
52639                 }
52640                 var globalPromiseType = getGlobalPromiseType(true);
52641                 if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) {
52642                     error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type);
52643                     return;
52644                 }
52645             }
52646             else {
52647                 markTypeNodeAsReferenced(returnTypeNode);
52648                 if (returnType === errorType) {
52649                     return;
52650                 }
52651                 var promiseConstructorName = ts.getEntityNameFromTypeNode(returnTypeNode);
52652                 if (promiseConstructorName === undefined) {
52653                     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));
52654                     return;
52655                 }
52656                 var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551, true);
52657                 var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType;
52658                 if (promiseConstructorType === errorType) {
52659                     if (promiseConstructorName.kind === 75 && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(false)) {
52660                         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);
52661                     }
52662                     else {
52663                         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));
52664                     }
52665                     return;
52666                 }
52667                 var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(true);
52668                 if (globalPromiseConstructorLikeType === emptyObjectType) {
52669                     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));
52670                     return;
52671                 }
52672                 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)) {
52673                     return;
52674                 }
52675                 var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName);
52676                 var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551);
52677                 if (collidingSymbol) {
52678                     error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName));
52679                     return;
52680                 }
52681             }
52682             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);
52683         }
52684         function checkDecorator(node) {
52685             var signature = getResolvedSignature(node);
52686             var returnType = getReturnTypeOfSignature(signature);
52687             if (returnType.flags & 1) {
52688                 return;
52689             }
52690             var expectedReturnType;
52691             var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
52692             var errorInfo;
52693             switch (node.parent.kind) {
52694                 case 245:
52695                     var classSymbol = getSymbolOfNode(node.parent);
52696                     var classConstructorType = getTypeOfSymbol(classSymbol);
52697                     expectedReturnType = getUnionType([classConstructorType, voidType]);
52698                     break;
52699                 case 156:
52700                     expectedReturnType = voidType;
52701                     errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any);
52702                     break;
52703                 case 159:
52704                     expectedReturnType = voidType;
52705                     errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any);
52706                     break;
52707                 case 161:
52708                 case 163:
52709                 case 164:
52710                     var methodType = getTypeOfNode(node.parent);
52711                     var descriptorType = createTypedPropertyDescriptorType(methodType);
52712                     expectedReturnType = getUnionType([descriptorType, voidType]);
52713                     break;
52714                 default:
52715                     return ts.Debug.fail();
52716             }
52717             checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, function () { return errorInfo; });
52718         }
52719         function markTypeNodeAsReferenced(node) {
52720             markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node));
52721         }
52722         function markEntityNameOrEntityExpressionAsReference(typeName) {
52723             if (!typeName)
52724                 return;
52725             var rootName = ts.getFirstIdentifier(typeName);
52726             var meaning = (typeName.kind === 75 ? 788968 : 1920) | 2097152;
52727             var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, undefined, undefined, true);
52728             if (rootSymbol
52729                 && rootSymbol.flags & 2097152
52730                 && symbolIsValue(rootSymbol)
52731                 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))
52732                 && !getTypeOnlyAliasDeclaration(rootSymbol)) {
52733                 markAliasSymbolAsReferenced(rootSymbol);
52734             }
52735         }
52736         function markDecoratorMedataDataTypeNodeAsReferenced(node) {
52737             var entityName = getEntityNameForDecoratorMetadata(node);
52738             if (entityName && ts.isEntityName(entityName)) {
52739                 markEntityNameOrEntityExpressionAsReference(entityName);
52740             }
52741         }
52742         function getEntityNameForDecoratorMetadata(node) {
52743             if (node) {
52744                 switch (node.kind) {
52745                     case 179:
52746                     case 178:
52747                         return getEntityNameForDecoratorMetadataFromTypeList(node.types);
52748                     case 180:
52749                         return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]);
52750                     case 182:
52751                         return getEntityNameForDecoratorMetadata(node.type);
52752                     case 169:
52753                         return node.typeName;
52754                 }
52755             }
52756         }
52757         function getEntityNameForDecoratorMetadataFromTypeList(types) {
52758             var commonEntityName;
52759             for (var _i = 0, types_20 = types; _i < types_20.length; _i++) {
52760                 var typeNode = types_20[_i];
52761                 while (typeNode.kind === 182) {
52762                     typeNode = typeNode.type;
52763                 }
52764                 if (typeNode.kind === 137) {
52765                     continue;
52766                 }
52767                 if (!strictNullChecks && (typeNode.kind === 100 || typeNode.kind === 146)) {
52768                     continue;
52769                 }
52770                 var individualEntityName = getEntityNameForDecoratorMetadata(typeNode);
52771                 if (!individualEntityName) {
52772                     return undefined;
52773                 }
52774                 if (commonEntityName) {
52775                     if (!ts.isIdentifier(commonEntityName) ||
52776                         !ts.isIdentifier(individualEntityName) ||
52777                         commonEntityName.escapedText !== individualEntityName.escapedText) {
52778                         return undefined;
52779                     }
52780                 }
52781                 else {
52782                     commonEntityName = individualEntityName;
52783                 }
52784             }
52785             return commonEntityName;
52786         }
52787         function getParameterTypeNodeForDecoratorCheck(node) {
52788             var typeNode = ts.getEffectiveTypeAnnotationNode(node);
52789             return ts.isRestParameter(node) ? ts.getRestParameterElementType(typeNode) : typeNode;
52790         }
52791         function checkDecorators(node) {
52792             if (!node.decorators) {
52793                 return;
52794             }
52795             if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) {
52796                 return;
52797             }
52798             if (!compilerOptions.experimentalDecorators) {
52799                 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);
52800             }
52801             var firstDecorator = node.decorators[0];
52802             checkExternalEmitHelpers(firstDecorator, 8);
52803             if (node.kind === 156) {
52804                 checkExternalEmitHelpers(firstDecorator, 32);
52805             }
52806             if (compilerOptions.emitDecoratorMetadata) {
52807                 checkExternalEmitHelpers(firstDecorator, 16);
52808                 switch (node.kind) {
52809                     case 245:
52810                         var constructor = ts.getFirstConstructorWithBody(node);
52811                         if (constructor) {
52812                             for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) {
52813                                 var parameter = _a[_i];
52814                                 markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
52815                             }
52816                         }
52817                         break;
52818                     case 163:
52819                     case 164:
52820                         var otherKind = node.kind === 163 ? 164 : 163;
52821                         var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind);
52822                         markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor));
52823                         break;
52824                     case 161:
52825                         for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) {
52826                             var parameter = _c[_b];
52827                             markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
52828                         }
52829                         markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node));
52830                         break;
52831                     case 159:
52832                         markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node));
52833                         break;
52834                     case 156:
52835                         markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node));
52836                         var containingSignature = node.parent;
52837                         for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) {
52838                             var parameter = _e[_d];
52839                             markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
52840                         }
52841                         break;
52842                 }
52843             }
52844             ts.forEach(node.decorators, checkDecorator);
52845         }
52846         function checkFunctionDeclaration(node) {
52847             if (produceDiagnostics) {
52848                 checkFunctionOrMethodDeclaration(node);
52849                 checkGrammarForGenerator(node);
52850                 checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
52851                 checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
52852             }
52853         }
52854         function checkJSDocTypeAliasTag(node) {
52855             if (!node.typeExpression) {
52856                 error(node.name, ts.Diagnostics.JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags);
52857             }
52858             if (node.name) {
52859                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0);
52860             }
52861             checkSourceElement(node.typeExpression);
52862         }
52863         function checkJSDocTemplateTag(node) {
52864             checkSourceElement(node.constraint);
52865             for (var _i = 0, _a = node.typeParameters; _i < _a.length; _i++) {
52866                 var tp = _a[_i];
52867                 checkSourceElement(tp);
52868             }
52869         }
52870         function checkJSDocTypeTag(node) {
52871             checkSourceElement(node.typeExpression);
52872         }
52873         function checkJSDocParameterTag(node) {
52874             checkSourceElement(node.typeExpression);
52875             if (!ts.getParameterSymbolFromJSDoc(node)) {
52876                 var decl = ts.getHostSignatureFromJSDoc(node);
52877                 if (decl) {
52878                     var i = ts.getJSDocTags(decl).filter(ts.isJSDocParameterTag).indexOf(node);
52879                     if (i > -1 && i < decl.parameters.length && ts.isBindingPattern(decl.parameters[i].name)) {
52880                         return;
52881                     }
52882                     if (!containsArgumentsReference(decl)) {
52883                         if (ts.isQualifiedName(node.name)) {
52884                             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));
52885                         }
52886                         else {
52887                             error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name));
52888                         }
52889                     }
52890                     else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node &&
52891                         node.typeExpression && node.typeExpression.type &&
52892                         !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) {
52893                         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));
52894                     }
52895                 }
52896             }
52897         }
52898         function checkJSDocPropertyTag(node) {
52899             checkSourceElement(node.typeExpression);
52900         }
52901         function checkJSDocFunctionType(node) {
52902             if (produceDiagnostics && !node.type && !ts.isJSDocConstructSignature(node)) {
52903                 reportImplicitAny(node, anyType);
52904             }
52905             checkSignatureDeclaration(node);
52906         }
52907         function checkJSDocImplementsTag(node) {
52908             var classLike = ts.getEffectiveJSDocHost(node);
52909             if (!classLike || !ts.isClassDeclaration(classLike) && !ts.isClassExpression(classLike)) {
52910                 error(classLike, ts.Diagnostics.JSDoc_0_is_not_attached_to_a_class, ts.idText(node.tagName));
52911             }
52912         }
52913         function checkJSDocAugmentsTag(node) {
52914             var classLike = ts.getEffectiveJSDocHost(node);
52915             if (!classLike || !ts.isClassDeclaration(classLike) && !ts.isClassExpression(classLike)) {
52916                 error(classLike, ts.Diagnostics.JSDoc_0_is_not_attached_to_a_class, ts.idText(node.tagName));
52917                 return;
52918             }
52919             var augmentsTags = ts.getJSDocTags(classLike).filter(ts.isJSDocAugmentsTag);
52920             ts.Debug.assert(augmentsTags.length > 0);
52921             if (augmentsTags.length > 1) {
52922                 error(augmentsTags[1], ts.Diagnostics.Class_declarations_cannot_have_more_than_one_augments_or_extends_tag);
52923             }
52924             var name = getIdentifierFromEntityNameExpression(node.class.expression);
52925             var extend = ts.getClassExtendsHeritageElement(classLike);
52926             if (extend) {
52927                 var className = getIdentifierFromEntityNameExpression(extend.expression);
52928                 if (className && name.escapedText !== className.escapedText) {
52929                     error(name, ts.Diagnostics.JSDoc_0_1_does_not_match_the_extends_2_clause, ts.idText(node.tagName), ts.idText(name), ts.idText(className));
52930                 }
52931             }
52932         }
52933         function getIdentifierFromEntityNameExpression(node) {
52934             switch (node.kind) {
52935                 case 75:
52936                     return node;
52937                 case 194:
52938                     return node.name;
52939                 default:
52940                     return undefined;
52941             }
52942         }
52943         function checkFunctionOrMethodDeclaration(node) {
52944             checkDecorators(node);
52945             checkSignatureDeclaration(node);
52946             var functionFlags = ts.getFunctionFlags(node);
52947             if (node.name && node.name.kind === 154) {
52948                 checkComputedPropertyName(node.name);
52949             }
52950             if (!hasNonBindableDynamicName(node)) {
52951                 var symbol = getSymbolOfNode(node);
52952                 var localSymbol = node.localSymbol || symbol;
52953                 var firstDeclaration = ts.find(localSymbol.declarations, function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072); });
52954                 if (node === firstDeclaration) {
52955                     checkFunctionOrConstructorSymbol(localSymbol);
52956                 }
52957                 if (symbol.parent) {
52958                     if (ts.getDeclarationOfKind(symbol, node.kind) === node) {
52959                         checkFunctionOrConstructorSymbol(symbol);
52960                     }
52961                 }
52962             }
52963             var body = node.kind === 160 ? undefined : node.body;
52964             checkSourceElement(body);
52965             checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node));
52966             if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) {
52967                 if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) {
52968                     reportImplicitAny(node, anyType);
52969                 }
52970                 if (functionFlags & 1 && ts.nodeIsPresent(body)) {
52971                     getReturnTypeOfSignature(getSignatureFromDeclaration(node));
52972                 }
52973             }
52974             if (ts.isInJSFile(node)) {
52975                 var typeTag = ts.getJSDocTypeTag(node);
52976                 if (typeTag && typeTag.typeExpression && !getContextualCallSignature(getTypeFromTypeNode(typeTag.typeExpression), node)) {
52977                     error(typeTag, ts.Diagnostics.The_type_of_a_function_declaration_must_match_the_function_s_signature);
52978                 }
52979             }
52980         }
52981         function registerForUnusedIdentifiersCheck(node) {
52982             if (produceDiagnostics) {
52983                 var sourceFile = ts.getSourceFileOfNode(node);
52984                 var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path);
52985                 if (!potentiallyUnusedIdentifiers) {
52986                     potentiallyUnusedIdentifiers = [];
52987                     allPotentiallyUnusedIdentifiers.set(sourceFile.path, potentiallyUnusedIdentifiers);
52988                 }
52989                 potentiallyUnusedIdentifiers.push(node);
52990             }
52991         }
52992         function checkUnusedIdentifiers(potentiallyUnusedIdentifiers, addDiagnostic) {
52993             for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) {
52994                 var node = potentiallyUnusedIdentifiers_1[_i];
52995                 switch (node.kind) {
52996                     case 245:
52997                     case 214:
52998                         checkUnusedClassMembers(node, addDiagnostic);
52999                         checkUnusedTypeParameters(node, addDiagnostic);
53000                         break;
53001                     case 290:
53002                     case 249:
53003                     case 223:
53004                     case 251:
53005                     case 230:
53006                     case 231:
53007                     case 232:
53008                         checkUnusedLocalsAndParameters(node, addDiagnostic);
53009                         break;
53010                     case 162:
53011                     case 201:
53012                     case 244:
53013                     case 202:
53014                     case 161:
53015                     case 163:
53016                     case 164:
53017                         if (node.body) {
53018                             checkUnusedLocalsAndParameters(node, addDiagnostic);
53019                         }
53020                         checkUnusedTypeParameters(node, addDiagnostic);
53021                         break;
53022                     case 160:
53023                     case 165:
53024                     case 166:
53025                     case 170:
53026                     case 171:
53027                     case 247:
53028                     case 246:
53029                         checkUnusedTypeParameters(node, addDiagnostic);
53030                         break;
53031                     case 181:
53032                         checkUnusedInferTypeParameter(node, addDiagnostic);
53033                         break;
53034                     default:
53035                         ts.Debug.assertNever(node, "Node should not have been registered for unused identifiers check");
53036                 }
53037             }
53038         }
53039         function errorUnusedLocal(declaration, name, addDiagnostic) {
53040             var node = ts.getNameOfDeclaration(declaration) || declaration;
53041             var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
53042             addDiagnostic(declaration, 0, ts.createDiagnosticForNode(node, message, name));
53043         }
53044         function isIdentifierThatStartsWithUnderscore(node) {
53045             return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95;
53046         }
53047         function checkUnusedClassMembers(node, addDiagnostic) {
53048             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
53049                 var member = _a[_i];
53050                 switch (member.kind) {
53051                     case 161:
53052                     case 159:
53053                     case 163:
53054                     case 164:
53055                         if (member.kind === 164 && member.symbol.flags & 32768) {
53056                             break;
53057                         }
53058                         var symbol = getSymbolOfNode(member);
53059                         if (!symbol.isReferenced
53060                             && (ts.hasModifier(member, 8) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name))
53061                             && !(member.flags & 8388608)) {
53062                             addDiagnostic(member, 0, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol)));
53063                         }
53064                         break;
53065                     case 162:
53066                         for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) {
53067                             var parameter = _c[_b];
53068                             if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8)) {
53069                                 addDiagnostic(parameter, 0, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol)));
53070                             }
53071                         }
53072                         break;
53073                     case 167:
53074                     case 222:
53075                         break;
53076                     default:
53077                         ts.Debug.fail();
53078                 }
53079             }
53080         }
53081         function checkUnusedInferTypeParameter(node, addDiagnostic) {
53082             var typeParameter = node.typeParameter;
53083             if (isTypeParameterUnused(typeParameter)) {
53084                 addDiagnostic(node, 1, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name)));
53085             }
53086         }
53087         function checkUnusedTypeParameters(node, addDiagnostic) {
53088             if (ts.last(getSymbolOfNode(node).declarations) !== node)
53089                 return;
53090             var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
53091             var seenParentsWithEveryUnused = new ts.NodeSet();
53092             for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) {
53093                 var typeParameter = typeParameters_3[_i];
53094                 if (!isTypeParameterUnused(typeParameter))
53095                     continue;
53096                 var name = ts.idText(typeParameter.name);
53097                 var parent = typeParameter.parent;
53098                 if (parent.kind !== 181 && parent.typeParameters.every(isTypeParameterUnused)) {
53099                     if (seenParentsWithEveryUnused.tryAdd(parent)) {
53100                         var range = ts.isJSDocTemplateTag(parent)
53101                             ? ts.rangeOfNode(parent)
53102                             : ts.rangeOfTypeParameters(parent.typeParameters);
53103                         var only = parent.typeParameters.length === 1;
53104                         var message = only ? ts.Diagnostics._0_is_declared_but_its_value_is_never_read : ts.Diagnostics.All_type_parameters_are_unused;
53105                         var arg0 = only ? name : undefined;
53106                         addDiagnostic(typeParameter, 1, ts.createFileDiagnostic(ts.getSourceFileOfNode(parent), range.pos, range.end - range.pos, message, arg0));
53107                     }
53108                 }
53109                 else {
53110                     addDiagnostic(typeParameter, 1, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name));
53111                 }
53112             }
53113         }
53114         function isTypeParameterUnused(typeParameter) {
53115             return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144) && !isIdentifierThatStartsWithUnderscore(typeParameter.name);
53116         }
53117         function addToGroup(map, key, value, getKey) {
53118             var keyString = String(getKey(key));
53119             var group = map.get(keyString);
53120             if (group) {
53121                 group[1].push(value);
53122             }
53123             else {
53124                 map.set(keyString, [key, [value]]);
53125             }
53126         }
53127         function tryGetRootParameterDeclaration(node) {
53128             return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter);
53129         }
53130         function isValidUnusedLocalDeclaration(declaration) {
53131             if (ts.isBindingElement(declaration) && isIdentifierThatStartsWithUnderscore(declaration.name)) {
53132                 return !!ts.findAncestor(declaration.parent, function (ancestor) {
53133                     return ts.isArrayBindingPattern(ancestor) || ts.isVariableDeclaration(ancestor) || ts.isVariableDeclarationList(ancestor) ? false :
53134                         ts.isForOfStatement(ancestor) ? true : "quit";
53135                 });
53136             }
53137             return ts.isAmbientModule(declaration) ||
53138                 (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name);
53139         }
53140         function checkUnusedLocalsAndParameters(nodeWithLocals, addDiagnostic) {
53141             var unusedImports = ts.createMap();
53142             var unusedDestructures = ts.createMap();
53143             var unusedVariables = ts.createMap();
53144             nodeWithLocals.locals.forEach(function (local) {
53145                 if (local.flags & 262144 ? !(local.flags & 3 && !(local.isReferenced & 3)) : local.isReferenced || local.exportSymbol) {
53146                     return;
53147                 }
53148                 for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) {
53149                     var declaration = _a[_i];
53150                     if (isValidUnusedLocalDeclaration(declaration)) {
53151                         continue;
53152                     }
53153                     if (isImportedDeclaration(declaration)) {
53154                         addToGroup(unusedImports, importClauseFromImported(declaration), declaration, getNodeId);
53155                     }
53156                     else if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent)) {
53157                         var lastElement = ts.last(declaration.parent.elements);
53158                         if (declaration === lastElement || !ts.last(declaration.parent.elements).dotDotDotToken) {
53159                             addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId);
53160                         }
53161                     }
53162                     else if (ts.isVariableDeclaration(declaration)) {
53163                         addToGroup(unusedVariables, declaration.parent, declaration, getNodeId);
53164                     }
53165                     else {
53166                         var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration);
53167                         var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration);
53168                         if (parameter && name) {
53169                             if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) {
53170                                 addDiagnostic(parameter, 1, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local)));
53171                             }
53172                         }
53173                         else {
53174                             errorUnusedLocal(declaration, ts.symbolName(local), addDiagnostic);
53175                         }
53176                     }
53177                 }
53178             });
53179             unusedImports.forEach(function (_a) {
53180                 var importClause = _a[0], unuseds = _a[1];
53181                 var importDecl = importClause.parent;
53182                 var nDeclarations = (importClause.name ? 1 : 0) +
53183                     (importClause.namedBindings ?
53184                         (importClause.namedBindings.kind === 256 ? 1 : importClause.namedBindings.elements.length)
53185                         : 0);
53186                 if (nDeclarations === unuseds.length) {
53187                     addDiagnostic(importDecl, 0, unuseds.length === 1
53188                         ? ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name))
53189                         : ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused));
53190                 }
53191                 else {
53192                     for (var _i = 0, unuseds_1 = unuseds; _i < unuseds_1.length; _i++) {
53193                         var unused = unuseds_1[_i];
53194                         errorUnusedLocal(unused, ts.idText(unused.name), addDiagnostic);
53195                     }
53196                 }
53197             });
53198             unusedDestructures.forEach(function (_a) {
53199                 var bindingPattern = _a[0], bindingElements = _a[1];
53200                 var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 : 0;
53201                 if (bindingPattern.elements.length === bindingElements.length) {
53202                     if (bindingElements.length === 1 && bindingPattern.parent.kind === 242 && bindingPattern.parent.parent.kind === 243) {
53203                         addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId);
53204                     }
53205                     else {
53206                         addDiagnostic(bindingPattern, kind, bindingElements.length === 1
53207                             ? ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(bindingElements).name))
53208                             : ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics.All_destructured_elements_are_unused));
53209                     }
53210                 }
53211                 else {
53212                     for (var _i = 0, bindingElements_1 = bindingElements; _i < bindingElements_1.length; _i++) {
53213                         var e = bindingElements_1[_i];
53214                         addDiagnostic(e, kind, ts.createDiagnosticForNode(e, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(e.name)));
53215                     }
53216                 }
53217             });
53218             unusedVariables.forEach(function (_a) {
53219                 var declarationList = _a[0], declarations = _a[1];
53220                 if (declarationList.declarations.length === declarations.length) {
53221                     addDiagnostic(declarationList, 0, declarations.length === 1
53222                         ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name))
53223                         : ts.createDiagnosticForNode(declarationList.parent.kind === 225 ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused));
53224                 }
53225                 else {
53226                     for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
53227                         var decl = declarations_5[_i];
53228                         addDiagnostic(decl, 0, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name)));
53229                     }
53230                 }
53231             });
53232         }
53233         function bindingNameText(name) {
53234             switch (name.kind) {
53235                 case 75:
53236                     return ts.idText(name);
53237                 case 190:
53238                 case 189:
53239                     return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name);
53240                 default:
53241                     return ts.Debug.assertNever(name);
53242             }
53243         }
53244         function isImportedDeclaration(node) {
53245             return node.kind === 255 || node.kind === 258 || node.kind === 256;
53246         }
53247         function importClauseFromImported(decl) {
53248             return decl.kind === 255 ? decl : decl.kind === 256 ? decl.parent : decl.parent.parent;
53249         }
53250         function checkBlock(node) {
53251             if (node.kind === 223) {
53252                 checkGrammarStatementInAmbientContext(node);
53253             }
53254             if (ts.isFunctionOrModuleBlock(node)) {
53255                 var saveFlowAnalysisDisabled = flowAnalysisDisabled;
53256                 ts.forEach(node.statements, checkSourceElement);
53257                 flowAnalysisDisabled = saveFlowAnalysisDisabled;
53258             }
53259             else {
53260                 ts.forEach(node.statements, checkSourceElement);
53261             }
53262             if (node.locals) {
53263                 registerForUnusedIdentifiersCheck(node);
53264             }
53265         }
53266         function checkCollisionWithArgumentsInGeneratedCode(node) {
53267             if (languageVersion >= 2 || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 8388608 || ts.nodeIsMissing(node.body)) {
53268                 return;
53269             }
53270             ts.forEach(node.parameters, function (p) {
53271                 if (p.name && !ts.isBindingPattern(p.name) && p.name.escapedText === argumentsSymbol.escapedName) {
53272                     error(p, ts.Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters);
53273                 }
53274             });
53275         }
53276         function needCollisionCheckForIdentifier(node, identifier, name) {
53277             if (!(identifier && identifier.escapedText === name)) {
53278                 return false;
53279             }
53280             if (node.kind === 159 ||
53281                 node.kind === 158 ||
53282                 node.kind === 161 ||
53283                 node.kind === 160 ||
53284                 node.kind === 163 ||
53285                 node.kind === 164) {
53286                 return false;
53287             }
53288             if (node.flags & 8388608) {
53289                 return false;
53290             }
53291             var root = ts.getRootDeclaration(node);
53292             if (root.kind === 156 && ts.nodeIsMissing(root.parent.body)) {
53293                 return false;
53294             }
53295             return true;
53296         }
53297         function checkIfThisIsCapturedInEnclosingScope(node) {
53298             ts.findAncestor(node, function (current) {
53299                 if (getNodeCheckFlags(current) & 4) {
53300                     var isDeclaration_1 = node.kind !== 75;
53301                     if (isDeclaration_1) {
53302                         error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference);
53303                     }
53304                     else {
53305                         error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference);
53306                     }
53307                     return true;
53308                 }
53309                 return false;
53310             });
53311         }
53312         function checkIfNewTargetIsCapturedInEnclosingScope(node) {
53313             ts.findAncestor(node, function (current) {
53314                 if (getNodeCheckFlags(current) & 8) {
53315                     var isDeclaration_2 = node.kind !== 75;
53316                     if (isDeclaration_2) {
53317                         error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference);
53318                     }
53319                     else {
53320                         error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference);
53321                     }
53322                     return true;
53323                 }
53324                 return false;
53325             });
53326         }
53327         function checkWeakMapCollision(node) {
53328             var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node);
53329             if (getNodeCheckFlags(enclosingBlockScope) & 67108864) {
53330                 error(node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, "WeakMap");
53331             }
53332         }
53333         function checkCollisionWithRequireExportsInGeneratedCode(node, name) {
53334             if (moduleKind >= ts.ModuleKind.ES2015 || compilerOptions.noEmit) {
53335                 return;
53336             }
53337             if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
53338                 return;
53339             }
53340             if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1) {
53341                 return;
53342             }
53343             var parent = getDeclarationContainer(node);
53344             if (parent.kind === 290 && ts.isExternalOrCommonJsModule(parent)) {
53345                 error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name));
53346             }
53347         }
53348         function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) {
53349             if (languageVersion >= 4 || compilerOptions.noEmit || !needCollisionCheckForIdentifier(node, name, "Promise")) {
53350                 return;
53351             }
53352             if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1) {
53353                 return;
53354             }
53355             var parent = getDeclarationContainer(node);
53356             if (parent.kind === 290 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048) {
53357                 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));
53358             }
53359         }
53360         function checkVarDeclaredNamesNotShadowed(node) {
53361             if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) {
53362                 return;
53363             }
53364             if (node.kind === 242 && !node.initializer) {
53365                 return;
53366             }
53367             var symbol = getSymbolOfNode(node);
53368             if (symbol.flags & 1) {
53369                 if (!ts.isIdentifier(node.name))
53370                     return ts.Debug.fail();
53371                 var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3, undefined, undefined, false);
53372                 if (localDeclarationSymbol &&
53373                     localDeclarationSymbol !== symbol &&
53374                     localDeclarationSymbol.flags & 2) {
53375                     if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) {
53376                         var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 243);
53377                         var container = varDeclList.parent.kind === 225 && varDeclList.parent.parent
53378                             ? varDeclList.parent.parent
53379                             : undefined;
53380                         var namesShareScope = container &&
53381                             (container.kind === 223 && ts.isFunctionLike(container.parent) ||
53382                                 container.kind === 250 ||
53383                                 container.kind === 249 ||
53384                                 container.kind === 290);
53385                         if (!namesShareScope) {
53386                             var name = symbolToString(localDeclarationSymbol);
53387                             error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name);
53388                         }
53389                     }
53390                 }
53391             }
53392         }
53393         function convertAutoToAny(type) {
53394             return type === autoType ? anyType : type === autoArrayType ? anyArrayType : type;
53395         }
53396         function checkVariableLikeDeclaration(node) {
53397             checkDecorators(node);
53398             if (!ts.isBindingElement(node)) {
53399                 checkSourceElement(node.type);
53400             }
53401             if (!node.name) {
53402                 return;
53403             }
53404             if (node.name.kind === 154) {
53405                 checkComputedPropertyName(node.name);
53406                 if (node.initializer) {
53407                     checkExpressionCached(node.initializer);
53408                 }
53409             }
53410             if (node.kind === 191) {
53411                 if (node.parent.kind === 189 && languageVersion < 99) {
53412                     checkExternalEmitHelpers(node, 4);
53413                 }
53414                 if (node.propertyName && node.propertyName.kind === 154) {
53415                     checkComputedPropertyName(node.propertyName);
53416                 }
53417                 var parent = node.parent.parent;
53418                 var parentType = getTypeForBindingElementParent(parent);
53419                 var name = node.propertyName || node.name;
53420                 if (parentType && !ts.isBindingPattern(name)) {
53421                     var exprType = getLiteralTypeFromPropertyName(name);
53422                     if (isTypeUsableAsPropertyName(exprType)) {
53423                         var nameText = getPropertyNameFromType(exprType);
53424                         var property = getPropertyOfType(parentType, nameText);
53425                         if (property) {
53426                             markPropertyAsReferenced(property, undefined, false);
53427                             checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 102, parentType, property);
53428                         }
53429                     }
53430                 }
53431             }
53432             if (ts.isBindingPattern(node.name)) {
53433                 if (node.name.kind === 190 && languageVersion < 2 && compilerOptions.downlevelIteration) {
53434                     checkExternalEmitHelpers(node, 512);
53435                 }
53436                 ts.forEach(node.name.elements, checkSourceElement);
53437             }
53438             if (node.initializer && ts.getRootDeclaration(node).kind === 156 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
53439                 error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation);
53440                 return;
53441             }
53442             if (ts.isBindingPattern(node.name)) {
53443                 var needCheckInitializer = node.initializer && node.parent.parent.kind !== 231;
53444                 var needCheckWidenedType = node.name.elements.length === 0;
53445                 if (needCheckInitializer || needCheckWidenedType) {
53446                     var widenedType = getWidenedTypeForVariableLikeDeclaration(node);
53447                     if (needCheckInitializer) {
53448                         var initializerType = checkExpressionCached(node.initializer);
53449                         if (strictNullChecks && needCheckWidenedType) {
53450                             checkNonNullNonVoidType(initializerType, node);
53451                         }
53452                         else {
53453                             checkTypeAssignableToAndOptionallyElaborate(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, node.initializer);
53454                         }
53455                     }
53456                     if (needCheckWidenedType) {
53457                         if (ts.isArrayBindingPattern(node.name)) {
53458                             checkIteratedTypeOrElementType(65, widenedType, undefinedType, node);
53459                         }
53460                         else if (strictNullChecks) {
53461                             checkNonNullNonVoidType(widenedType, node);
53462                         }
53463                     }
53464                 }
53465                 return;
53466             }
53467             var symbol = getSymbolOfNode(node);
53468             var type = convertAutoToAny(getTypeOfSymbol(symbol));
53469             if (node === symbol.valueDeclaration) {
53470                 var initializer = ts.getEffectiveInitializer(node);
53471                 if (initializer) {
53472                     var isJSObjectLiteralInitializer = ts.isInJSFile(node) &&
53473                         ts.isObjectLiteralExpression(initializer) &&
53474                         (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) &&
53475                         ts.hasEntries(symbol.exports);
53476                     if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 231) {
53477                         checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, undefined);
53478                     }
53479                 }
53480                 if (symbol.declarations.length > 1) {
53481                     if (ts.some(symbol.declarations, function (d) { return d !== node && ts.isVariableLike(d) && !areDeclarationFlagsIdentical(d, node); })) {
53482                         error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name));
53483                     }
53484                 }
53485             }
53486             else {
53487                 var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node));
53488                 if (type !== errorType && declarationType !== errorType &&
53489                     !isTypeIdenticalTo(type, declarationType) &&
53490                     !(symbol.flags & 67108864)) {
53491                     errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType);
53492                 }
53493                 if (node.initializer) {
53494                     checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, undefined);
53495                 }
53496                 if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) {
53497                     error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name));
53498                 }
53499             }
53500             if (node.kind !== 159 && node.kind !== 158) {
53501                 checkExportsOnMergedDeclarations(node);
53502                 if (node.kind === 242 || node.kind === 191) {
53503                     checkVarDeclaredNamesNotShadowed(node);
53504                 }
53505                 checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
53506                 checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
53507                 if (!compilerOptions.noEmit && languageVersion < 99 && needCollisionCheckForIdentifier(node, node.name, "WeakMap")) {
53508                     potentialWeakMapCollisions.push(node);
53509                 }
53510             }
53511         }
53512         function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) {
53513             var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration);
53514             var message = nextDeclaration.kind === 159 || nextDeclaration.kind === 158
53515                 ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2
53516                 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2;
53517             var declName = ts.declarationNameToString(nextDeclarationName);
53518             var err = error(nextDeclarationName, message, declName, typeToString(firstType), typeToString(nextType));
53519             if (firstDeclaration) {
53520                 ts.addRelatedInfo(err, ts.createDiagnosticForNode(firstDeclaration, ts.Diagnostics._0_was_also_declared_here, declName));
53521             }
53522         }
53523         function areDeclarationFlagsIdentical(left, right) {
53524             if ((left.kind === 156 && right.kind === 242) ||
53525                 (left.kind === 242 && right.kind === 156)) {
53526                 return true;
53527             }
53528             if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) {
53529                 return false;
53530             }
53531             var interestingFlags = 8 |
53532                 16 |
53533                 256 |
53534                 128 |
53535                 64 |
53536                 32;
53537             return ts.getSelectedModifierFlags(left, interestingFlags) === ts.getSelectedModifierFlags(right, interestingFlags);
53538         }
53539         function checkVariableDeclaration(node) {
53540             checkGrammarVariableDeclaration(node);
53541             return checkVariableLikeDeclaration(node);
53542         }
53543         function checkBindingElement(node) {
53544             checkGrammarBindingElement(node);
53545             return checkVariableLikeDeclaration(node);
53546         }
53547         function checkVariableStatement(node) {
53548             if (!checkGrammarDecoratorsAndModifiers(node) && !checkGrammarVariableDeclarationList(node.declarationList))
53549                 checkGrammarForDisallowedLetOrConstStatement(node);
53550             ts.forEach(node.declarationList.declarations, checkSourceElement);
53551         }
53552         function checkExpressionStatement(node) {
53553             checkGrammarStatementInAmbientContext(node);
53554             checkExpression(node.expression);
53555         }
53556         function checkIfStatement(node) {
53557             checkGrammarStatementInAmbientContext(node);
53558             var type = checkTruthinessExpression(node.expression);
53559             checkTestingKnownTruthyCallableType(node.expression, node.thenStatement, type);
53560             checkSourceElement(node.thenStatement);
53561             if (node.thenStatement.kind === 224) {
53562                 error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement);
53563             }
53564             checkSourceElement(node.elseStatement);
53565         }
53566         function checkTestingKnownTruthyCallableType(condExpr, body, type) {
53567             if (!strictNullChecks) {
53568                 return;
53569             }
53570             var testedNode = ts.isIdentifier(condExpr)
53571                 ? condExpr
53572                 : ts.isPropertyAccessExpression(condExpr)
53573                     ? condExpr.name
53574                     : undefined;
53575             if (!testedNode) {
53576                 return;
53577             }
53578             var possiblyFalsy = getFalsyFlags(type);
53579             if (possiblyFalsy) {
53580                 return;
53581             }
53582             var callSignatures = getSignaturesOfType(type, 0);
53583             if (callSignatures.length === 0) {
53584                 return;
53585             }
53586             var testedFunctionSymbol = getSymbolAtLocation(testedNode);
53587             if (!testedFunctionSymbol) {
53588                 return;
53589             }
53590             var functionIsUsedInBody = ts.forEachChild(body, function check(childNode) {
53591                 if (ts.isIdentifier(childNode)) {
53592                     var childSymbol = getSymbolAtLocation(childNode);
53593                     if (childSymbol && childSymbol === testedFunctionSymbol) {
53594                         if (ts.isIdentifier(condExpr)) {
53595                             return true;
53596                         }
53597                         var testedExpression = testedNode.parent;
53598                         var childExpression = childNode.parent;
53599                         while (testedExpression && childExpression) {
53600                             if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) ||
53601                                 testedExpression.kind === 104 && childExpression.kind === 104) {
53602                                 return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression);
53603                             }
53604                             if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) {
53605                                 if (getSymbolAtLocation(testedExpression.name) !== getSymbolAtLocation(childExpression.name)) {
53606                                     return false;
53607                                 }
53608                                 childExpression = childExpression.expression;
53609                                 testedExpression = testedExpression.expression;
53610                             }
53611                             else {
53612                                 return false;
53613                             }
53614                         }
53615                     }
53616                 }
53617                 return ts.forEachChild(childNode, check);
53618             });
53619             if (!functionIsUsedInBody) {
53620                 error(condExpr, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead);
53621             }
53622         }
53623         function checkDoStatement(node) {
53624             checkGrammarStatementInAmbientContext(node);
53625             checkSourceElement(node.statement);
53626             checkTruthinessExpression(node.expression);
53627         }
53628         function checkWhileStatement(node) {
53629             checkGrammarStatementInAmbientContext(node);
53630             checkTruthinessExpression(node.expression);
53631             checkSourceElement(node.statement);
53632         }
53633         function checkTruthinessOfType(type, node) {
53634             if (type.flags & 16384) {
53635                 error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness);
53636             }
53637             return type;
53638         }
53639         function checkTruthinessExpression(node, checkMode) {
53640             return checkTruthinessOfType(checkExpression(node, checkMode), node);
53641         }
53642         function checkForStatement(node) {
53643             if (!checkGrammarStatementInAmbientContext(node)) {
53644                 if (node.initializer && node.initializer.kind === 243) {
53645                     checkGrammarVariableDeclarationList(node.initializer);
53646                 }
53647             }
53648             if (node.initializer) {
53649                 if (node.initializer.kind === 243) {
53650                     ts.forEach(node.initializer.declarations, checkVariableDeclaration);
53651                 }
53652                 else {
53653                     checkExpression(node.initializer);
53654                 }
53655             }
53656             if (node.condition)
53657                 checkTruthinessExpression(node.condition);
53658             if (node.incrementor)
53659                 checkExpression(node.incrementor);
53660             checkSourceElement(node.statement);
53661             if (node.locals) {
53662                 registerForUnusedIdentifiersCheck(node);
53663             }
53664         }
53665         function checkForOfStatement(node) {
53666             checkGrammarForInOrForOfStatement(node);
53667             if (node.awaitModifier) {
53668                 var functionFlags = ts.getFunctionFlags(ts.getContainingFunction(node));
53669                 if ((functionFlags & (4 | 2)) === 2 && languageVersion < 99) {
53670                     checkExternalEmitHelpers(node, 32768);
53671                 }
53672             }
53673             else if (compilerOptions.downlevelIteration && languageVersion < 2) {
53674                 checkExternalEmitHelpers(node, 256);
53675             }
53676             if (node.initializer.kind === 243) {
53677                 checkForInOrForOfVariableDeclaration(node);
53678             }
53679             else {
53680                 var varExpr = node.initializer;
53681                 var iteratedType = checkRightHandSideOfForOf(node);
53682                 if (varExpr.kind === 192 || varExpr.kind === 193) {
53683                     checkDestructuringAssignment(varExpr, iteratedType || errorType);
53684                 }
53685                 else {
53686                     var leftType = checkExpression(varExpr);
53687                     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);
53688                     if (iteratedType) {
53689                         checkTypeAssignableToAndOptionallyElaborate(iteratedType, leftType, varExpr, node.expression);
53690                     }
53691                 }
53692             }
53693             checkSourceElement(node.statement);
53694             if (node.locals) {
53695                 registerForUnusedIdentifiersCheck(node);
53696             }
53697         }
53698         function checkForInStatement(node) {
53699             checkGrammarForInOrForOfStatement(node);
53700             var rightType = getNonNullableTypeIfNeeded(checkExpression(node.expression));
53701             if (node.initializer.kind === 243) {
53702                 var variable = node.initializer.declarations[0];
53703                 if (variable && ts.isBindingPattern(variable.name)) {
53704                     error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern);
53705                 }
53706                 checkForInOrForOfVariableDeclaration(node);
53707             }
53708             else {
53709                 var varExpr = node.initializer;
53710                 var leftType = checkExpression(varExpr);
53711                 if (varExpr.kind === 192 || varExpr.kind === 193) {
53712                     error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern);
53713                 }
53714                 else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) {
53715                     error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any);
53716                 }
53717                 else {
53718                     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);
53719                 }
53720             }
53721             if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 | 58982400)) {
53722                 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));
53723             }
53724             checkSourceElement(node.statement);
53725             if (node.locals) {
53726                 registerForUnusedIdentifiersCheck(node);
53727             }
53728         }
53729         function checkForInOrForOfVariableDeclaration(iterationStatement) {
53730             var variableDeclarationList = iterationStatement.initializer;
53731             if (variableDeclarationList.declarations.length >= 1) {
53732                 var decl = variableDeclarationList.declarations[0];
53733                 checkVariableDeclaration(decl);
53734             }
53735         }
53736         function checkRightHandSideOfForOf(statement) {
53737             var use = statement.awaitModifier ? 15 : 13;
53738             return checkIteratedTypeOrElementType(use, checkNonNullExpression(statement.expression), undefinedType, statement.expression);
53739         }
53740         function checkIteratedTypeOrElementType(use, inputType, sentType, errorNode) {
53741             if (isTypeAny(inputType)) {
53742                 return inputType;
53743             }
53744             return getIteratedTypeOrElementType(use, inputType, sentType, errorNode, true) || anyType;
53745         }
53746         function getIteratedTypeOrElementType(use, inputType, sentType, errorNode, checkAssignability) {
53747             var allowAsyncIterables = (use & 2) !== 0;
53748             if (inputType === neverType) {
53749                 reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables);
53750                 return undefined;
53751             }
53752             var uplevelIteration = languageVersion >= 2;
53753             var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration;
53754             if (uplevelIteration || downlevelIteration || allowAsyncIterables) {
53755                 var iterationTypes = getIterationTypesOfIterable(inputType, use, uplevelIteration ? errorNode : undefined);
53756                 if (checkAssignability) {
53757                     if (iterationTypes) {
53758                         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 :
53759                             use & 32 ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 :
53760                                 use & 64 ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 :
53761                                     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 :
53762                                         undefined;
53763                         if (diagnostic) {
53764                             checkTypeAssignableTo(sentType, iterationTypes.nextType, errorNode, diagnostic);
53765                         }
53766                     }
53767                 }
53768                 if (iterationTypes || uplevelIteration) {
53769                     return iterationTypes && iterationTypes.yieldType;
53770                 }
53771             }
53772             var arrayType = inputType;
53773             var reportedError = false;
53774             var hasStringConstituent = false;
53775             if (use & 4) {
53776                 if (arrayType.flags & 1048576) {
53777                     var arrayTypes = inputType.types;
53778                     var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 132); });
53779                     if (filteredTypes !== arrayTypes) {
53780                         arrayType = getUnionType(filteredTypes, 2);
53781                     }
53782                 }
53783                 else if (arrayType.flags & 132) {
53784                     arrayType = neverType;
53785                 }
53786                 hasStringConstituent = arrayType !== inputType;
53787                 if (hasStringConstituent) {
53788                     if (languageVersion < 1) {
53789                         if (errorNode) {
53790                             error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher);
53791                             reportedError = true;
53792                         }
53793                     }
53794                     if (arrayType.flags & 131072) {
53795                         return stringType;
53796                     }
53797                 }
53798             }
53799             if (!isArrayLikeType(arrayType)) {
53800                 if (errorNode && !reportedError) {
53801                     var yieldType = getIterationTypeOfIterable(use, 0, inputType, undefined);
53802                     var _a = !(use & 4) || hasStringConstituent
53803                         ? downlevelIteration
53804                             ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]
53805                             : yieldType
53806                                 ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]
53807                                 : [ts.Diagnostics.Type_0_is_not_an_array_type, true]
53808                         : downlevelIteration
53809                             ? [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]
53810                             : yieldType
53811                                 ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]
53812                                 : [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true], defaultDiagnostic = _a[0], maybeMissingAwait = _a[1];
53813                     errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType));
53814                 }
53815                 return hasStringConstituent ? stringType : undefined;
53816             }
53817             var arrayElementType = getIndexTypeOfType(arrayType, 1);
53818             if (hasStringConstituent && arrayElementType) {
53819                 if (arrayElementType.flags & 132) {
53820                     return stringType;
53821                 }
53822                 return getUnionType([arrayElementType, stringType], 2);
53823             }
53824             return arrayElementType;
53825         }
53826         function getIterationTypeOfIterable(use, typeKind, inputType, errorNode) {
53827             if (isTypeAny(inputType)) {
53828                 return undefined;
53829             }
53830             var iterationTypes = getIterationTypesOfIterable(inputType, use, errorNode);
53831             return iterationTypes && iterationTypes[getIterationTypesKeyFromIterationTypeKind(typeKind)];
53832         }
53833         function createIterationTypes(yieldType, returnType, nextType) {
53834             if (yieldType === void 0) { yieldType = neverType; }
53835             if (returnType === void 0) { returnType = neverType; }
53836             if (nextType === void 0) { nextType = unknownType; }
53837             if (yieldType.flags & 67359327 &&
53838                 returnType.flags & (1 | 131072 | 2 | 16384 | 32768) &&
53839                 nextType.flags & (1 | 131072 | 2 | 16384 | 32768)) {
53840                 var id = getTypeListId([yieldType, returnType, nextType]);
53841                 var iterationTypes = iterationTypesCache.get(id);
53842                 if (!iterationTypes) {
53843                     iterationTypes = { yieldType: yieldType, returnType: returnType, nextType: nextType };
53844                     iterationTypesCache.set(id, iterationTypes);
53845                 }
53846                 return iterationTypes;
53847             }
53848             return { yieldType: yieldType, returnType: returnType, nextType: nextType };
53849         }
53850         function combineIterationTypes(array) {
53851             var yieldTypes;
53852             var returnTypes;
53853             var nextTypes;
53854             for (var _i = 0, array_10 = array; _i < array_10.length; _i++) {
53855                 var iterationTypes = array_10[_i];
53856                 if (iterationTypes === undefined || iterationTypes === noIterationTypes) {
53857                     continue;
53858                 }
53859                 if (iterationTypes === anyIterationTypes) {
53860                     return anyIterationTypes;
53861                 }
53862                 yieldTypes = ts.append(yieldTypes, iterationTypes.yieldType);
53863                 returnTypes = ts.append(returnTypes, iterationTypes.returnType);
53864                 nextTypes = ts.append(nextTypes, iterationTypes.nextType);
53865             }
53866             if (yieldTypes || returnTypes || nextTypes) {
53867                 return createIterationTypes(yieldTypes && getUnionType(yieldTypes), returnTypes && getUnionType(returnTypes), nextTypes && getIntersectionType(nextTypes));
53868             }
53869             return noIterationTypes;
53870         }
53871         function getCachedIterationTypes(type, cacheKey) {
53872             return type[cacheKey];
53873         }
53874         function setCachedIterationTypes(type, cacheKey, cachedTypes) {
53875             return type[cacheKey] = cachedTypes;
53876         }
53877         function getIterationTypesOfIterable(type, use, errorNode) {
53878             if (isTypeAny(type)) {
53879                 return anyIterationTypes;
53880             }
53881             if (!(type.flags & 1048576)) {
53882                 var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode);
53883                 if (iterationTypes_1 === noIterationTypes) {
53884                     if (errorNode) {
53885                         reportTypeNotIterableError(errorNode, type, !!(use & 2));
53886                     }
53887                     return undefined;
53888                 }
53889                 return iterationTypes_1;
53890             }
53891             var cacheKey = use & 2 ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable";
53892             var cachedTypes = getCachedIterationTypes(type, cacheKey);
53893             if (cachedTypes)
53894                 return cachedTypes === noIterationTypes ? undefined : cachedTypes;
53895             var allIterationTypes;
53896             for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
53897                 var constituent = _a[_i];
53898                 var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode);
53899                 if (iterationTypes_2 === noIterationTypes) {
53900                     if (errorNode) {
53901                         reportTypeNotIterableError(errorNode, type, !!(use & 2));
53902                         errorNode = undefined;
53903                     }
53904                 }
53905                 else {
53906                     allIterationTypes = ts.append(allIterationTypes, iterationTypes_2);
53907                 }
53908             }
53909             var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes;
53910             setCachedIterationTypes(type, cacheKey, iterationTypes);
53911             return iterationTypes === noIterationTypes ? undefined : iterationTypes;
53912         }
53913         function getAsyncFromSyncIterationTypes(iterationTypes, errorNode) {
53914             if (iterationTypes === noIterationTypes)
53915                 return noIterationTypes;
53916             if (iterationTypes === anyIterationTypes)
53917                 return anyIterationTypes;
53918             var yieldType = iterationTypes.yieldType, returnType = iterationTypes.returnType, nextType = iterationTypes.nextType;
53919             return createIterationTypes(getAwaitedType(yieldType, errorNode) || anyType, getAwaitedType(returnType, errorNode) || anyType, nextType);
53920         }
53921         function getIterationTypesOfIterableWorker(type, use, errorNode) {
53922             if (isTypeAny(type)) {
53923                 return anyIterationTypes;
53924             }
53925             if (use & 2) {
53926                 var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) ||
53927                     getIterationTypesOfIterableFast(type, asyncIterationTypesResolver);
53928                 if (iterationTypes) {
53929                     return iterationTypes;
53930                 }
53931             }
53932             if (use & 1) {
53933                 var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) ||
53934                     getIterationTypesOfIterableFast(type, syncIterationTypesResolver);
53935                 if (iterationTypes) {
53936                     if (use & 2) {
53937                         if (iterationTypes !== noIterationTypes) {
53938                             return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode));
53939                         }
53940                     }
53941                     else {
53942                         return iterationTypes;
53943                     }
53944                 }
53945             }
53946             if (use & 2) {
53947                 var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode);
53948                 if (iterationTypes !== noIterationTypes) {
53949                     return iterationTypes;
53950                 }
53951             }
53952             if (use & 1) {
53953                 var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode);
53954                 if (iterationTypes !== noIterationTypes) {
53955                     if (use & 2) {
53956                         return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes
53957                             ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode)
53958                             : noIterationTypes);
53959                     }
53960                     else {
53961                         return iterationTypes;
53962                     }
53963                 }
53964             }
53965             return noIterationTypes;
53966         }
53967         function getIterationTypesOfIterableCached(type, resolver) {
53968             return getCachedIterationTypes(type, resolver.iterableCacheKey);
53969         }
53970         function getIterationTypesOfGlobalIterableType(globalType, resolver) {
53971             var globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) ||
53972                 getIterationTypesOfIterableSlow(globalType, resolver, undefined);
53973             return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes;
53974         }
53975         function getIterationTypesOfIterableFast(type, resolver) {
53976             var globalType;
53977             if (isReferenceToType(type, globalType = resolver.getGlobalIterableType(false)) ||
53978                 isReferenceToType(type, globalType = resolver.getGlobalIterableIteratorType(false))) {
53979                 var yieldType = getTypeArguments(type)[0];
53980                 var _a = getIterationTypesOfGlobalIterableType(globalType, resolver), returnType = _a.returnType, nextType = _a.nextType;
53981                 return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(yieldType, returnType, nextType));
53982             }
53983             if (isReferenceToType(type, resolver.getGlobalGeneratorType(false))) {
53984                 var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2];
53985                 return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(yieldType, returnType, nextType));
53986             }
53987         }
53988         function getIterationTypesOfIterableSlow(type, resolver, errorNode) {
53989             var _a;
53990             var method = getPropertyOfType(type, ts.getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName));
53991             var methodType = method && !(method.flags & 16777216) ? getTypeOfSymbol(method) : undefined;
53992             if (isTypeAny(methodType)) {
53993                 return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
53994             }
53995             var signatures = methodType ? getSignaturesOfType(methodType, 0) : undefined;
53996             if (!ts.some(signatures)) {
53997                 return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
53998             }
53999             var iteratorType = getUnionType(ts.map(signatures, getReturnTypeOfSignature), 2);
54000             var iterationTypes = (_a = getIterationTypesOfIterator(iteratorType, resolver, errorNode)) !== null && _a !== void 0 ? _a : noIterationTypes;
54001             return setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
54002         }
54003         function reportTypeNotIterableError(errorNode, type, allowAsyncIterables) {
54004             var message = allowAsyncIterables
54005                 ? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
54006                 : ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
54007             errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
54008         }
54009         function getIterationTypesOfIterator(type, resolver, errorNode) {
54010             if (isTypeAny(type)) {
54011                 return anyIterationTypes;
54012             }
54013             var iterationTypes = getIterationTypesOfIteratorCached(type, resolver) ||
54014                 getIterationTypesOfIteratorFast(type, resolver) ||
54015                 getIterationTypesOfIteratorSlow(type, resolver, errorNode);
54016             return iterationTypes === noIterationTypes ? undefined : iterationTypes;
54017         }
54018         function getIterationTypesOfIteratorCached(type, resolver) {
54019             return getCachedIterationTypes(type, resolver.iteratorCacheKey);
54020         }
54021         function getIterationTypesOfIteratorFast(type, resolver) {
54022             var globalType = resolver.getGlobalIterableIteratorType(false);
54023             if (isReferenceToType(type, globalType)) {
54024                 var yieldType = getTypeArguments(type)[0];
54025                 var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) ||
54026                     getIterationTypesOfIteratorSlow(globalType, resolver, undefined);
54027                 var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType;
54028                 return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
54029             }
54030             if (isReferenceToType(type, resolver.getGlobalIteratorType(false)) ||
54031                 isReferenceToType(type, resolver.getGlobalGeneratorType(false))) {
54032                 var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2];
54033                 return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
54034             }
54035         }
54036         function isIteratorResult(type, kind) {
54037             var doneType = getTypeOfPropertyOfType(type, "done") || falseType;
54038             return isTypeAssignableTo(kind === 0 ? falseType : trueType, doneType);
54039         }
54040         function isYieldIteratorResult(type) {
54041             return isIteratorResult(type, 0);
54042         }
54043         function isReturnIteratorResult(type) {
54044             return isIteratorResult(type, 1);
54045         }
54046         function getIterationTypesOfIteratorResult(type) {
54047             if (isTypeAny(type)) {
54048                 return anyIterationTypes;
54049             }
54050             var cachedTypes = getCachedIterationTypes(type, "iterationTypesOfIteratorResult");
54051             if (cachedTypes) {
54052                 return cachedTypes;
54053             }
54054             if (isReferenceToType(type, getGlobalIteratorYieldResultType(false))) {
54055                 var yieldType_1 = getTypeArguments(type)[0];
54056                 return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(yieldType_1, undefined, undefined));
54057             }
54058             if (isReferenceToType(type, getGlobalIteratorReturnResultType(false))) {
54059                 var returnType_1 = getTypeArguments(type)[0];
54060                 return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(undefined, returnType_1, undefined));
54061             }
54062             var yieldIteratorResult = filterType(type, isYieldIteratorResult);
54063             var yieldType = yieldIteratorResult !== neverType ? getTypeOfPropertyOfType(yieldIteratorResult, "value") : undefined;
54064             var returnIteratorResult = filterType(type, isReturnIteratorResult);
54065             var returnType = returnIteratorResult !== neverType ? getTypeOfPropertyOfType(returnIteratorResult, "value") : undefined;
54066             if (!yieldType && !returnType) {
54067                 return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", noIterationTypes);
54068             }
54069             return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(yieldType, returnType || voidType, undefined));
54070         }
54071         function getIterationTypesOfMethod(type, resolver, methodName, errorNode) {
54072             var method = getPropertyOfType(type, methodName);
54073             if (!method && methodName !== "next") {
54074                 return undefined;
54075             }
54076             var methodType = method && !(methodName === "next" && (method.flags & 16777216))
54077                 ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152)
54078                 : undefined;
54079             if (isTypeAny(methodType)) {
54080                 return methodName === "next" ? anyIterationTypes : anyIterationTypesExceptNext;
54081             }
54082             var methodSignatures = methodType ? getSignaturesOfType(methodType, 0) : ts.emptyArray;
54083             if (methodSignatures.length === 0) {
54084                 if (errorNode) {
54085                     var diagnostic = methodName === "next"
54086                         ? resolver.mustHaveANextMethodDiagnostic
54087                         : resolver.mustBeAMethodDiagnostic;
54088                     error(errorNode, diagnostic, methodName);
54089                 }
54090                 return methodName === "next" ? anyIterationTypes : undefined;
54091             }
54092             var methodParameterTypes;
54093             var methodReturnTypes;
54094             for (var _i = 0, methodSignatures_1 = methodSignatures; _i < methodSignatures_1.length; _i++) {
54095                 var signature = methodSignatures_1[_i];
54096                 if (methodName !== "throw" && ts.some(signature.parameters)) {
54097                     methodParameterTypes = ts.append(methodParameterTypes, getTypeAtPosition(signature, 0));
54098                 }
54099                 methodReturnTypes = ts.append(methodReturnTypes, getReturnTypeOfSignature(signature));
54100             }
54101             var returnTypes;
54102             var nextType;
54103             if (methodName !== "throw") {
54104                 var methodParameterType = methodParameterTypes ? getUnionType(methodParameterTypes) : unknownType;
54105                 if (methodName === "next") {
54106                     nextType = methodParameterType;
54107                 }
54108                 else if (methodName === "return") {
54109                     var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType;
54110                     returnTypes = ts.append(returnTypes, resolvedMethodParameterType);
54111                 }
54112             }
54113             var yieldType;
54114             var methodReturnType = methodReturnTypes ? getUnionType(methodReturnTypes, 2) : neverType;
54115             var resolvedMethodReturnType = resolver.resolveIterationType(methodReturnType, errorNode) || anyType;
54116             var iterationTypes = getIterationTypesOfIteratorResult(resolvedMethodReturnType);
54117             if (iterationTypes === noIterationTypes) {
54118                 if (errorNode) {
54119                     error(errorNode, resolver.mustHaveAValueDiagnostic, methodName);
54120                 }
54121                 yieldType = anyType;
54122                 returnTypes = ts.append(returnTypes, anyType);
54123             }
54124             else {
54125                 yieldType = iterationTypes.yieldType;
54126                 returnTypes = ts.append(returnTypes, iterationTypes.returnType);
54127             }
54128             return createIterationTypes(yieldType, getUnionType(returnTypes), nextType);
54129         }
54130         function getIterationTypesOfIteratorSlow(type, resolver, errorNode) {
54131             var iterationTypes = combineIterationTypes([
54132                 getIterationTypesOfMethod(type, resolver, "next", errorNode),
54133                 getIterationTypesOfMethod(type, resolver, "return", errorNode),
54134                 getIterationTypesOfMethod(type, resolver, "throw", errorNode),
54135             ]);
54136             return setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
54137         }
54138         function getIterationTypeOfGeneratorFunctionReturnType(kind, returnType, isAsyncGenerator) {
54139             if (isTypeAny(returnType)) {
54140                 return undefined;
54141             }
54142             var iterationTypes = getIterationTypesOfGeneratorFunctionReturnType(returnType, isAsyncGenerator);
54143             return iterationTypes && iterationTypes[getIterationTypesKeyFromIterationTypeKind(kind)];
54144         }
54145         function getIterationTypesOfGeneratorFunctionReturnType(type, isAsyncGenerator) {
54146             if (isTypeAny(type)) {
54147                 return anyIterationTypes;
54148             }
54149             var use = isAsyncGenerator ? 2 : 1;
54150             var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
54151             return getIterationTypesOfIterable(type, use, undefined) ||
54152                 getIterationTypesOfIterator(type, resolver, undefined);
54153         }
54154         function checkBreakOrContinueStatement(node) {
54155             if (!checkGrammarStatementInAmbientContext(node))
54156                 checkGrammarBreakOrContinueStatement(node);
54157         }
54158         function unwrapReturnType(returnType, functionFlags) {
54159             var _a, _b;
54160             var isGenerator = !!(functionFlags & 1);
54161             var isAsync = !!(functionFlags & 2);
54162             return isGenerator ? (_a = getIterationTypeOfGeneratorFunctionReturnType(1, returnType, isAsync)) !== null && _a !== void 0 ? _a : errorType :
54163                 isAsync ? (_b = getAwaitedType(returnType)) !== null && _b !== void 0 ? _b : errorType :
54164                     returnType;
54165         }
54166         function isUnwrappedReturnTypeVoidOrAny(func, returnType) {
54167             var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func));
54168             return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 | 3);
54169         }
54170         function checkReturnStatement(node) {
54171             var _a;
54172             if (checkGrammarStatementInAmbientContext(node)) {
54173                 return;
54174             }
54175             var func = ts.getContainingFunction(node);
54176             if (!func) {
54177                 grammarErrorOnFirstToken(node, ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body);
54178                 return;
54179             }
54180             var signature = getSignatureFromDeclaration(func);
54181             var returnType = getReturnTypeOfSignature(signature);
54182             var functionFlags = ts.getFunctionFlags(func);
54183             if (strictNullChecks || node.expression || returnType.flags & 131072) {
54184                 var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
54185                 if (func.kind === 164) {
54186                     if (node.expression) {
54187                         error(node, ts.Diagnostics.Setters_cannot_return_a_value);
54188                     }
54189                 }
54190                 else if (func.kind === 162) {
54191                     if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) {
54192                         error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
54193                     }
54194                 }
54195                 else if (getReturnTypeFromAnnotation(func)) {
54196                     var unwrappedReturnType = (_a = unwrapReturnType(returnType, functionFlags)) !== null && _a !== void 0 ? _a : returnType;
54197                     var unwrappedExprType = functionFlags & 2
54198                         ? 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)
54199                         : exprType;
54200                     if (unwrappedReturnType) {
54201                         checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, node, node.expression);
54202                     }
54203                 }
54204             }
54205             else if (func.kind !== 162 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) {
54206                 error(node, ts.Diagnostics.Not_all_code_paths_return_a_value);
54207             }
54208         }
54209         function checkWithStatement(node) {
54210             if (!checkGrammarStatementInAmbientContext(node)) {
54211                 if (node.flags & 32768) {
54212                     grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block);
54213                 }
54214             }
54215             checkExpression(node.expression);
54216             var sourceFile = ts.getSourceFileOfNode(node);
54217             if (!hasParseDiagnostics(sourceFile)) {
54218                 var start = ts.getSpanOfTokenAtPosition(sourceFile, node.pos).start;
54219                 var end = node.statement.pos;
54220                 grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any);
54221             }
54222         }
54223         function checkSwitchStatement(node) {
54224             checkGrammarStatementInAmbientContext(node);
54225             var firstDefaultClause;
54226             var hasDuplicateDefaultClause = false;
54227             var expressionType = checkExpression(node.expression);
54228             var expressionIsLiteral = isLiteralType(expressionType);
54229             ts.forEach(node.caseBlock.clauses, function (clause) {
54230                 if (clause.kind === 278 && !hasDuplicateDefaultClause) {
54231                     if (firstDefaultClause === undefined) {
54232                         firstDefaultClause = clause;
54233                     }
54234                     else {
54235                         grammarErrorOnNode(clause, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement);
54236                         hasDuplicateDefaultClause = true;
54237                     }
54238                 }
54239                 if (produceDiagnostics && clause.kind === 277) {
54240                     var caseType = checkExpression(clause.expression);
54241                     var caseIsLiteral = isLiteralType(caseType);
54242                     var comparedExpressionType = expressionType;
54243                     if (!caseIsLiteral || !expressionIsLiteral) {
54244                         caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
54245                         comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
54246                     }
54247                     if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
54248                         checkTypeComparableTo(caseType, comparedExpressionType, clause.expression, undefined);
54249                     }
54250                 }
54251                 ts.forEach(clause.statements, checkSourceElement);
54252                 if (compilerOptions.noFallthroughCasesInSwitch && clause.fallthroughFlowNode && isReachableFlowNode(clause.fallthroughFlowNode)) {
54253                     error(clause, ts.Diagnostics.Fallthrough_case_in_switch);
54254                 }
54255             });
54256             if (node.caseBlock.locals) {
54257                 registerForUnusedIdentifiersCheck(node.caseBlock);
54258             }
54259         }
54260         function checkLabeledStatement(node) {
54261             if (!checkGrammarStatementInAmbientContext(node)) {
54262                 ts.findAncestor(node.parent, function (current) {
54263                     if (ts.isFunctionLike(current)) {
54264                         return "quit";
54265                     }
54266                     if (current.kind === 238 && current.label.escapedText === node.label.escapedText) {
54267                         grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label));
54268                         return true;
54269                     }
54270                     return false;
54271                 });
54272             }
54273             checkSourceElement(node.statement);
54274         }
54275         function checkThrowStatement(node) {
54276             if (!checkGrammarStatementInAmbientContext(node)) {
54277                 if (node.expression === undefined) {
54278                     grammarErrorAfterFirstToken(node, ts.Diagnostics.Line_break_not_permitted_here);
54279                 }
54280             }
54281             if (node.expression) {
54282                 checkExpression(node.expression);
54283             }
54284         }
54285         function checkTryStatement(node) {
54286             checkGrammarStatementInAmbientContext(node);
54287             checkBlock(node.tryBlock);
54288             var catchClause = node.catchClause;
54289             if (catchClause) {
54290                 if (catchClause.variableDeclaration) {
54291                     if (catchClause.variableDeclaration.type) {
54292                         grammarErrorOnFirstToken(catchClause.variableDeclaration.type, ts.Diagnostics.Catch_clause_variable_cannot_have_a_type_annotation);
54293                     }
54294                     else if (catchClause.variableDeclaration.initializer) {
54295                         grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer);
54296                     }
54297                     else {
54298                         var blockLocals_1 = catchClause.block.locals;
54299                         if (blockLocals_1) {
54300                             ts.forEachKey(catchClause.locals, function (caughtName) {
54301                                 var blockLocal = blockLocals_1.get(caughtName);
54302                                 if (blockLocal && (blockLocal.flags & 2) !== 0) {
54303                                     grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName);
54304                                 }
54305                             });
54306                         }
54307                     }
54308                 }
54309                 checkBlock(catchClause.block);
54310             }
54311             if (node.finallyBlock) {
54312                 checkBlock(node.finallyBlock);
54313             }
54314         }
54315         function checkIndexConstraints(type) {
54316             var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1);
54317             var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0);
54318             var stringIndexType = getIndexTypeOfType(type, 0);
54319             var numberIndexType = getIndexTypeOfType(type, 1);
54320             if (stringIndexType || numberIndexType) {
54321                 ts.forEach(getPropertiesOfObjectType(type), function (prop) {
54322                     var propType = getTypeOfSymbol(prop);
54323                     checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0);
54324                     checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1);
54325                 });
54326                 var classDeclaration = type.symbol.valueDeclaration;
54327                 if (ts.getObjectFlags(type) & 1 && ts.isClassLike(classDeclaration)) {
54328                     for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) {
54329                         var member = _a[_i];
54330                         if (!ts.hasModifier(member, 32) && hasNonBindableDynamicName(member)) {
54331                             var symbol = getSymbolOfNode(member);
54332                             var propType = getTypeOfSymbol(symbol);
54333                             checkIndexConstraintForProperty(symbol, propType, type, declaredStringIndexer, stringIndexType, 0);
54334                             checkIndexConstraintForProperty(symbol, propType, type, declaredNumberIndexer, numberIndexType, 1);
54335                         }
54336                     }
54337                 }
54338             }
54339             var errorNode;
54340             if (stringIndexType && numberIndexType) {
54341                 errorNode = declaredNumberIndexer || declaredStringIndexer;
54342                 if (!errorNode && (ts.getObjectFlags(type) & 2)) {
54343                     var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0) && getIndexTypeOfType(base, 1); });
54344                     errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0];
54345                 }
54346             }
54347             if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) {
54348                 error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType));
54349             }
54350             function checkIndexConstraintForProperty(prop, propertyType, containingType, indexDeclaration, indexType, indexKind) {
54351                 if (!indexType || ts.isKnownSymbol(prop)) {
54352                     return;
54353                 }
54354                 var propDeclaration = prop.valueDeclaration;
54355                 var name = propDeclaration && ts.getNameOfDeclaration(propDeclaration);
54356                 if (name && ts.isPrivateIdentifier(name)) {
54357                     return;
54358                 }
54359                 if (indexKind === 1 && !(name ? isNumericName(name) : isNumericLiteralName(prop.escapedName))) {
54360                     return;
54361                 }
54362                 var errorNode;
54363                 if (propDeclaration && name &&
54364                     (propDeclaration.kind === 209 ||
54365                         name.kind === 154 ||
54366                         prop.parent === containingType.symbol)) {
54367                     errorNode = propDeclaration;
54368                 }
54369                 else if (indexDeclaration) {
54370                     errorNode = indexDeclaration;
54371                 }
54372                 else if (ts.getObjectFlags(containingType) & 2) {
54373                     var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.escapedName) && getIndexTypeOfType(base, indexKind); });
54374                     errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0];
54375                 }
54376                 if (errorNode && !isTypeAssignableTo(propertyType, indexType)) {
54377                     var errorMessage = indexKind === 0
54378                         ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2
54379                         : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2;
54380                     error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType));
54381                 }
54382             }
54383         }
54384         function checkTypeNameIsReserved(name, message) {
54385             switch (name.escapedText) {
54386                 case "any":
54387                 case "unknown":
54388                 case "number":
54389                 case "bigint":
54390                 case "boolean":
54391                 case "string":
54392                 case "symbol":
54393                 case "void":
54394                 case "object":
54395                     error(name, message, name.escapedText);
54396             }
54397         }
54398         function checkClassNameCollisionWithObject(name) {
54399             if (languageVersion === 1 && name.escapedText === "Object"
54400                 && moduleKind < ts.ModuleKind.ES2015) {
54401                 error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]);
54402             }
54403         }
54404         function checkTypeParameters(typeParameterDeclarations) {
54405             if (typeParameterDeclarations) {
54406                 var seenDefault = false;
54407                 for (var i = 0; i < typeParameterDeclarations.length; i++) {
54408                     var node = typeParameterDeclarations[i];
54409                     checkTypeParameter(node);
54410                     if (produceDiagnostics) {
54411                         if (node.default) {
54412                             seenDefault = true;
54413                             checkTypeParametersNotReferenced(node.default, typeParameterDeclarations, i);
54414                         }
54415                         else if (seenDefault) {
54416                             error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters);
54417                         }
54418                         for (var j = 0; j < i; j++) {
54419                             if (typeParameterDeclarations[j].symbol === node.symbol) {
54420                                 error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name));
54421                             }
54422                         }
54423                     }
54424                 }
54425             }
54426         }
54427         function checkTypeParametersNotReferenced(root, typeParameters, index) {
54428             visit(root);
54429             function visit(node) {
54430                 if (node.kind === 169) {
54431                     var type = getTypeFromTypeReference(node);
54432                     if (type.flags & 262144) {
54433                         for (var i = index; i < typeParameters.length; i++) {
54434                             if (type.symbol === getSymbolOfNode(typeParameters[i])) {
54435                                 error(node, ts.Diagnostics.Type_parameter_defaults_can_only_reference_previously_declared_type_parameters);
54436                             }
54437                         }
54438                     }
54439                 }
54440                 ts.forEachChild(node, visit);
54441             }
54442         }
54443         function checkTypeParameterListsIdentical(symbol) {
54444             if (symbol.declarations.length === 1) {
54445                 return;
54446             }
54447             var links = getSymbolLinks(symbol);
54448             if (!links.typeParametersChecked) {
54449                 links.typeParametersChecked = true;
54450                 var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol);
54451                 if (declarations.length <= 1) {
54452                     return;
54453                 }
54454                 var type = getDeclaredTypeOfSymbol(symbol);
54455                 if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) {
54456                     var name = symbolToString(symbol);
54457                     for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
54458                         var declaration = declarations_6[_i];
54459                         error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name);
54460                     }
54461                 }
54462             }
54463         }
54464         function areTypeParametersIdentical(declarations, targetParameters) {
54465             var maxTypeArgumentCount = ts.length(targetParameters);
54466             var minTypeArgumentCount = getMinTypeArgumentCount(targetParameters);
54467             for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
54468                 var declaration = declarations_7[_i];
54469                 var sourceParameters = ts.getEffectiveTypeParameterDeclarations(declaration);
54470                 var numTypeParameters = sourceParameters.length;
54471                 if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
54472                     return false;
54473                 }
54474                 for (var i = 0; i < numTypeParameters; i++) {
54475                     var source = sourceParameters[i];
54476                     var target = targetParameters[i];
54477                     if (source.name.escapedText !== target.symbol.escapedName) {
54478                         return false;
54479                     }
54480                     var constraint = ts.getEffectiveConstraintOfTypeParameter(source);
54481                     var sourceConstraint = constraint && getTypeFromTypeNode(constraint);
54482                     var targetConstraint = getConstraintOfTypeParameter(target);
54483                     if (sourceConstraint && targetConstraint && !isTypeIdenticalTo(sourceConstraint, targetConstraint)) {
54484                         return false;
54485                     }
54486                     var sourceDefault = source.default && getTypeFromTypeNode(source.default);
54487                     var targetDefault = getDefaultFromTypeParameter(target);
54488                     if (sourceDefault && targetDefault && !isTypeIdenticalTo(sourceDefault, targetDefault)) {
54489                         return false;
54490                     }
54491                 }
54492             }
54493             return true;
54494         }
54495         function checkClassExpression(node) {
54496             checkClassLikeDeclaration(node);
54497             checkNodeDeferred(node);
54498             return getTypeOfSymbol(getSymbolOfNode(node));
54499         }
54500         function checkClassExpressionDeferred(node) {
54501             ts.forEach(node.members, checkSourceElement);
54502             registerForUnusedIdentifiersCheck(node);
54503         }
54504         function checkClassDeclaration(node) {
54505             if (!node.name && !ts.hasModifier(node, 512)) {
54506                 grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name);
54507             }
54508             checkClassLikeDeclaration(node);
54509             ts.forEach(node.members, checkSourceElement);
54510             registerForUnusedIdentifiersCheck(node);
54511         }
54512         function checkClassLikeDeclaration(node) {
54513             checkGrammarClassLikeDeclaration(node);
54514             checkDecorators(node);
54515             if (node.name) {
54516                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0);
54517                 checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
54518                 checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
54519                 if (!(node.flags & 8388608)) {
54520                     checkClassNameCollisionWithObject(node.name);
54521                 }
54522             }
54523             checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node));
54524             checkExportsOnMergedDeclarations(node);
54525             var symbol = getSymbolOfNode(node);
54526             var type = getDeclaredTypeOfSymbol(symbol);
54527             var typeWithThis = getTypeWithThisArgument(type);
54528             var staticType = getTypeOfSymbol(symbol);
54529             checkTypeParameterListsIdentical(symbol);
54530             checkClassForDuplicateDeclarations(node);
54531             if (!(node.flags & 8388608)) {
54532                 checkClassForStaticPropertyNameConflicts(node);
54533             }
54534             var baseTypeNode = ts.getEffectiveBaseTypeNode(node);
54535             if (baseTypeNode) {
54536                 ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
54537                 if (languageVersion < 2) {
54538                     checkExternalEmitHelpers(baseTypeNode.parent, 1);
54539                 }
54540                 var extendsNode = ts.getClassExtendsHeritageElement(node);
54541                 if (extendsNode && extendsNode !== baseTypeNode) {
54542                     checkExpression(extendsNode.expression);
54543                 }
54544                 var baseTypes = getBaseTypes(type);
54545                 if (baseTypes.length && produceDiagnostics) {
54546                     var baseType_1 = baseTypes[0];
54547                     var baseConstructorType = getBaseConstructorTypeOfClass(type);
54548                     var staticBaseType = getApparentType(baseConstructorType);
54549                     checkBaseTypeAccessibility(staticBaseType, baseTypeNode);
54550                     checkSourceElement(baseTypeNode.expression);
54551                     if (ts.some(baseTypeNode.typeArguments)) {
54552                         ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
54553                         for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) {
54554                             var constructor = _a[_i];
54555                             if (!checkTypeArgumentConstraints(baseTypeNode, constructor.typeParameters)) {
54556                                 break;
54557                             }
54558                         }
54559                     }
54560                     var baseWithThis = getTypeWithThisArgument(baseType_1, type.thisType);
54561                     if (!checkTypeAssignableTo(typeWithThis, baseWithThis, undefined)) {
54562                         issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1);
54563                     }
54564                     else {
54565                         checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
54566                     }
54567                     if (baseConstructorType.flags & 8650752 && !isMixinConstructorType(staticType)) {
54568                         error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
54569                     }
54570                     if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 8650752)) {
54571                         var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode);
54572                         if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType_1); })) {
54573                             error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type);
54574                         }
54575                     }
54576                     checkKindsOfPropertyMemberOverrides(type, baseType_1);
54577                 }
54578             }
54579             var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node);
54580             if (implementedTypeNodes) {
54581                 for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) {
54582                     var typeRefNode = implementedTypeNodes_1[_b];
54583                     if (!ts.isEntityNameExpression(typeRefNode.expression)) {
54584                         error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments);
54585                     }
54586                     checkTypeReferenceNode(typeRefNode);
54587                     if (produceDiagnostics) {
54588                         var t = getReducedType(getTypeFromTypeNode(typeRefNode));
54589                         if (t !== errorType) {
54590                             if (isValidBaseType(t)) {
54591                                 var genericDiag = t.symbol && t.symbol.flags & 32 ?
54592                                     ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
54593                                     ts.Diagnostics.Class_0_incorrectly_implements_interface_1;
54594                                 var baseWithThis = getTypeWithThisArgument(t, type.thisType);
54595                                 if (!checkTypeAssignableTo(typeWithThis, baseWithThis, undefined)) {
54596                                     issueMemberSpecificError(node, typeWithThis, baseWithThis, genericDiag);
54597                                 }
54598                             }
54599                             else {
54600                                 error(typeRefNode, ts.Diagnostics.A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members);
54601                             }
54602                         }
54603                     }
54604                 }
54605             }
54606             if (produceDiagnostics) {
54607                 checkIndexConstraints(type);
54608                 checkTypeForDuplicateIndexSignatures(node);
54609                 checkPropertyInitialization(node);
54610             }
54611         }
54612         function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
54613             var issuedMemberError = false;
54614             var _loop_19 = function (member) {
54615                 if (ts.hasStaticModifier(member)) {
54616                     return "continue";
54617                 }
54618                 var declaredProp = member.name && getSymbolAtLocation(member.name) || getSymbolAtLocation(member);
54619                 if (declaredProp) {
54620                     var prop = getPropertyOfType(typeWithThis, declaredProp.escapedName);
54621                     var baseProp = getPropertyOfType(baseWithThis, declaredProp.escapedName);
54622                     if (prop && baseProp) {
54623                         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)); };
54624                         if (!checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(baseProp), member.name || member, undefined, rootChain)) {
54625                             issuedMemberError = true;
54626                         }
54627                     }
54628                 }
54629             };
54630             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
54631                 var member = _a[_i];
54632                 _loop_19(member);
54633             }
54634             if (!issuedMemberError) {
54635                 checkTypeAssignableTo(typeWithThis, baseWithThis, node.name || node, broadDiag);
54636             }
54637         }
54638         function checkBaseTypeAccessibility(type, node) {
54639             var signatures = getSignaturesOfType(type, 1);
54640             if (signatures.length) {
54641                 var declaration = signatures[0].declaration;
54642                 if (declaration && ts.hasModifier(declaration, 8)) {
54643                     var typeClassDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol);
54644                     if (!isNodeWithinClass(node, typeClassDeclaration)) {
54645                         error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol));
54646                     }
54647                 }
54648             }
54649         }
54650         function getTargetSymbol(s) {
54651             return ts.getCheckFlags(s) & 1 ? s.target : s;
54652         }
54653         function getClassOrInterfaceDeclarationsOfSymbol(symbol) {
54654             return ts.filter(symbol.declarations, function (d) {
54655                 return d.kind === 245 || d.kind === 246;
54656             });
54657         }
54658         function checkKindsOfPropertyMemberOverrides(type, baseType) {
54659             var baseProperties = getPropertiesOfType(baseType);
54660             basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
54661                 var baseProperty = baseProperties_1[_i];
54662                 var base = getTargetSymbol(baseProperty);
54663                 if (base.flags & 4194304) {
54664                     continue;
54665                 }
54666                 var baseSymbol = getPropertyOfObjectType(type, base.escapedName);
54667                 if (!baseSymbol) {
54668                     continue;
54669                 }
54670                 var derived = getTargetSymbol(baseSymbol);
54671                 var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base);
54672                 ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration.");
54673                 if (derived === base) {
54674                     var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol);
54675                     if (baseDeclarationFlags & 128 && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128))) {
54676                         for (var _a = 0, _b = getBaseTypes(type); _a < _b.length; _a++) {
54677                             var otherBaseType = _b[_a];
54678                             if (otherBaseType === baseType)
54679                                 continue;
54680                             var baseSymbol_1 = getPropertyOfObjectType(otherBaseType, base.escapedName);
54681                             var derivedElsewhere = baseSymbol_1 && getTargetSymbol(baseSymbol_1);
54682                             if (derivedElsewhere && derivedElsewhere !== base) {
54683                                 continue basePropertyCheck;
54684                             }
54685                         }
54686                         if (derivedClassDecl.kind === 214) {
54687                             error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType));
54688                         }
54689                         else {
54690                             error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
54691                         }
54692                     }
54693                 }
54694                 else {
54695                     var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived);
54696                     if (baseDeclarationFlags & 8 || derivedDeclarationFlags & 8) {
54697                         continue;
54698                     }
54699                     var errorMessage = void 0;
54700                     var basePropertyFlags = base.flags & 98308;
54701                     var derivedPropertyFlags = derived.flags & 98308;
54702                     if (basePropertyFlags && derivedPropertyFlags) {
54703                         if (!compilerOptions.useDefineForClassFields
54704                             || baseDeclarationFlags & 128 && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer)
54705                             || base.valueDeclaration && base.valueDeclaration.parent.kind === 246
54706                             || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) {
54707                             continue;
54708                         }
54709                         var overriddenInstanceProperty = basePropertyFlags !== 4 && derivedPropertyFlags === 4;
54710                         var overriddenInstanceAccessor = basePropertyFlags === 4 && derivedPropertyFlags !== 4;
54711                         if (overriddenInstanceProperty || overriddenInstanceAccessor) {
54712                             var errorMessage_1 = overriddenInstanceProperty ?
54713                                 ts.Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property :
54714                                 ts.Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor;
54715                             error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type));
54716                         }
54717                         else {
54718                             var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 159 && !d.initializer; });
54719                             if (uninitialized
54720                                 && !(derived.flags & 33554432)
54721                                 && !(baseDeclarationFlags & 128)
54722                                 && !(derivedDeclarationFlags & 128)
54723                                 && !derived.declarations.some(function (d) { return !!(d.flags & 8388608); })) {
54724                                 var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol));
54725                                 var propName = uninitialized.name;
54726                                 if (uninitialized.exclamationToken
54727                                     || !constructor
54728                                     || !ts.isIdentifier(propName)
54729                                     || !strictNullChecks
54730                                     || !isPropertyInitializedInConstructor(propName, type, constructor)) {
54731                                     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;
54732                                     error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_2, symbolToString(base), typeToString(baseType));
54733                                 }
54734                             }
54735                         }
54736                         continue;
54737                     }
54738                     else if (isPrototypeProperty(base)) {
54739                         if (isPrototypeProperty(derived) || derived.flags & 4) {
54740                             continue;
54741                         }
54742                         else {
54743                             ts.Debug.assert(!!(derived.flags & 98304));
54744                             errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor;
54745                         }
54746                     }
54747                     else if (base.flags & 98304) {
54748                         errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function;
54749                     }
54750                     else {
54751                         errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function;
54752                     }
54753                     error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type));
54754                 }
54755             }
54756         }
54757         function getNonInterhitedProperties(type, baseTypes, properties) {
54758             if (!ts.length(baseTypes)) {
54759                 return properties;
54760             }
54761             var seen = ts.createUnderscoreEscapedMap();
54762             ts.forEach(properties, function (p) { seen.set(p.escapedName, p); });
54763             for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) {
54764                 var base = baseTypes_2[_i];
54765                 var properties_5 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
54766                 for (var _a = 0, properties_4 = properties_5; _a < properties_4.length; _a++) {
54767                     var prop = properties_4[_a];
54768                     var existing = seen.get(prop.escapedName);
54769                     if (existing && !isPropertyIdenticalTo(existing, prop)) {
54770                         seen.delete(prop.escapedName);
54771                     }
54772                 }
54773             }
54774             return ts.arrayFrom(seen.values());
54775         }
54776         function checkInheritedPropertiesAreIdentical(type, typeNode) {
54777             var baseTypes = getBaseTypes(type);
54778             if (baseTypes.length < 2) {
54779                 return true;
54780             }
54781             var seen = ts.createUnderscoreEscapedMap();
54782             ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen.set(p.escapedName, { prop: p, containingType: type }); });
54783             var ok = true;
54784             for (var _i = 0, baseTypes_3 = baseTypes; _i < baseTypes_3.length; _i++) {
54785                 var base = baseTypes_3[_i];
54786                 var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
54787                 for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) {
54788                     var prop = properties_6[_a];
54789                     var existing = seen.get(prop.escapedName);
54790                     if (!existing) {
54791                         seen.set(prop.escapedName, { prop: prop, containingType: base });
54792                     }
54793                     else {
54794                         var isInheritedProperty = existing.containingType !== type;
54795                         if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) {
54796                             ok = false;
54797                             var typeName1 = typeToString(existing.containingType);
54798                             var typeName2 = typeToString(base);
54799                             var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Named_property_0_of_types_1_and_2_are_not_identical, symbolToString(prop), typeName1, typeName2);
54800                             errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2);
54801                             diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo));
54802                         }
54803                     }
54804                 }
54805             }
54806             return ok;
54807         }
54808         function checkPropertyInitialization(node) {
54809             if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608) {
54810                 return;
54811             }
54812             var constructor = findConstructorDeclaration(node);
54813             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
54814                 var member = _a[_i];
54815                 if (ts.getModifierFlags(member) & 2) {
54816                     continue;
54817                 }
54818                 if (isInstancePropertyWithoutInitializer(member)) {
54819                     var propName = member.name;
54820                     if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName)) {
54821                         var type = getTypeOfSymbol(getSymbolOfNode(member));
54822                         if (!(type.flags & 3 || getFalsyFlags(type) & 32768)) {
54823                             if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) {
54824                                 error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName));
54825                             }
54826                         }
54827                     }
54828                 }
54829             }
54830         }
54831         function isInstancePropertyWithoutInitializer(node) {
54832             return node.kind === 159 &&
54833                 !ts.hasModifier(node, 32 | 128) &&
54834                 !node.exclamationToken &&
54835                 !node.initializer;
54836         }
54837         function isPropertyInitializedInConstructor(propName, propType, constructor) {
54838             var reference = ts.createPropertyAccess(ts.createThis(), propName);
54839             reference.expression.parent = reference;
54840             reference.parent = constructor;
54841             reference.flowNode = constructor.returnFlowNode;
54842             var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
54843             return !(getFalsyFlags(flowType) & 32768);
54844         }
54845         function checkInterfaceDeclaration(node) {
54846             if (!checkGrammarDecoratorsAndModifiers(node))
54847                 checkGrammarInterfaceDeclaration(node);
54848             checkTypeParameters(node.typeParameters);
54849             if (produceDiagnostics) {
54850                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0);
54851                 checkExportsOnMergedDeclarations(node);
54852                 var symbol = getSymbolOfNode(node);
54853                 checkTypeParameterListsIdentical(symbol);
54854                 var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 246);
54855                 if (node === firstInterfaceDecl) {
54856                     var type = getDeclaredTypeOfSymbol(symbol);
54857                     var typeWithThis = getTypeWithThisArgument(type);
54858                     if (checkInheritedPropertiesAreIdentical(type, node.name)) {
54859                         for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) {
54860                             var baseType = _a[_i];
54861                             checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1);
54862                         }
54863                         checkIndexConstraints(type);
54864                     }
54865                 }
54866                 checkObjectTypeForDuplicateDeclarations(node);
54867             }
54868             ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) {
54869                 if (!ts.isEntityNameExpression(heritageElement.expression)) {
54870                     error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments);
54871                 }
54872                 checkTypeReferenceNode(heritageElement);
54873             });
54874             ts.forEach(node.members, checkSourceElement);
54875             if (produceDiagnostics) {
54876                 checkTypeForDuplicateIndexSignatures(node);
54877                 registerForUnusedIdentifiersCheck(node);
54878             }
54879         }
54880         function checkTypeAliasDeclaration(node) {
54881             checkGrammarDecoratorsAndModifiers(node);
54882             checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0);
54883             checkExportsOnMergedDeclarations(node);
54884             checkTypeParameters(node.typeParameters);
54885             checkSourceElement(node.type);
54886             registerForUnusedIdentifiersCheck(node);
54887         }
54888         function computeEnumMemberValues(node) {
54889             var nodeLinks = getNodeLinks(node);
54890             if (!(nodeLinks.flags & 16384)) {
54891                 nodeLinks.flags |= 16384;
54892                 var autoValue = 0;
54893                 for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
54894                     var member = _a[_i];
54895                     var value = computeMemberValue(member, autoValue);
54896                     getNodeLinks(member).enumMemberValue = value;
54897                     autoValue = typeof value === "number" ? value + 1 : undefined;
54898                 }
54899             }
54900         }
54901         function computeMemberValue(member, autoValue) {
54902             if (ts.isComputedNonLiteralName(member.name)) {
54903                 error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums);
54904             }
54905             else {
54906                 var text = ts.getTextOfPropertyName(member.name);
54907                 if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) {
54908                     error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name);
54909                 }
54910             }
54911             if (member.initializer) {
54912                 return computeConstantValue(member);
54913             }
54914             if (member.parent.flags & 8388608 && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0) {
54915                 return undefined;
54916             }
54917             if (autoValue !== undefined) {
54918                 return autoValue;
54919             }
54920             error(member.name, ts.Diagnostics.Enum_member_must_have_initializer);
54921             return undefined;
54922         }
54923         function computeConstantValue(member) {
54924             var enumKind = getEnumKind(getSymbolOfNode(member.parent));
54925             var isConstEnum = ts.isEnumConst(member.parent);
54926             var initializer = member.initializer;
54927             var value = enumKind === 1 && !isLiteralEnumMember(member) ? undefined : evaluate(initializer);
54928             if (value !== undefined) {
54929                 if (isConstEnum && typeof value === "number" && !isFinite(value)) {
54930                     error(initializer, isNaN(value) ?
54931                         ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN :
54932                         ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value);
54933                 }
54934             }
54935             else if (enumKind === 1) {
54936                 error(initializer, ts.Diagnostics.Computed_values_are_not_permitted_in_an_enum_with_string_valued_members);
54937                 return 0;
54938             }
54939             else if (isConstEnum) {
54940                 error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values);
54941             }
54942             else if (member.parent.flags & 8388608) {
54943                 error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression);
54944             }
54945             else {
54946                 var source = checkExpression(initializer);
54947                 if (!isTypeAssignableToKind(source, 296)) {
54948                     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));
54949                 }
54950                 else {
54951                     checkTypeAssignableTo(source, getDeclaredTypeOfSymbol(getSymbolOfNode(member.parent)), initializer, undefined);
54952                 }
54953             }
54954             return value;
54955             function evaluate(expr) {
54956                 switch (expr.kind) {
54957                     case 207:
54958                         var value_2 = evaluate(expr.operand);
54959                         if (typeof value_2 === "number") {
54960                             switch (expr.operator) {
54961                                 case 39: return value_2;
54962                                 case 40: return -value_2;
54963                                 case 54: return ~value_2;
54964                             }
54965                         }
54966                         break;
54967                     case 209:
54968                         var left = evaluate(expr.left);
54969                         var right = evaluate(expr.right);
54970                         if (typeof left === "number" && typeof right === "number") {
54971                             switch (expr.operatorToken.kind) {
54972                                 case 51: return left | right;
54973                                 case 50: return left & right;
54974                                 case 48: return left >> right;
54975                                 case 49: return left >>> right;
54976                                 case 47: return left << right;
54977                                 case 52: return left ^ right;
54978                                 case 41: return left * right;
54979                                 case 43: return left / right;
54980                                 case 39: return left + right;
54981                                 case 40: return left - right;
54982                                 case 44: return left % right;
54983                                 case 42: return Math.pow(left, right);
54984                             }
54985                         }
54986                         else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39) {
54987                             return left + right;
54988                         }
54989                         break;
54990                     case 10:
54991                     case 14:
54992                         return expr.text;
54993                     case 8:
54994                         checkGrammarNumericLiteral(expr);
54995                         return +expr.text;
54996                     case 200:
54997                         return evaluate(expr.expression);
54998                     case 75:
54999                         var identifier = expr;
55000                         if (isInfinityOrNaNString(identifier.escapedText)) {
55001                             return +(identifier.escapedText);
55002                         }
55003                         return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText);
55004                     case 195:
55005                     case 194:
55006                         var ex = expr;
55007                         if (isConstantMemberAccess(ex)) {
55008                             var type = getTypeOfExpression(ex.expression);
55009                             if (type.symbol && type.symbol.flags & 384) {
55010                                 var name = void 0;
55011                                 if (ex.kind === 194) {
55012                                     name = ex.name.escapedText;
55013                                 }
55014                                 else {
55015                                     name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text);
55016                                 }
55017                                 return evaluateEnumMember(expr, type.symbol, name);
55018                             }
55019                         }
55020                         break;
55021                 }
55022                 return undefined;
55023             }
55024             function evaluateEnumMember(expr, enumSymbol, name) {
55025                 var memberSymbol = enumSymbol.exports.get(name);
55026                 if (memberSymbol) {
55027                     var declaration = memberSymbol.valueDeclaration;
55028                     if (declaration !== member) {
55029                         if (isBlockScopedNameDeclaredBeforeUse(declaration, member)) {
55030                             return getEnumMemberValue(declaration);
55031                         }
55032                         error(expr, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
55033                         return 0;
55034                     }
55035                     else {
55036                         error(expr, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(memberSymbol));
55037                     }
55038                 }
55039                 return undefined;
55040             }
55041         }
55042         function isConstantMemberAccess(node) {
55043             return node.kind === 75 ||
55044                 node.kind === 194 && isConstantMemberAccess(node.expression) ||
55045                 node.kind === 195 && isConstantMemberAccess(node.expression) &&
55046                     ts.isStringLiteralLike(node.argumentExpression);
55047         }
55048         function checkEnumDeclaration(node) {
55049             if (!produceDiagnostics) {
55050                 return;
55051             }
55052             checkGrammarDecoratorsAndModifiers(node);
55053             checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0);
55054             checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
55055             checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
55056             checkExportsOnMergedDeclarations(node);
55057             node.members.forEach(checkEnumMember);
55058             computeEnumMemberValues(node);
55059             var enumSymbol = getSymbolOfNode(node);
55060             var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind);
55061             if (node === firstDeclaration) {
55062                 if (enumSymbol.declarations.length > 1) {
55063                     var enumIsConst_1 = ts.isEnumConst(node);
55064                     ts.forEach(enumSymbol.declarations, function (decl) {
55065                         if (ts.isEnumDeclaration(decl) && ts.isEnumConst(decl) !== enumIsConst_1) {
55066                             error(ts.getNameOfDeclaration(decl), ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const);
55067                         }
55068                     });
55069                 }
55070                 var seenEnumMissingInitialInitializer_1 = false;
55071                 ts.forEach(enumSymbol.declarations, function (declaration) {
55072                     if (declaration.kind !== 248) {
55073                         return false;
55074                     }
55075                     var enumDeclaration = declaration;
55076                     if (!enumDeclaration.members.length) {
55077                         return false;
55078                     }
55079                     var firstEnumMember = enumDeclaration.members[0];
55080                     if (!firstEnumMember.initializer) {
55081                         if (seenEnumMissingInitialInitializer_1) {
55082                             error(firstEnumMember.name, ts.Diagnostics.In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element);
55083                         }
55084                         else {
55085                             seenEnumMissingInitialInitializer_1 = true;
55086                         }
55087                     }
55088                 });
55089             }
55090         }
55091         function checkEnumMember(node) {
55092             if (ts.isPrivateIdentifier(node.name)) {
55093                 error(node, ts.Diagnostics.An_enum_member_cannot_be_named_with_a_private_identifier);
55094             }
55095         }
55096         function getFirstNonAmbientClassOrFunctionDeclaration(symbol) {
55097             var declarations = symbol.declarations;
55098             for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
55099                 var declaration = declarations_8[_i];
55100                 if ((declaration.kind === 245 ||
55101                     (declaration.kind === 244 && ts.nodeIsPresent(declaration.body))) &&
55102                     !(declaration.flags & 8388608)) {
55103                     return declaration;
55104                 }
55105             }
55106             return undefined;
55107         }
55108         function inSameLexicalScope(node1, node2) {
55109             var container1 = ts.getEnclosingBlockScopeContainer(node1);
55110             var container2 = ts.getEnclosingBlockScopeContainer(node2);
55111             if (isGlobalSourceFile(container1)) {
55112                 return isGlobalSourceFile(container2);
55113             }
55114             else if (isGlobalSourceFile(container2)) {
55115                 return false;
55116             }
55117             else {
55118                 return container1 === container2;
55119             }
55120         }
55121         function checkModuleDeclaration(node) {
55122             if (produceDiagnostics) {
55123                 var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node);
55124                 var inAmbientContext = node.flags & 8388608;
55125                 if (isGlobalAugmentation && !inAmbientContext) {
55126                     error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context);
55127                 }
55128                 var isAmbientExternalModule = ts.isAmbientModule(node);
55129                 var contextErrorMessage = isAmbientExternalModule
55130                     ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file
55131                     : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module;
55132                 if (checkGrammarModuleElementContext(node, contextErrorMessage)) {
55133                     return;
55134                 }
55135                 if (!checkGrammarDecoratorsAndModifiers(node)) {
55136                     if (!inAmbientContext && node.name.kind === 10) {
55137                         grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names);
55138                     }
55139                 }
55140                 if (ts.isIdentifier(node.name)) {
55141                     checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
55142                     checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
55143                 }
55144                 checkExportsOnMergedDeclarations(node);
55145                 var symbol = getSymbolOfNode(node);
55146                 if (symbol.flags & 512
55147                     && !inAmbientContext
55148                     && symbol.declarations.length > 1
55149                     && isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules)) {
55150                     var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol);
55151                     if (firstNonAmbientClassOrFunc) {
55152                         if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) {
55153                             error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged);
55154                         }
55155                         else if (node.pos < firstNonAmbientClassOrFunc.pos) {
55156                             error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged);
55157                         }
55158                     }
55159                     var mergedClass = ts.getDeclarationOfKind(symbol, 245);
55160                     if (mergedClass &&
55161                         inSameLexicalScope(node, mergedClass)) {
55162                         getNodeLinks(node).flags |= 32768;
55163                     }
55164                 }
55165                 if (isAmbientExternalModule) {
55166                     if (ts.isExternalModuleAugmentation(node)) {
55167                         var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432);
55168                         if (checkBody && node.body) {
55169                             for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
55170                                 var statement = _a[_i];
55171                                 checkModuleAugmentationElement(statement, isGlobalAugmentation);
55172                             }
55173                         }
55174                     }
55175                     else if (isGlobalSourceFile(node.parent)) {
55176                         if (isGlobalAugmentation) {
55177                             error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations);
55178                         }
55179                         else if (ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(node.name))) {
55180                             error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name);
55181                         }
55182                     }
55183                     else {
55184                         if (isGlobalAugmentation) {
55185                             error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations);
55186                         }
55187                         else {
55188                             error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces);
55189                         }
55190                     }
55191                 }
55192             }
55193             if (node.body) {
55194                 checkSourceElement(node.body);
55195                 if (!ts.isGlobalScopeAugmentation(node)) {
55196                     registerForUnusedIdentifiersCheck(node);
55197                 }
55198             }
55199         }
55200         function checkModuleAugmentationElement(node, isGlobalAugmentation) {
55201             switch (node.kind) {
55202                 case 225:
55203                     for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
55204                         var decl = _a[_i];
55205                         checkModuleAugmentationElement(decl, isGlobalAugmentation);
55206                     }
55207                     break;
55208                 case 259:
55209                 case 260:
55210                     grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations);
55211                     break;
55212                 case 253:
55213                 case 254:
55214                     grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module);
55215                     break;
55216                 case 191:
55217                 case 242:
55218                     var name = node.name;
55219                     if (ts.isBindingPattern(name)) {
55220                         for (var _b = 0, _c = name.elements; _b < _c.length; _b++) {
55221                             var el = _c[_b];
55222                             checkModuleAugmentationElement(el, isGlobalAugmentation);
55223                         }
55224                         break;
55225                     }
55226                 case 245:
55227                 case 248:
55228                 case 244:
55229                 case 246:
55230                 case 249:
55231                 case 247:
55232                     if (isGlobalAugmentation) {
55233                         return;
55234                     }
55235                     var symbol = getSymbolOfNode(node);
55236                     if (symbol) {
55237                         var reportError = !(symbol.flags & 33554432);
55238                         if (!reportError) {
55239                             reportError = !!symbol.parent && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]);
55240                         }
55241                     }
55242                     break;
55243             }
55244         }
55245         function getFirstNonModuleExportsIdentifier(node) {
55246             switch (node.kind) {
55247                 case 75:
55248                     return node;
55249                 case 153:
55250                     do {
55251                         node = node.left;
55252                     } while (node.kind !== 75);
55253                     return node;
55254                 case 194:
55255                     do {
55256                         if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) {
55257                             return node.name;
55258                         }
55259                         node = node.expression;
55260                     } while (node.kind !== 75);
55261                     return node;
55262             }
55263         }
55264         function checkExternalImportOrExportDeclaration(node) {
55265             var moduleName = ts.getExternalModuleName(node);
55266             if (!moduleName || ts.nodeIsMissing(moduleName)) {
55267                 return false;
55268             }
55269             if (!ts.isStringLiteral(moduleName)) {
55270                 error(moduleName, ts.Diagnostics.String_literal_expected);
55271                 return false;
55272             }
55273             var inAmbientExternalModule = node.parent.kind === 250 && ts.isAmbientModule(node.parent.parent);
55274             if (node.parent.kind !== 290 && !inAmbientExternalModule) {
55275                 error(moduleName, node.kind === 260 ?
55276                     ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace :
55277                     ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module);
55278                 return false;
55279             }
55280             if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) {
55281                 if (!isTopLevelInExternalModuleAugmentation(node)) {
55282                     error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name);
55283                     return false;
55284                 }
55285             }
55286             return true;
55287         }
55288         function checkAliasSymbol(node) {
55289             var symbol = getSymbolOfNode(node);
55290             var target = resolveAlias(symbol);
55291             var shouldSkipWithJSExpandoTargets = symbol.flags & 67108864;
55292             if (!shouldSkipWithJSExpandoTargets && target !== unknownSymbol) {
55293                 symbol = getMergedSymbol(symbol.exportSymbol || symbol);
55294                 var excludedMeanings = (symbol.flags & (111551 | 1048576) ? 111551 : 0) |
55295                     (symbol.flags & 788968 ? 788968 : 0) |
55296                     (symbol.flags & 1920 ? 1920 : 0);
55297                 if (target.flags & excludedMeanings) {
55298                     var message = node.kind === 263 ?
55299                         ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
55300                         ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
55301                     error(node, message, symbolToString(symbol));
55302                 }
55303                 if (compilerOptions.isolatedModules
55304                     && node.kind === 263
55305                     && !node.parent.parent.isTypeOnly
55306                     && !(target.flags & 111551)
55307                     && !(node.flags & 8388608)) {
55308                     error(node, ts.Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type);
55309                 }
55310             }
55311         }
55312         function checkImportBinding(node) {
55313             checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
55314             checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
55315             checkAliasSymbol(node);
55316         }
55317         function checkImportDeclaration(node) {
55318             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
55319                 return;
55320             }
55321             if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) {
55322                 grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers);
55323             }
55324             if (checkExternalImportOrExportDeclaration(node)) {
55325                 var importClause = node.importClause;
55326                 if (importClause && !checkGrammarImportClause(importClause)) {
55327                     if (importClause.name) {
55328                         checkImportBinding(importClause);
55329                     }
55330                     if (importClause.namedBindings) {
55331                         if (importClause.namedBindings.kind === 256) {
55332                             checkImportBinding(importClause.namedBindings);
55333                         }
55334                         else {
55335                             var moduleExisted = resolveExternalModuleName(node, node.moduleSpecifier);
55336                             if (moduleExisted) {
55337                                 ts.forEach(importClause.namedBindings.elements, checkImportBinding);
55338                             }
55339                         }
55340                     }
55341                 }
55342             }
55343         }
55344         function checkImportEqualsDeclaration(node) {
55345             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
55346                 return;
55347             }
55348             checkGrammarDecoratorsAndModifiers(node);
55349             if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) {
55350                 checkImportBinding(node);
55351                 if (ts.hasModifier(node, 1)) {
55352                     markExportAsReferenced(node);
55353                 }
55354                 if (node.moduleReference.kind !== 265) {
55355                     var target = resolveAlias(getSymbolOfNode(node));
55356                     if (target !== unknownSymbol) {
55357                         if (target.flags & 111551) {
55358                             var moduleName = ts.getFirstIdentifier(node.moduleReference);
55359                             if (!(resolveEntityName(moduleName, 111551 | 1920).flags & 1920)) {
55360                                 error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName));
55361                             }
55362                         }
55363                         if (target.flags & 788968) {
55364                             checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0);
55365                         }
55366                     }
55367                 }
55368                 else {
55369                     if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 8388608)) {
55370                         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);
55371                     }
55372                 }
55373             }
55374         }
55375         function checkExportDeclaration(node) {
55376             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) {
55377                 return;
55378             }
55379             if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) {
55380                 grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers);
55381             }
55382             if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0) {
55383                 checkExternalEmitHelpers(node, 1048576);
55384             }
55385             checkGrammarExportDeclaration(node);
55386             if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) {
55387                 if (node.exportClause && !ts.isNamespaceExport(node.exportClause)) {
55388                     ts.forEach(node.exportClause.elements, checkExportSpecifier);
55389                     var inAmbientExternalModule = node.parent.kind === 250 && ts.isAmbientModule(node.parent.parent);
55390                     var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 250 &&
55391                         !node.moduleSpecifier && node.flags & 8388608;
55392                     if (node.parent.kind !== 290 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) {
55393                         error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace);
55394                     }
55395                 }
55396                 else {
55397                     var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier);
55398                     if (moduleSymbol && hasExportAssignmentSymbol(moduleSymbol)) {
55399                         error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol));
55400                     }
55401                     else if (node.exportClause) {
55402                         checkAliasSymbol(node.exportClause);
55403                     }
55404                     if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) {
55405                         checkExternalEmitHelpers(node, 65536);
55406                     }
55407                 }
55408             }
55409         }
55410         function checkGrammarExportDeclaration(node) {
55411             var _a;
55412             var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 261;
55413             if (isTypeOnlyExportStar) {
55414                 grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type);
55415             }
55416             return !isTypeOnlyExportStar;
55417         }
55418         function checkGrammarModuleElementContext(node, errorMessage) {
55419             var isInAppropriateContext = node.parent.kind === 290 || node.parent.kind === 250 || node.parent.kind === 249;
55420             if (!isInAppropriateContext) {
55421                 grammarErrorOnFirstToken(node, errorMessage);
55422             }
55423             return !isInAppropriateContext;
55424         }
55425         function importClauseContainsReferencedImport(importClause) {
55426             return ts.forEachImportClauseDeclaration(importClause, function (declaration) {
55427                 return !!getSymbolOfNode(declaration).isReferenced;
55428             });
55429         }
55430         function importClauseContainsConstEnumUsedAsValue(importClause) {
55431             return ts.forEachImportClauseDeclaration(importClause, function (declaration) {
55432                 return !!getSymbolLinks(getSymbolOfNode(declaration)).constEnumReferenced;
55433             });
55434         }
55435         function checkImportsForTypeOnlyConversion(sourceFile) {
55436             for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
55437                 var statement = _a[_i];
55438                 if (ts.isImportDeclaration(statement) &&
55439                     statement.importClause &&
55440                     !statement.importClause.isTypeOnly &&
55441                     importClauseContainsReferencedImport(statement.importClause) &&
55442                     !isReferencedAliasDeclaration(statement.importClause, true) &&
55443                     !importClauseContainsConstEnumUsedAsValue(statement.importClause)) {
55444                     error(statement, ts.Diagnostics.This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is_set_to_error);
55445                 }
55446             }
55447         }
55448         function checkExportSpecifier(node) {
55449             checkAliasSymbol(node);
55450             if (ts.getEmitDeclarations(compilerOptions)) {
55451                 collectLinkedAliases(node.propertyName || node.name, true);
55452             }
55453             if (!node.parent.parent.moduleSpecifier) {
55454                 var exportedName = node.propertyName || node.name;
55455                 var symbol = resolveName(exportedName, exportedName.escapedText, 111551 | 788968 | 1920 | 2097152, undefined, undefined, true);
55456                 if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) {
55457                     error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName));
55458                 }
55459                 else {
55460                     markExportAsReferenced(node);
55461                     var target = symbol && (symbol.flags & 2097152 ? resolveAlias(symbol) : symbol);
55462                     if (!target || target === unknownSymbol || target.flags & 111551) {
55463                         checkExpressionCached(node.propertyName || node.name);
55464                     }
55465                 }
55466             }
55467         }
55468         function checkExportAssignment(node) {
55469             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) {
55470                 return;
55471             }
55472             var container = node.parent.kind === 290 ? node.parent : node.parent.parent;
55473             if (container.kind === 249 && !ts.isAmbientModule(container)) {
55474                 if (node.isExportEquals) {
55475                     error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace);
55476                 }
55477                 else {
55478                     error(node, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module);
55479                 }
55480                 return;
55481             }
55482             if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) {
55483                 grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers);
55484             }
55485             if (node.expression.kind === 75) {
55486                 var id = node.expression;
55487                 var sym = resolveEntityName(id, 67108863, true, true, node);
55488                 if (sym) {
55489                     markAliasReferenced(sym, id);
55490                     var target = sym.flags & 2097152 ? resolveAlias(sym) : sym;
55491                     if (target === unknownSymbol || target.flags & 111551) {
55492                         checkExpressionCached(node.expression);
55493                     }
55494                 }
55495                 if (ts.getEmitDeclarations(compilerOptions)) {
55496                     collectLinkedAliases(node.expression, true);
55497                 }
55498             }
55499             else {
55500                 checkExpressionCached(node.expression);
55501             }
55502             checkExternalModuleExports(container);
55503             if ((node.flags & 8388608) && !ts.isEntityNameExpression(node.expression)) {
55504                 grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
55505             }
55506             if (node.isExportEquals && !(node.flags & 8388608)) {
55507                 if (moduleKind >= ts.ModuleKind.ES2015) {
55508                     grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
55509                 }
55510                 else if (moduleKind === ts.ModuleKind.System) {
55511                     grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system);
55512                 }
55513             }
55514         }
55515         function hasExportedMembers(moduleSymbol) {
55516             return ts.forEachEntry(moduleSymbol.exports, function (_, id) { return id !== "export="; });
55517         }
55518         function checkExternalModuleExports(node) {
55519             var moduleSymbol = getSymbolOfNode(node);
55520             var links = getSymbolLinks(moduleSymbol);
55521             if (!links.exportsChecked) {
55522                 var exportEqualsSymbol = moduleSymbol.exports.get("export=");
55523                 if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) {
55524                     var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration;
55525                     if (!isTopLevelInExternalModuleAugmentation(declaration) && !ts.isInJSFile(declaration)) {
55526                         error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements);
55527                     }
55528                 }
55529                 var exports_2 = getExportsOfModule(moduleSymbol);
55530                 if (exports_2) {
55531                     exports_2.forEach(function (_a, id) {
55532                         var declarations = _a.declarations, flags = _a.flags;
55533                         if (id === "__export") {
55534                             return;
55535                         }
55536                         if (flags & (1920 | 64 | 384)) {
55537                             return;
55538                         }
55539                         var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverloadAndNotAccessor);
55540                         if (flags & 524288 && exportedDeclarationsCount <= 2) {
55541                             return;
55542                         }
55543                         if (exportedDeclarationsCount > 1) {
55544                             for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
55545                                 var declaration = declarations_9[_i];
55546                                 if (isNotOverload(declaration)) {
55547                                     diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id)));
55548                                 }
55549                             }
55550                         }
55551                     });
55552                 }
55553                 links.exportsChecked = true;
55554             }
55555         }
55556         function checkSourceElement(node) {
55557             if (node) {
55558                 var saveCurrentNode = currentNode;
55559                 currentNode = node;
55560                 instantiationCount = 0;
55561                 checkSourceElementWorker(node);
55562                 currentNode = saveCurrentNode;
55563             }
55564         }
55565         function checkSourceElementWorker(node) {
55566             if (ts.isInJSFile(node)) {
55567                 ts.forEach(node.jsDoc, function (_a) {
55568                     var tags = _a.tags;
55569                     return ts.forEach(tags, checkSourceElement);
55570                 });
55571             }
55572             var kind = node.kind;
55573             if (cancellationToken) {
55574                 switch (kind) {
55575                     case 249:
55576                     case 245:
55577                     case 246:
55578                     case 244:
55579                         cancellationToken.throwIfCancellationRequested();
55580                 }
55581             }
55582             if (kind >= 225 && kind <= 241 && node.flowNode && !isReachableFlowNode(node.flowNode)) {
55583                 errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected);
55584             }
55585             switch (kind) {
55586                 case 155:
55587                     return checkTypeParameter(node);
55588                 case 156:
55589                     return checkParameter(node);
55590                 case 159:
55591                     return checkPropertyDeclaration(node);
55592                 case 158:
55593                     return checkPropertySignature(node);
55594                 case 170:
55595                 case 171:
55596                 case 165:
55597                 case 166:
55598                 case 167:
55599                     return checkSignatureDeclaration(node);
55600                 case 161:
55601                 case 160:
55602                     return checkMethodDeclaration(node);
55603                 case 162:
55604                     return checkConstructorDeclaration(node);
55605                 case 163:
55606                 case 164:
55607                     return checkAccessorDeclaration(node);
55608                 case 169:
55609                     return checkTypeReferenceNode(node);
55610                 case 168:
55611                     return checkTypePredicate(node);
55612                 case 172:
55613                     return checkTypeQuery(node);
55614                 case 173:
55615                     return checkTypeLiteral(node);
55616                 case 174:
55617                     return checkArrayType(node);
55618                 case 175:
55619                     return checkTupleType(node);
55620                 case 178:
55621                 case 179:
55622                     return checkUnionOrIntersectionType(node);
55623                 case 182:
55624                 case 176:
55625                 case 177:
55626                     return checkSourceElement(node.type);
55627                 case 183:
55628                     return checkThisType(node);
55629                 case 184:
55630                     return checkTypeOperator(node);
55631                 case 180:
55632                     return checkConditionalType(node);
55633                 case 181:
55634                     return checkInferType(node);
55635                 case 188:
55636                     return checkImportType(node);
55637                 case 307:
55638                     return checkJSDocAugmentsTag(node);
55639                 case 308:
55640                     return checkJSDocImplementsTag(node);
55641                 case 322:
55642                 case 315:
55643                 case 316:
55644                     return checkJSDocTypeAliasTag(node);
55645                 case 321:
55646                     return checkJSDocTemplateTag(node);
55647                 case 320:
55648                     return checkJSDocTypeTag(node);
55649                 case 317:
55650                     return checkJSDocParameterTag(node);
55651                 case 323:
55652                     return checkJSDocPropertyTag(node);
55653                 case 300:
55654                     checkJSDocFunctionType(node);
55655                 case 298:
55656                 case 297:
55657                 case 295:
55658                 case 296:
55659                 case 304:
55660                     checkJSDocTypeIsInJsFile(node);
55661                     ts.forEachChild(node, checkSourceElement);
55662                     return;
55663                 case 301:
55664                     checkJSDocVariadicType(node);
55665                     return;
55666                 case 294:
55667                     return checkSourceElement(node.type);
55668                 case 185:
55669                     return checkIndexedAccessType(node);
55670                 case 186:
55671                     return checkMappedType(node);
55672                 case 244:
55673                     return checkFunctionDeclaration(node);
55674                 case 223:
55675                 case 250:
55676                     return checkBlock(node);
55677                 case 225:
55678                     return checkVariableStatement(node);
55679                 case 226:
55680                     return checkExpressionStatement(node);
55681                 case 227:
55682                     return checkIfStatement(node);
55683                 case 228:
55684                     return checkDoStatement(node);
55685                 case 229:
55686                     return checkWhileStatement(node);
55687                 case 230:
55688                     return checkForStatement(node);
55689                 case 231:
55690                     return checkForInStatement(node);
55691                 case 232:
55692                     return checkForOfStatement(node);
55693                 case 233:
55694                 case 234:
55695                     return checkBreakOrContinueStatement(node);
55696                 case 235:
55697                     return checkReturnStatement(node);
55698                 case 236:
55699                     return checkWithStatement(node);
55700                 case 237:
55701                     return checkSwitchStatement(node);
55702                 case 238:
55703                     return checkLabeledStatement(node);
55704                 case 239:
55705                     return checkThrowStatement(node);
55706                 case 240:
55707                     return checkTryStatement(node);
55708                 case 242:
55709                     return checkVariableDeclaration(node);
55710                 case 191:
55711                     return checkBindingElement(node);
55712                 case 245:
55713                     return checkClassDeclaration(node);
55714                 case 246:
55715                     return checkInterfaceDeclaration(node);
55716                 case 247:
55717                     return checkTypeAliasDeclaration(node);
55718                 case 248:
55719                     return checkEnumDeclaration(node);
55720                 case 249:
55721                     return checkModuleDeclaration(node);
55722                 case 254:
55723                     return checkImportDeclaration(node);
55724                 case 253:
55725                     return checkImportEqualsDeclaration(node);
55726                 case 260:
55727                     return checkExportDeclaration(node);
55728                 case 259:
55729                     return checkExportAssignment(node);
55730                 case 224:
55731                 case 241:
55732                     checkGrammarStatementInAmbientContext(node);
55733                     return;
55734                 case 264:
55735                     return checkMissingDeclaration(node);
55736             }
55737         }
55738         function checkJSDocTypeIsInJsFile(node) {
55739             if (!ts.isInJSFile(node)) {
55740                 grammarErrorOnNode(node, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments);
55741             }
55742         }
55743         function checkJSDocVariadicType(node) {
55744             checkJSDocTypeIsInJsFile(node);
55745             checkSourceElement(node.type);
55746             var parent = node.parent;
55747             if (ts.isParameter(parent) && ts.isJSDocFunctionType(parent.parent)) {
55748                 if (ts.last(parent.parent.parameters) !== parent) {
55749                     error(node, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
55750                 }
55751                 return;
55752             }
55753             if (!ts.isJSDocTypeExpression(parent)) {
55754                 error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature);
55755             }
55756             var paramTag = node.parent.parent;
55757             if (!ts.isJSDocParameterTag(paramTag)) {
55758                 error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature);
55759                 return;
55760             }
55761             var param = ts.getParameterSymbolFromJSDoc(paramTag);
55762             if (!param) {
55763                 return;
55764             }
55765             var host = ts.getHostSignatureFromJSDoc(paramTag);
55766             if (!host || ts.last(host.parameters).symbol !== param) {
55767                 error(node, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
55768             }
55769         }
55770         function getTypeFromJSDocVariadicType(node) {
55771             var type = getTypeFromTypeNode(node.type);
55772             var parent = node.parent;
55773             var paramTag = node.parent.parent;
55774             if (ts.isJSDocTypeExpression(node.parent) && ts.isJSDocParameterTag(paramTag)) {
55775                 var host_1 = ts.getHostSignatureFromJSDoc(paramTag);
55776                 if (host_1) {
55777                     var lastParamDeclaration = ts.lastOrUndefined(host_1.parameters);
55778                     var symbol = ts.getParameterSymbolFromJSDoc(paramTag);
55779                     if (!lastParamDeclaration ||
55780                         symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) {
55781                         return createArrayType(type);
55782                     }
55783                 }
55784             }
55785             if (ts.isParameter(parent) && ts.isJSDocFunctionType(parent.parent)) {
55786                 return createArrayType(type);
55787             }
55788             return addOptionality(type);
55789         }
55790         function checkNodeDeferred(node) {
55791             var enclosingFile = ts.getSourceFileOfNode(node);
55792             var links = getNodeLinks(enclosingFile);
55793             if (!(links.flags & 1)) {
55794                 links.deferredNodes = links.deferredNodes || ts.createMap();
55795                 var id = "" + getNodeId(node);
55796                 links.deferredNodes.set(id, node);
55797             }
55798         }
55799         function checkDeferredNodes(context) {
55800             var links = getNodeLinks(context);
55801             if (links.deferredNodes) {
55802                 links.deferredNodes.forEach(checkDeferredNode);
55803             }
55804         }
55805         function checkDeferredNode(node) {
55806             var saveCurrentNode = currentNode;
55807             currentNode = node;
55808             instantiationCount = 0;
55809             switch (node.kind) {
55810                 case 196:
55811                 case 197:
55812                 case 198:
55813                 case 157:
55814                 case 268:
55815                     resolveUntypedCall(node);
55816                     break;
55817                 case 201:
55818                 case 202:
55819                 case 161:
55820                 case 160:
55821                     checkFunctionExpressionOrObjectLiteralMethodDeferred(node);
55822                     break;
55823                 case 163:
55824                 case 164:
55825                     checkAccessorDeclaration(node);
55826                     break;
55827                 case 214:
55828                     checkClassExpressionDeferred(node);
55829                     break;
55830                 case 267:
55831                     checkJsxSelfClosingElementDeferred(node);
55832                     break;
55833                 case 266:
55834                     checkJsxElementDeferred(node);
55835                     break;
55836             }
55837             currentNode = saveCurrentNode;
55838         }
55839         function checkSourceFile(node) {
55840             ts.performance.mark("beforeCheck");
55841             checkSourceFileWorker(node);
55842             ts.performance.mark("afterCheck");
55843             ts.performance.measure("Check", "beforeCheck", "afterCheck");
55844         }
55845         function unusedIsError(kind, isAmbient) {
55846             if (isAmbient) {
55847                 return false;
55848             }
55849             switch (kind) {
55850                 case 0:
55851                     return !!compilerOptions.noUnusedLocals;
55852                 case 1:
55853                     return !!compilerOptions.noUnusedParameters;
55854                 default:
55855                     return ts.Debug.assertNever(kind);
55856             }
55857         }
55858         function getPotentiallyUnusedIdentifiers(sourceFile) {
55859             return allPotentiallyUnusedIdentifiers.get(sourceFile.path) || ts.emptyArray;
55860         }
55861         function checkSourceFileWorker(node) {
55862             var links = getNodeLinks(node);
55863             if (!(links.flags & 1)) {
55864                 if (ts.skipTypeChecking(node, compilerOptions, host)) {
55865                     return;
55866                 }
55867                 checkGrammarSourceFile(node);
55868                 ts.clear(potentialThisCollisions);
55869                 ts.clear(potentialNewTargetCollisions);
55870                 ts.clear(potentialWeakMapCollisions);
55871                 ts.forEach(node.statements, checkSourceElement);
55872                 checkSourceElement(node.endOfFileToken);
55873                 checkDeferredNodes(node);
55874                 if (ts.isExternalOrCommonJsModule(node)) {
55875                     registerForUnusedIdentifiersCheck(node);
55876                 }
55877                 if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
55878                     checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
55879                         if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 8388608))) {
55880                             diagnostics.add(diag);
55881                         }
55882                     });
55883                 }
55884                 if (compilerOptions.importsNotUsedAsValues === 2 &&
55885                     !node.isDeclarationFile &&
55886                     ts.isExternalModule(node)) {
55887                     checkImportsForTypeOnlyConversion(node);
55888                 }
55889                 if (ts.isExternalOrCommonJsModule(node)) {
55890                     checkExternalModuleExports(node);
55891                 }
55892                 if (potentialThisCollisions.length) {
55893                     ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope);
55894                     ts.clear(potentialThisCollisions);
55895                 }
55896                 if (potentialNewTargetCollisions.length) {
55897                     ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope);
55898                     ts.clear(potentialNewTargetCollisions);
55899                 }
55900                 if (potentialWeakMapCollisions.length) {
55901                     ts.forEach(potentialWeakMapCollisions, checkWeakMapCollision);
55902                     ts.clear(potentialWeakMapCollisions);
55903                 }
55904                 links.flags |= 1;
55905             }
55906         }
55907         function getDiagnostics(sourceFile, ct) {
55908             try {
55909                 cancellationToken = ct;
55910                 return getDiagnosticsWorker(sourceFile);
55911             }
55912             finally {
55913                 cancellationToken = undefined;
55914             }
55915         }
55916         function getDiagnosticsWorker(sourceFile) {
55917             throwIfNonDiagnosticsProducing();
55918             if (sourceFile) {
55919                 var previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
55920                 var previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length;
55921                 checkSourceFile(sourceFile);
55922                 var semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
55923                 var currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
55924                 if (currentGlobalDiagnostics !== previousGlobalDiagnostics) {
55925                     var deferredGlobalDiagnostics = ts.relativeComplement(previousGlobalDiagnostics, currentGlobalDiagnostics, ts.compareDiagnostics);
55926                     return ts.concatenate(deferredGlobalDiagnostics, semanticDiagnostics);
55927                 }
55928                 else if (previousGlobalDiagnosticsSize === 0 && currentGlobalDiagnostics.length > 0) {
55929                     return ts.concatenate(currentGlobalDiagnostics, semanticDiagnostics);
55930                 }
55931                 return semanticDiagnostics;
55932             }
55933             ts.forEach(host.getSourceFiles(), checkSourceFile);
55934             return diagnostics.getDiagnostics();
55935         }
55936         function getGlobalDiagnostics() {
55937             throwIfNonDiagnosticsProducing();
55938             return diagnostics.getGlobalDiagnostics();
55939         }
55940         function throwIfNonDiagnosticsProducing() {
55941             if (!produceDiagnostics) {
55942                 throw new Error("Trying to get diagnostics from a type checker that does not produce them.");
55943             }
55944         }
55945         function getSymbolsInScope(location, meaning) {
55946             if (location.flags & 16777216) {
55947                 return [];
55948             }
55949             var symbols = ts.createSymbolTable();
55950             var isStatic = false;
55951             populateSymbols();
55952             symbols.delete("this");
55953             return symbolsToArray(symbols);
55954             function populateSymbols() {
55955                 while (location) {
55956                     if (location.locals && !isGlobalSourceFile(location)) {
55957                         copySymbols(location.locals, meaning);
55958                     }
55959                     switch (location.kind) {
55960                         case 290:
55961                             if (!ts.isExternalOrCommonJsModule(location))
55962                                 break;
55963                         case 249:
55964                             copySymbols(getSymbolOfNode(location).exports, meaning & 2623475);
55965                             break;
55966                         case 248:
55967                             copySymbols(getSymbolOfNode(location).exports, meaning & 8);
55968                             break;
55969                         case 214:
55970                             var className = location.name;
55971                             if (className) {
55972                                 copySymbol(location.symbol, meaning);
55973                             }
55974                         case 245:
55975                         case 246:
55976                             if (!isStatic) {
55977                                 copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968);
55978                             }
55979                             break;
55980                         case 201:
55981                             var funcName = location.name;
55982                             if (funcName) {
55983                                 copySymbol(location.symbol, meaning);
55984                             }
55985                             break;
55986                     }
55987                     if (ts.introducesArgumentsExoticObject(location)) {
55988                         copySymbol(argumentsSymbol, meaning);
55989                     }
55990                     isStatic = ts.hasModifier(location, 32);
55991                     location = location.parent;
55992                 }
55993                 copySymbols(globals, meaning);
55994             }
55995             function copySymbol(symbol, meaning) {
55996                 if (ts.getCombinedLocalAndExportSymbolFlags(symbol) & meaning) {
55997                     var id = symbol.escapedName;
55998                     if (!symbols.has(id)) {
55999                         symbols.set(id, symbol);
56000                     }
56001                 }
56002             }
56003             function copySymbols(source, meaning) {
56004                 if (meaning) {
56005                     source.forEach(function (symbol) {
56006                         copySymbol(symbol, meaning);
56007                     });
56008                 }
56009             }
56010         }
56011         function isTypeDeclarationName(name) {
56012             return name.kind === 75 &&
56013                 isTypeDeclaration(name.parent) &&
56014                 name.parent.name === name;
56015         }
56016         function isTypeDeclaration(node) {
56017             switch (node.kind) {
56018                 case 155:
56019                 case 245:
56020                 case 246:
56021                 case 247:
56022                 case 248:
56023                     return true;
56024                 case 255:
56025                     return node.isTypeOnly;
56026                 case 258:
56027                 case 263:
56028                     return node.parent.parent.isTypeOnly;
56029                 default:
56030                     return false;
56031             }
56032         }
56033         function isTypeReferenceIdentifier(node) {
56034             while (node.parent.kind === 153) {
56035                 node = node.parent;
56036             }
56037             return node.parent.kind === 169;
56038         }
56039         function isHeritageClauseElementIdentifier(node) {
56040             while (node.parent.kind === 194) {
56041                 node = node.parent;
56042             }
56043             return node.parent.kind === 216;
56044         }
56045         function forEachEnclosingClass(node, callback) {
56046             var result;
56047             while (true) {
56048                 node = ts.getContainingClass(node);
56049                 if (!node)
56050                     break;
56051                 if (result = callback(node))
56052                     break;
56053             }
56054             return result;
56055         }
56056         function isNodeUsedDuringClassInitialization(node) {
56057             return !!ts.findAncestor(node, function (element) {
56058                 if (ts.isConstructorDeclaration(element) && ts.nodeIsPresent(element.body) || ts.isPropertyDeclaration(element)) {
56059                     return true;
56060                 }
56061                 else if (ts.isClassLike(element) || ts.isFunctionLikeDeclaration(element)) {
56062                     return "quit";
56063                 }
56064                 return false;
56065             });
56066         }
56067         function isNodeWithinClass(node, classDeclaration) {
56068             return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; });
56069         }
56070         function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) {
56071             while (nodeOnRightSide.parent.kind === 153) {
56072                 nodeOnRightSide = nodeOnRightSide.parent;
56073             }
56074             if (nodeOnRightSide.parent.kind === 253) {
56075                 return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined;
56076             }
56077             if (nodeOnRightSide.parent.kind === 259) {
56078                 return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined;
56079             }
56080             return undefined;
56081         }
56082         function isInRightSideOfImportOrExportAssignment(node) {
56083             return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined;
56084         }
56085         function getSpecialPropertyAssignmentSymbolFromEntityName(entityName) {
56086             var specialPropertyAssignmentKind = ts.getAssignmentDeclarationKind(entityName.parent.parent);
56087             switch (specialPropertyAssignmentKind) {
56088                 case 1:
56089                 case 3:
56090                     return getSymbolOfNode(entityName.parent);
56091                 case 4:
56092                 case 2:
56093                 case 5:
56094                     return getSymbolOfNode(entityName.parent.parent);
56095             }
56096         }
56097         function isImportTypeQualifierPart(node) {
56098             var parent = node.parent;
56099             while (ts.isQualifiedName(parent)) {
56100                 node = parent;
56101                 parent = parent.parent;
56102             }
56103             if (parent && parent.kind === 188 && parent.qualifier === node) {
56104                 return parent;
56105             }
56106             return undefined;
56107         }
56108         function getSymbolOfNameOrPropertyAccessExpression(name) {
56109             if (ts.isDeclarationName(name)) {
56110                 return getSymbolOfNode(name.parent);
56111             }
56112             if (ts.isInJSFile(name) &&
56113                 name.parent.kind === 194 &&
56114                 name.parent === name.parent.parent.left) {
56115                 if (!ts.isPrivateIdentifier(name)) {
56116                     var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(name);
56117                     if (specialPropertyAssignmentSymbol) {
56118                         return specialPropertyAssignmentSymbol;
56119                     }
56120                 }
56121             }
56122             if (name.parent.kind === 259 && ts.isEntityNameExpression(name)) {
56123                 var success = resolveEntityName(name, 111551 | 788968 | 1920 | 2097152, true);
56124                 if (success && success !== unknownSymbol) {
56125                     return success;
56126                 }
56127             }
56128             else if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name) && isInRightSideOfImportOrExportAssignment(name)) {
56129                 var importEqualsDeclaration = ts.getAncestor(name, 253);
56130                 ts.Debug.assert(importEqualsDeclaration !== undefined);
56131                 return getSymbolOfPartOfRightHandSideOfImportEquals(name, true);
56132             }
56133             if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name)) {
56134                 var possibleImportNode = isImportTypeQualifierPart(name);
56135                 if (possibleImportNode) {
56136                     getTypeFromTypeNode(possibleImportNode);
56137                     var sym = getNodeLinks(name).resolvedSymbol;
56138                     return sym === unknownSymbol ? undefined : sym;
56139                 }
56140             }
56141             while (ts.isRightSideOfQualifiedNameOrPropertyAccess(name)) {
56142                 name = name.parent;
56143             }
56144             if (isHeritageClauseElementIdentifier(name)) {
56145                 var meaning = 0;
56146                 if (name.parent.kind === 216) {
56147                     meaning = 788968;
56148                     if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) {
56149                         meaning |= 111551;
56150                     }
56151                 }
56152                 else {
56153                     meaning = 1920;
56154                 }
56155                 meaning |= 2097152;
56156                 var entityNameSymbol = ts.isEntityNameExpression(name) ? resolveEntityName(name, meaning) : undefined;
56157                 if (entityNameSymbol) {
56158                     return entityNameSymbol;
56159                 }
56160             }
56161             if (name.parent.kind === 317) {
56162                 return ts.getParameterSymbolFromJSDoc(name.parent);
56163             }
56164             if (name.parent.kind === 155 && name.parent.parent.kind === 321) {
56165                 ts.Debug.assert(!ts.isInJSFile(name));
56166                 var typeParameter = ts.getTypeParameterFromJsDoc(name.parent);
56167                 return typeParameter && typeParameter.symbol;
56168             }
56169             if (ts.isExpressionNode(name)) {
56170                 if (ts.nodeIsMissing(name)) {
56171                     return undefined;
56172                 }
56173                 if (name.kind === 75) {
56174                     if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) {
56175                         var symbol = getIntrinsicTagSymbol(name.parent);
56176                         return symbol === unknownSymbol ? undefined : symbol;
56177                     }
56178                     return resolveEntityName(name, 111551, false, true);
56179                 }
56180                 else if (name.kind === 194 || name.kind === 153) {
56181                     var links = getNodeLinks(name);
56182                     if (links.resolvedSymbol) {
56183                         return links.resolvedSymbol;
56184                     }
56185                     if (name.kind === 194) {
56186                         checkPropertyAccessExpression(name);
56187                     }
56188                     else {
56189                         checkQualifiedName(name);
56190                     }
56191                     return links.resolvedSymbol;
56192                 }
56193             }
56194             else if (isTypeReferenceIdentifier(name)) {
56195                 var meaning = name.parent.kind === 169 ? 788968 : 1920;
56196                 return resolveEntityName(name, meaning, false, true);
56197             }
56198             if (name.parent.kind === 168) {
56199                 return resolveEntityName(name, 1);
56200             }
56201             return undefined;
56202         }
56203         function getSymbolAtLocation(node, ignoreErrors) {
56204             if (node.kind === 290) {
56205                 return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined;
56206             }
56207             var parent = node.parent;
56208             var grandParent = parent.parent;
56209             if (node.flags & 16777216) {
56210                 return undefined;
56211             }
56212             if (isDeclarationNameOrImportPropertyName(node)) {
56213                 var parentSymbol = getSymbolOfNode(parent);
56214                 return ts.isImportOrExportSpecifier(node.parent) && node.parent.propertyName === node
56215                     ? getImmediateAliasedSymbol(parentSymbol)
56216                     : parentSymbol;
56217             }
56218             else if (ts.isLiteralComputedPropertyDeclarationName(node)) {
56219                 return getSymbolOfNode(parent.parent);
56220             }
56221             if (node.kind === 75) {
56222                 if (isInRightSideOfImportOrExportAssignment(node)) {
56223                     return getSymbolOfNameOrPropertyAccessExpression(node);
56224                 }
56225                 else if (parent.kind === 191 &&
56226                     grandParent.kind === 189 &&
56227                     node === parent.propertyName) {
56228                     var typeOfPattern = getTypeOfNode(grandParent);
56229                     var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText);
56230                     if (propertyDeclaration) {
56231                         return propertyDeclaration;
56232                     }
56233                 }
56234             }
56235             switch (node.kind) {
56236                 case 75:
56237                 case 76:
56238                 case 194:
56239                 case 153:
56240                     return getSymbolOfNameOrPropertyAccessExpression(node);
56241                 case 104:
56242                     var container = ts.getThisContainer(node, false);
56243                     if (ts.isFunctionLike(container)) {
56244                         var sig = getSignatureFromDeclaration(container);
56245                         if (sig.thisParameter) {
56246                             return sig.thisParameter;
56247                         }
56248                     }
56249                     if (ts.isInExpressionContext(node)) {
56250                         return checkExpression(node).symbol;
56251                     }
56252                 case 183:
56253                     return getTypeFromThisTypeNode(node).symbol;
56254                 case 102:
56255                     return checkExpression(node).symbol;
56256                 case 129:
56257                     var constructorDeclaration = node.parent;
56258                     if (constructorDeclaration && constructorDeclaration.kind === 162) {
56259                         return constructorDeclaration.parent.symbol;
56260                     }
56261                     return undefined;
56262                 case 10:
56263                 case 14:
56264                     if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) ||
56265                         ((node.parent.kind === 254 || node.parent.kind === 260) && node.parent.moduleSpecifier === node) ||
56266                         ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, false)) || ts.isImportCall(node.parent)) ||
56267                         (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) {
56268                         return resolveExternalModuleName(node, node, ignoreErrors);
56269                     }
56270                     if (ts.isCallExpression(parent) && ts.isBindableObjectDefinePropertyCall(parent) && parent.arguments[1] === node) {
56271                         return getSymbolOfNode(parent);
56272                     }
56273                 case 8:
56274                     var objectType = ts.isElementAccessExpression(parent)
56275                         ? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined
56276                         : ts.isLiteralTypeNode(parent) && ts.isIndexedAccessTypeNode(grandParent)
56277                             ? getTypeFromTypeNode(grandParent.objectType)
56278                             : undefined;
56279                     return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text));
56280                 case 84:
56281                 case 94:
56282                 case 38:
56283                 case 80:
56284                     return getSymbolOfNode(node.parent);
56285                 case 188:
56286                     return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined;
56287                 case 89:
56288                     return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined;
56289                 default:
56290                     return undefined;
56291             }
56292         }
56293         function getShorthandAssignmentValueSymbol(location) {
56294             if (location && location.kind === 282) {
56295                 return resolveEntityName(location.name, 111551 | 2097152);
56296             }
56297             return undefined;
56298         }
56299         function getExportSpecifierLocalTargetSymbol(node) {
56300             return node.parent.parent.moduleSpecifier ?
56301                 getExternalModuleMember(node.parent.parent, node) :
56302                 resolveEntityName(node.propertyName || node.name, 111551 | 788968 | 1920 | 2097152);
56303         }
56304         function getTypeOfNode(node) {
56305             if (node.flags & 16777216) {
56306                 return errorType;
56307             }
56308             var classDecl = ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node);
56309             var classType = classDecl && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(classDecl.class));
56310             if (ts.isPartOfTypeNode(node)) {
56311                 var typeFromTypeNode = getTypeFromTypeNode(node);
56312                 return classType ? getTypeWithThisArgument(typeFromTypeNode, classType.thisType) : typeFromTypeNode;
56313             }
56314             if (ts.isExpressionNode(node)) {
56315                 return getRegularTypeOfExpression(node);
56316             }
56317             if (classType && !classDecl.isImplements) {
56318                 var baseType = ts.firstOrUndefined(getBaseTypes(classType));
56319                 return baseType ? getTypeWithThisArgument(baseType, classType.thisType) : errorType;
56320             }
56321             if (isTypeDeclaration(node)) {
56322                 var symbol = getSymbolOfNode(node);
56323                 return getDeclaredTypeOfSymbol(symbol);
56324             }
56325             if (isTypeDeclarationName(node)) {
56326                 var symbol = getSymbolAtLocation(node);
56327                 return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType;
56328             }
56329             if (ts.isDeclaration(node)) {
56330                 var symbol = getSymbolOfNode(node);
56331                 return getTypeOfSymbol(symbol);
56332             }
56333             if (isDeclarationNameOrImportPropertyName(node)) {
56334                 var symbol = getSymbolAtLocation(node);
56335                 if (symbol) {
56336                     return getTypeOfSymbol(symbol);
56337                 }
56338                 return errorType;
56339             }
56340             if (ts.isBindingPattern(node)) {
56341                 return getTypeForVariableLikeDeclaration(node.parent, true) || errorType;
56342             }
56343             if (isInRightSideOfImportOrExportAssignment(node)) {
56344                 var symbol = getSymbolAtLocation(node);
56345                 if (symbol) {
56346                     var declaredType = getDeclaredTypeOfSymbol(symbol);
56347                     return declaredType !== errorType ? declaredType : getTypeOfSymbol(symbol);
56348                 }
56349             }
56350             return errorType;
56351         }
56352         function getTypeOfAssignmentPattern(expr) {
56353             ts.Debug.assert(expr.kind === 193 || expr.kind === 192);
56354             if (expr.parent.kind === 232) {
56355                 var iteratedType = checkRightHandSideOfForOf(expr.parent);
56356                 return checkDestructuringAssignment(expr, iteratedType || errorType);
56357             }
56358             if (expr.parent.kind === 209) {
56359                 var iteratedType = getTypeOfExpression(expr.parent.right);
56360                 return checkDestructuringAssignment(expr, iteratedType || errorType);
56361             }
56362             if (expr.parent.kind === 281) {
56363                 var node_4 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
56364                 var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_4) || errorType;
56365                 var propertyIndex = ts.indexOfNode(node_4.properties, expr.parent);
56366                 return checkObjectLiteralDestructuringPropertyAssignment(node_4, typeOfParentObjectLiteral, propertyIndex);
56367             }
56368             var node = ts.cast(expr.parent, ts.isArrayLiteralExpression);
56369             var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType;
56370             var elementType = checkIteratedTypeOrElementType(65, typeOfArrayLiteral, undefinedType, expr.parent) || errorType;
56371             return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType);
56372         }
56373         function getPropertySymbolOfDestructuringAssignment(location) {
56374             var typeOfObjectLiteral = getTypeOfAssignmentPattern(ts.cast(location.parent.parent, ts.isAssignmentPattern));
56375             return typeOfObjectLiteral && getPropertyOfType(typeOfObjectLiteral, location.escapedText);
56376         }
56377         function getRegularTypeOfExpression(expr) {
56378             if (ts.isRightSideOfQualifiedNameOrPropertyAccess(expr)) {
56379                 expr = expr.parent;
56380             }
56381             return getRegularTypeOfLiteralType(getTypeOfExpression(expr));
56382         }
56383         function getParentTypeOfClassElement(node) {
56384             var classSymbol = getSymbolOfNode(node.parent);
56385             return ts.hasModifier(node, 32)
56386                 ? getTypeOfSymbol(classSymbol)
56387                 : getDeclaredTypeOfSymbol(classSymbol);
56388         }
56389         function getClassElementPropertyKeyType(element) {
56390             var name = element.name;
56391             switch (name.kind) {
56392                 case 75:
56393                     return getLiteralType(ts.idText(name));
56394                 case 8:
56395                 case 10:
56396                     return getLiteralType(name.text);
56397                 case 154:
56398                     var nameType = checkComputedPropertyName(name);
56399                     return isTypeAssignableToKind(nameType, 12288) ? nameType : stringType;
56400                 default:
56401                     return ts.Debug.fail("Unsupported property name.");
56402             }
56403         }
56404         function getAugmentedPropertiesOfType(type) {
56405             type = getApparentType(type);
56406             var propsByName = ts.createSymbolTable(getPropertiesOfType(type));
56407             var functionType = getSignaturesOfType(type, 0).length ? globalCallableFunctionType :
56408                 getSignaturesOfType(type, 1).length ? globalNewableFunctionType :
56409                     undefined;
56410             if (functionType) {
56411                 ts.forEach(getPropertiesOfType(functionType), function (p) {
56412                     if (!propsByName.has(p.escapedName)) {
56413                         propsByName.set(p.escapedName, p);
56414                     }
56415                 });
56416             }
56417             return getNamedMembers(propsByName);
56418         }
56419         function typeHasCallOrConstructSignatures(type) {
56420             return ts.typeHasCallOrConstructSignatures(type, checker);
56421         }
56422         function getRootSymbols(symbol) {
56423             var roots = getImmediateRootSymbols(symbol);
56424             return roots ? ts.flatMap(roots, getRootSymbols) : [symbol];
56425         }
56426         function getImmediateRootSymbols(symbol) {
56427             if (ts.getCheckFlags(symbol) & 6) {
56428                 return ts.mapDefined(getSymbolLinks(symbol).containingType.types, function (type) { return getPropertyOfType(type, symbol.escapedName); });
56429             }
56430             else if (symbol.flags & 33554432) {
56431                 var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin;
56432                 return leftSpread ? [leftSpread, rightSpread]
56433                     : syntheticOrigin ? [syntheticOrigin]
56434                         : ts.singleElementArray(tryGetAliasTarget(symbol));
56435             }
56436             return undefined;
56437         }
56438         function tryGetAliasTarget(symbol) {
56439             var target;
56440             var next = symbol;
56441             while (next = getSymbolLinks(next).target) {
56442                 target = next;
56443             }
56444             return target;
56445         }
56446         function isArgumentsLocalBinding(nodeIn) {
56447             if (!ts.isGeneratedIdentifier(nodeIn)) {
56448                 var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
56449                 if (node) {
56450                     var isPropertyName_1 = node.parent.kind === 194 && node.parent.name === node;
56451                     return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol;
56452                 }
56453             }
56454             return false;
56455         }
56456         function moduleExportsSomeValue(moduleReferenceExpression) {
56457             var moduleSymbol = resolveExternalModuleName(moduleReferenceExpression.parent, moduleReferenceExpression);
56458             if (!moduleSymbol || ts.isShorthandAmbientModuleSymbol(moduleSymbol)) {
56459                 return true;
56460             }
56461             var hasExportAssignment = hasExportAssignmentSymbol(moduleSymbol);
56462             moduleSymbol = resolveExternalModuleSymbol(moduleSymbol);
56463             var symbolLinks = getSymbolLinks(moduleSymbol);
56464             if (symbolLinks.exportsSomeValue === undefined) {
56465                 symbolLinks.exportsSomeValue = hasExportAssignment
56466                     ? !!(moduleSymbol.flags & 111551)
56467                     : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue);
56468             }
56469             return symbolLinks.exportsSomeValue;
56470             function isValue(s) {
56471                 s = resolveSymbol(s);
56472                 return s && !!(s.flags & 111551);
56473             }
56474         }
56475         function isNameOfModuleOrEnumDeclaration(node) {
56476             return ts.isModuleOrEnumDeclaration(node.parent) && node === node.parent.name;
56477         }
56478         function getReferencedExportContainer(nodeIn, prefixLocals) {
56479             var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
56480             if (node) {
56481                 var symbol = getReferencedValueSymbol(node, isNameOfModuleOrEnumDeclaration(node));
56482                 if (symbol) {
56483                     if (symbol.flags & 1048576) {
56484                         var exportSymbol = getMergedSymbol(symbol.exportSymbol);
56485                         if (!prefixLocals && exportSymbol.flags & 944 && !(exportSymbol.flags & 3)) {
56486                             return undefined;
56487                         }
56488                         symbol = exportSymbol;
56489                     }
56490                     var parentSymbol_1 = getParentOfSymbol(symbol);
56491                     if (parentSymbol_1) {
56492                         if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 290) {
56493                             var symbolFile = parentSymbol_1.valueDeclaration;
56494                             var referenceFile = ts.getSourceFileOfNode(node);
56495                             var symbolIsUmdExport = symbolFile !== referenceFile;
56496                             return symbolIsUmdExport ? undefined : symbolFile;
56497                         }
56498                         return ts.findAncestor(node.parent, function (n) { return ts.isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol_1; });
56499                     }
56500                 }
56501             }
56502         }
56503         function getReferencedImportDeclaration(nodeIn) {
56504             var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
56505             if (node) {
56506                 var symbol = getReferencedValueSymbol(node);
56507                 if (isNonLocalAlias(symbol, 111551) && !getTypeOnlyAliasDeclaration(symbol)) {
56508                     return getDeclarationOfAliasSymbol(symbol);
56509                 }
56510             }
56511             return undefined;
56512         }
56513         function isSymbolOfDestructuredElementOfCatchBinding(symbol) {
56514             return ts.isBindingElement(symbol.valueDeclaration)
56515                 && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 280;
56516         }
56517         function isSymbolOfDeclarationWithCollidingName(symbol) {
56518             if (symbol.flags & 418 && !ts.isSourceFile(symbol.valueDeclaration)) {
56519                 var links = getSymbolLinks(symbol);
56520                 if (links.isDeclarationWithCollidingName === undefined) {
56521                     var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration);
56522                     if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) {
56523                         var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration);
56524                         if (resolveName(container.parent, symbol.escapedName, 111551, undefined, undefined, false)) {
56525                             links.isDeclarationWithCollidingName = true;
56526                         }
56527                         else if (nodeLinks_1.flags & 262144) {
56528                             var isDeclaredInLoop = nodeLinks_1.flags & 524288;
56529                             var inLoopInitializer = ts.isIterationStatement(container, false);
56530                             var inLoopBodyBlock = container.kind === 223 && ts.isIterationStatement(container.parent, false);
56531                             links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock));
56532                         }
56533                         else {
56534                             links.isDeclarationWithCollidingName = false;
56535                         }
56536                     }
56537                 }
56538                 return links.isDeclarationWithCollidingName;
56539             }
56540             return false;
56541         }
56542         function getReferencedDeclarationWithCollidingName(nodeIn) {
56543             if (!ts.isGeneratedIdentifier(nodeIn)) {
56544                 var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
56545                 if (node) {
56546                     var symbol = getReferencedValueSymbol(node);
56547                     if (symbol && isSymbolOfDeclarationWithCollidingName(symbol)) {
56548                         return symbol.valueDeclaration;
56549                     }
56550                 }
56551             }
56552             return undefined;
56553         }
56554         function isDeclarationWithCollidingName(nodeIn) {
56555             var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration);
56556             if (node) {
56557                 var symbol = getSymbolOfNode(node);
56558                 if (symbol) {
56559                     return isSymbolOfDeclarationWithCollidingName(symbol);
56560                 }
56561             }
56562             return false;
56563         }
56564         function isValueAliasDeclaration(node) {
56565             switch (node.kind) {
56566                 case 253:
56567                     return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol);
56568                 case 255:
56569                 case 256:
56570                 case 258:
56571                 case 263:
56572                     var symbol = getSymbolOfNode(node) || unknownSymbol;
56573                     return isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol);
56574                 case 260:
56575                     var exportClause = node.exportClause;
56576                     return !!exportClause && (ts.isNamespaceExport(exportClause) ||
56577                         ts.some(exportClause.elements, isValueAliasDeclaration));
56578                 case 259:
56579                     return node.expression && node.expression.kind === 75 ?
56580                         isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) :
56581                         true;
56582             }
56583             return false;
56584         }
56585         function isTopLevelValueImportEqualsWithEntityName(nodeIn) {
56586             var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration);
56587             if (node === undefined || node.parent.kind !== 290 || !ts.isInternalModuleImportEqualsDeclaration(node)) {
56588                 return false;
56589             }
56590             var isValue = isAliasResolvedToValue(getSymbolOfNode(node));
56591             return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference);
56592         }
56593         function isAliasResolvedToValue(symbol) {
56594             var target = resolveAlias(symbol);
56595             if (target === unknownSymbol) {
56596                 return true;
56597             }
56598             return !!(target.flags & 111551) &&
56599                 (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target));
56600         }
56601         function isConstEnumOrConstEnumOnlyModule(s) {
56602             return isConstEnumSymbol(s) || !!s.constEnumOnlyModule;
56603         }
56604         function isReferencedAliasDeclaration(node, checkChildren) {
56605             if (isAliasSymbolDeclaration(node)) {
56606                 var symbol = getSymbolOfNode(node);
56607                 if (symbol && getSymbolLinks(symbol).referenced) {
56608                     return true;
56609                 }
56610                 var target = getSymbolLinks(symbol).target;
56611                 if (target && ts.getModifierFlags(node) & 1 &&
56612                     target.flags & 111551 &&
56613                     (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) {
56614                     return true;
56615                 }
56616             }
56617             if (checkChildren) {
56618                 return !!ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); });
56619             }
56620             return false;
56621         }
56622         function isImplementationOfOverload(node) {
56623             if (ts.nodeIsPresent(node.body)) {
56624                 if (ts.isGetAccessor(node) || ts.isSetAccessor(node))
56625                     return false;
56626                 var symbol = getSymbolOfNode(node);
56627                 var signaturesOfSymbol = getSignaturesOfSymbol(symbol);
56628                 return signaturesOfSymbol.length > 1 ||
56629                     (signaturesOfSymbol.length === 1 && signaturesOfSymbol[0].declaration !== node);
56630             }
56631             return false;
56632         }
56633         function isRequiredInitializedParameter(parameter) {
56634             return !!strictNullChecks &&
56635                 !isOptionalParameter(parameter) &&
56636                 !ts.isJSDocParameterTag(parameter) &&
56637                 !!parameter.initializer &&
56638                 !ts.hasModifier(parameter, 92);
56639         }
56640         function isOptionalUninitializedParameterProperty(parameter) {
56641             return strictNullChecks &&
56642                 isOptionalParameter(parameter) &&
56643                 !parameter.initializer &&
56644                 ts.hasModifier(parameter, 92);
56645         }
56646         function isExpandoFunctionDeclaration(node) {
56647             var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
56648             if (!declaration) {
56649                 return false;
56650             }
56651             var symbol = getSymbolOfNode(declaration);
56652             if (!symbol || !(symbol.flags & 16)) {
56653                 return false;
56654             }
56655             return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); });
56656         }
56657         function getPropertiesOfContainerFunction(node) {
56658             var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
56659             if (!declaration) {
56660                 return ts.emptyArray;
56661             }
56662             var symbol = getSymbolOfNode(declaration);
56663             return symbol && getPropertiesOfType(getTypeOfSymbol(symbol)) || ts.emptyArray;
56664         }
56665         function getNodeCheckFlags(node) {
56666             return getNodeLinks(node).flags || 0;
56667         }
56668         function getEnumMemberValue(node) {
56669             computeEnumMemberValues(node.parent);
56670             return getNodeLinks(node).enumMemberValue;
56671         }
56672         function canHaveConstantValue(node) {
56673             switch (node.kind) {
56674                 case 284:
56675                 case 194:
56676                 case 195:
56677                     return true;
56678             }
56679             return false;
56680         }
56681         function getConstantValue(node) {
56682             if (node.kind === 284) {
56683                 return getEnumMemberValue(node);
56684             }
56685             var symbol = getNodeLinks(node).resolvedSymbol;
56686             if (symbol && (symbol.flags & 8)) {
56687                 var member = symbol.valueDeclaration;
56688                 if (ts.isEnumConst(member.parent)) {
56689                     return getEnumMemberValue(member);
56690                 }
56691             }
56692             return undefined;
56693         }
56694         function isFunctionType(type) {
56695             return !!(type.flags & 524288) && getSignaturesOfType(type, 0).length > 0;
56696         }
56697         function getTypeReferenceSerializationKind(typeNameIn, location) {
56698             var typeName = ts.getParseTreeNode(typeNameIn, ts.isEntityName);
56699             if (!typeName)
56700                 return ts.TypeReferenceSerializationKind.Unknown;
56701             if (location) {
56702                 location = ts.getParseTreeNode(location);
56703                 if (!location)
56704                     return ts.TypeReferenceSerializationKind.Unknown;
56705             }
56706             var valueSymbol = resolveEntityName(typeName, 111551, true, false, location);
56707             var typeSymbol = resolveEntityName(typeName, 788968, true, false, location);
56708             if (valueSymbol && valueSymbol === typeSymbol) {
56709                 var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(false);
56710                 if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) {
56711                     return ts.TypeReferenceSerializationKind.Promise;
56712                 }
56713                 var constructorType = getTypeOfSymbol(valueSymbol);
56714                 if (constructorType && isConstructorType(constructorType)) {
56715                     return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue;
56716                 }
56717             }
56718             if (!typeSymbol) {
56719                 return ts.TypeReferenceSerializationKind.Unknown;
56720             }
56721             var type = getDeclaredTypeOfSymbol(typeSymbol);
56722             if (type === errorType) {
56723                 return ts.TypeReferenceSerializationKind.Unknown;
56724             }
56725             else if (type.flags & 3) {
56726                 return ts.TypeReferenceSerializationKind.ObjectType;
56727             }
56728             else if (isTypeAssignableToKind(type, 16384 | 98304 | 131072)) {
56729                 return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType;
56730             }
56731             else if (isTypeAssignableToKind(type, 528)) {
56732                 return ts.TypeReferenceSerializationKind.BooleanType;
56733             }
56734             else if (isTypeAssignableToKind(type, 296)) {
56735                 return ts.TypeReferenceSerializationKind.NumberLikeType;
56736             }
56737             else if (isTypeAssignableToKind(type, 2112)) {
56738                 return ts.TypeReferenceSerializationKind.BigIntLikeType;
56739             }
56740             else if (isTypeAssignableToKind(type, 132)) {
56741                 return ts.TypeReferenceSerializationKind.StringLikeType;
56742             }
56743             else if (isTupleType(type)) {
56744                 return ts.TypeReferenceSerializationKind.ArrayLikeType;
56745             }
56746             else if (isTypeAssignableToKind(type, 12288)) {
56747                 return ts.TypeReferenceSerializationKind.ESSymbolType;
56748             }
56749             else if (isFunctionType(type)) {
56750                 return ts.TypeReferenceSerializationKind.TypeWithCallSignature;
56751             }
56752             else if (isArrayType(type)) {
56753                 return ts.TypeReferenceSerializationKind.ArrayLikeType;
56754             }
56755             else {
56756                 return ts.TypeReferenceSerializationKind.ObjectType;
56757             }
56758         }
56759         function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) {
56760             var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor);
56761             if (!declaration) {
56762                 return ts.createToken(125);
56763             }
56764             var symbol = getSymbolOfNode(declaration);
56765             var type = symbol && !(symbol.flags & (2048 | 131072))
56766                 ? getWidenedLiteralType(getTypeOfSymbol(symbol))
56767                 : errorType;
56768             if (type.flags & 8192 &&
56769                 type.symbol === symbol) {
56770                 flags |= 1048576;
56771             }
56772             if (addUndefined) {
56773                 type = getOptionalType(type);
56774             }
56775             return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024, tracker);
56776         }
56777         function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) {
56778             var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike);
56779             if (!signatureDeclaration) {
56780                 return ts.createToken(125);
56781             }
56782             var signature = getSignatureFromDeclaration(signatureDeclaration);
56783             return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024, tracker);
56784         }
56785         function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) {
56786             var expr = ts.getParseTreeNode(exprIn, ts.isExpression);
56787             if (!expr) {
56788                 return ts.createToken(125);
56789             }
56790             var type = getWidenedType(getRegularTypeOfExpression(expr));
56791             return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024, tracker);
56792         }
56793         function hasGlobalName(name) {
56794             return globals.has(ts.escapeLeadingUnderscores(name));
56795         }
56796         function getReferencedValueSymbol(reference, startInDeclarationContainer) {
56797             var resolvedSymbol = getNodeLinks(reference).resolvedSymbol;
56798             if (resolvedSymbol) {
56799                 return resolvedSymbol;
56800             }
56801             var location = reference;
56802             if (startInDeclarationContainer) {
56803                 var parent = reference.parent;
56804                 if (ts.isDeclaration(parent) && reference === parent.name) {
56805                     location = getDeclarationContainer(parent);
56806                 }
56807             }
56808             return resolveName(location, reference.escapedText, 111551 | 1048576 | 2097152, undefined, undefined, true);
56809         }
56810         function getReferencedValueDeclaration(referenceIn) {
56811             if (!ts.isGeneratedIdentifier(referenceIn)) {
56812                 var reference = ts.getParseTreeNode(referenceIn, ts.isIdentifier);
56813                 if (reference) {
56814                     var symbol = getReferencedValueSymbol(reference);
56815                     if (symbol) {
56816                         return getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration;
56817                     }
56818                 }
56819             }
56820             return undefined;
56821         }
56822         function isLiteralConstDeclaration(node) {
56823             if (ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) {
56824                 return isFreshLiteralType(getTypeOfSymbol(getSymbolOfNode(node)));
56825             }
56826             return false;
56827         }
56828         function literalTypeToNode(type, enclosing, tracker) {
56829             var enumResult = type.flags & 1024 ? nodeBuilder.symbolToExpression(type.symbol, 111551, enclosing, undefined, tracker)
56830                 : type === trueType ? ts.createTrue() : type === falseType && ts.createFalse();
56831             return enumResult || ts.createLiteral(type.value);
56832         }
56833         function createLiteralConstValue(node, tracker) {
56834             var type = getTypeOfSymbol(getSymbolOfNode(node));
56835             return literalTypeToNode(type, node, tracker);
56836         }
56837         function getJsxFactoryEntity(location) {
56838             return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity;
56839         }
56840         function createResolver() {
56841             var resolvedTypeReferenceDirectives = host.getResolvedTypeReferenceDirectives();
56842             var fileToDirective;
56843             if (resolvedTypeReferenceDirectives) {
56844                 fileToDirective = ts.createMap();
56845                 resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) {
56846                     if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
56847                         return;
56848                     }
56849                     var file = host.getSourceFile(resolvedDirective.resolvedFileName);
56850                     if (file) {
56851                         addReferencedFilesToTypeDirective(file, key);
56852                     }
56853                 });
56854             }
56855             return {
56856                 getReferencedExportContainer: getReferencedExportContainer,
56857                 getReferencedImportDeclaration: getReferencedImportDeclaration,
56858                 getReferencedDeclarationWithCollidingName: getReferencedDeclarationWithCollidingName,
56859                 isDeclarationWithCollidingName: isDeclarationWithCollidingName,
56860                 isValueAliasDeclaration: function (node) {
56861                     node = ts.getParseTreeNode(node);
56862                     return node ? isValueAliasDeclaration(node) : true;
56863                 },
56864                 hasGlobalName: hasGlobalName,
56865                 isReferencedAliasDeclaration: function (node, checkChildren) {
56866                     node = ts.getParseTreeNode(node);
56867                     return node ? isReferencedAliasDeclaration(node, checkChildren) : true;
56868                 },
56869                 getNodeCheckFlags: function (node) {
56870                     node = ts.getParseTreeNode(node);
56871                     return node ? getNodeCheckFlags(node) : 0;
56872                 },
56873                 isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName,
56874                 isDeclarationVisible: isDeclarationVisible,
56875                 isImplementationOfOverload: isImplementationOfOverload,
56876                 isRequiredInitializedParameter: isRequiredInitializedParameter,
56877                 isOptionalUninitializedParameterProperty: isOptionalUninitializedParameterProperty,
56878                 isExpandoFunctionDeclaration: isExpandoFunctionDeclaration,
56879                 getPropertiesOfContainerFunction: getPropertiesOfContainerFunction,
56880                 createTypeOfDeclaration: createTypeOfDeclaration,
56881                 createReturnTypeOfSignatureDeclaration: createReturnTypeOfSignatureDeclaration,
56882                 createTypeOfExpression: createTypeOfExpression,
56883                 createLiteralConstValue: createLiteralConstValue,
56884                 isSymbolAccessible: isSymbolAccessible,
56885                 isEntityNameVisible: isEntityNameVisible,
56886                 getConstantValue: function (nodeIn) {
56887                     var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue);
56888                     return node ? getConstantValue(node) : undefined;
56889                 },
56890                 collectLinkedAliases: collectLinkedAliases,
56891                 getReferencedValueDeclaration: getReferencedValueDeclaration,
56892                 getTypeReferenceSerializationKind: getTypeReferenceSerializationKind,
56893                 isOptionalParameter: isOptionalParameter,
56894                 moduleExportsSomeValue: moduleExportsSomeValue,
56895                 isArgumentsLocalBinding: isArgumentsLocalBinding,
56896                 getExternalModuleFileFromDeclaration: getExternalModuleFileFromDeclaration,
56897                 getTypeReferenceDirectivesForEntityName: getTypeReferenceDirectivesForEntityName,
56898                 getTypeReferenceDirectivesForSymbol: getTypeReferenceDirectivesForSymbol,
56899                 isLiteralConstDeclaration: isLiteralConstDeclaration,
56900                 isLateBound: function (nodeIn) {
56901                     var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration);
56902                     var symbol = node && getSymbolOfNode(node);
56903                     return !!(symbol && ts.getCheckFlags(symbol) & 4096);
56904                 },
56905                 getJsxFactoryEntity: getJsxFactoryEntity,
56906                 getAllAccessorDeclarations: function (accessor) {
56907                     accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration);
56908                     var otherKind = accessor.kind === 164 ? 163 : 164;
56909                     var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind);
56910                     var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor;
56911                     var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor;
56912                     var setAccessor = accessor.kind === 164 ? accessor : otherAccessor;
56913                     var getAccessor = accessor.kind === 163 ? accessor : otherAccessor;
56914                     return {
56915                         firstAccessor: firstAccessor,
56916                         secondAccessor: secondAccessor,
56917                         setAccessor: setAccessor,
56918                         getAccessor: getAccessor
56919                     };
56920                 },
56921                 getSymbolOfExternalModuleSpecifier: function (moduleName) { return resolveExternalModuleNameWorker(moduleName, moduleName, undefined); },
56922                 isBindingCapturedByNode: function (node, decl) {
56923                     var parseNode = ts.getParseTreeNode(node);
56924                     var parseDecl = ts.getParseTreeNode(decl);
56925                     return !!parseNode && !!parseDecl && (ts.isVariableDeclaration(parseDecl) || ts.isBindingElement(parseDecl)) && isBindingCapturedByNode(parseNode, parseDecl);
56926                 },
56927                 getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) {
56928                     var n = ts.getParseTreeNode(node);
56929                     ts.Debug.assert(n && n.kind === 290, "Non-sourcefile node passed into getDeclarationsForSourceFile");
56930                     var sym = getSymbolOfNode(node);
56931                     if (!sym) {
56932                         return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled);
56933                     }
56934                     return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled);
56935                 },
56936                 isImportRequiredByAugmentation: isImportRequiredByAugmentation,
56937             };
56938             function isImportRequiredByAugmentation(node) {
56939                 var file = ts.getSourceFileOfNode(node);
56940                 if (!file.symbol)
56941                     return false;
56942                 var importTarget = getExternalModuleFileFromDeclaration(node);
56943                 if (!importTarget)
56944                     return false;
56945                 if (importTarget === file)
56946                     return false;
56947                 var exports = getExportsOfModule(file.symbol);
56948                 for (var _i = 0, _a = ts.arrayFrom(exports.values()); _i < _a.length; _i++) {
56949                     var s = _a[_i];
56950                     if (s.mergeId) {
56951                         var merged = getMergedSymbol(s);
56952                         for (var _b = 0, _c = merged.declarations; _b < _c.length; _b++) {
56953                             var d = _c[_b];
56954                             var declFile = ts.getSourceFileOfNode(d);
56955                             if (declFile === importTarget) {
56956                                 return true;
56957                             }
56958                         }
56959                     }
56960                 }
56961                 return false;
56962             }
56963             function isInHeritageClause(node) {
56964                 return node.parent && node.parent.kind === 216 && node.parent.parent && node.parent.parent.kind === 279;
56965             }
56966             function getTypeReferenceDirectivesForEntityName(node) {
56967                 if (!fileToDirective) {
56968                     return undefined;
56969                 }
56970                 var meaning = 788968 | 1920;
56971                 if ((node.kind === 75 && isInTypeQuery(node)) || (node.kind === 194 && !isInHeritageClause(node))) {
56972                     meaning = 111551 | 1048576;
56973                 }
56974                 var symbol = resolveEntityName(node, meaning, true);
56975                 return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined;
56976             }
56977             function getTypeReferenceDirectivesForSymbol(symbol, meaning) {
56978                 if (!fileToDirective) {
56979                     return undefined;
56980                 }
56981                 if (!isSymbolFromTypeDeclarationFile(symbol)) {
56982                     return undefined;
56983                 }
56984                 var typeReferenceDirectives;
56985                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
56986                     var decl = _a[_i];
56987                     if (decl.symbol && decl.symbol.flags & meaning) {
56988                         var file = ts.getSourceFileOfNode(decl);
56989                         var typeReferenceDirective = fileToDirective.get(file.path);
56990                         if (typeReferenceDirective) {
56991                             (typeReferenceDirectives || (typeReferenceDirectives = [])).push(typeReferenceDirective);
56992                         }
56993                         else {
56994                             return undefined;
56995                         }
56996                     }
56997                 }
56998                 return typeReferenceDirectives;
56999             }
57000             function isSymbolFromTypeDeclarationFile(symbol) {
57001                 if (!symbol.declarations) {
57002                     return false;
57003                 }
57004                 var current = symbol;
57005                 while (true) {
57006                     var parent = getParentOfSymbol(current);
57007                     if (parent) {
57008                         current = parent;
57009                     }
57010                     else {
57011                         break;
57012                     }
57013                 }
57014                 if (current.valueDeclaration && current.valueDeclaration.kind === 290 && current.flags & 512) {
57015                     return false;
57016                 }
57017                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
57018                     var decl = _a[_i];
57019                     var file = ts.getSourceFileOfNode(decl);
57020                     if (fileToDirective.has(file.path)) {
57021                         return true;
57022                     }
57023                 }
57024                 return false;
57025             }
57026             function addReferencedFilesToTypeDirective(file, key) {
57027                 if (fileToDirective.has(file.path))
57028                     return;
57029                 fileToDirective.set(file.path, key);
57030                 for (var _i = 0, _a = file.referencedFiles; _i < _a.length; _i++) {
57031                     var fileName = _a[_i].fileName;
57032                     var resolvedFile = ts.resolveTripleslashReference(fileName, file.originalFileName);
57033                     var referencedFile = host.getSourceFile(resolvedFile);
57034                     if (referencedFile) {
57035                         addReferencedFilesToTypeDirective(referencedFile, key);
57036                     }
57037                 }
57038             }
57039         }
57040         function getExternalModuleFileFromDeclaration(declaration) {
57041             var specifier = declaration.kind === 249 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration);
57042             var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, undefined);
57043             if (!moduleSymbol) {
57044                 return undefined;
57045             }
57046             return ts.getDeclarationOfKind(moduleSymbol, 290);
57047         }
57048         function initializeTypeChecker() {
57049             for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) {
57050                 var file = _a[_i];
57051                 ts.bindSourceFile(file, compilerOptions);
57052             }
57053             amalgamatedDuplicates = ts.createMap();
57054             var augmentations;
57055             for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) {
57056                 var file = _c[_b];
57057                 if (file.redirectInfo) {
57058                     continue;
57059                 }
57060                 if (!ts.isExternalOrCommonJsModule(file)) {
57061                     var fileGlobalThisSymbol = file.locals.get("globalThis");
57062                     if (fileGlobalThisSymbol) {
57063                         for (var _d = 0, _e = fileGlobalThisSymbol.declarations; _d < _e.length; _d++) {
57064                             var declaration = _e[_d];
57065                             diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0, "globalThis"));
57066                         }
57067                     }
57068                     mergeSymbolTable(globals, file.locals);
57069                 }
57070                 if (file.jsGlobalAugmentations) {
57071                     mergeSymbolTable(globals, file.jsGlobalAugmentations);
57072                 }
57073                 if (file.patternAmbientModules && file.patternAmbientModules.length) {
57074                     patternAmbientModules = ts.concatenate(patternAmbientModules, file.patternAmbientModules);
57075                 }
57076                 if (file.moduleAugmentations.length) {
57077                     (augmentations || (augmentations = [])).push(file.moduleAugmentations);
57078                 }
57079                 if (file.symbol && file.symbol.globalExports) {
57080                     var source = file.symbol.globalExports;
57081                     source.forEach(function (sourceSymbol, id) {
57082                         if (!globals.has(id)) {
57083                             globals.set(id, sourceSymbol);
57084                         }
57085                     });
57086                 }
57087             }
57088             if (augmentations) {
57089                 for (var _f = 0, augmentations_1 = augmentations; _f < augmentations_1.length; _f++) {
57090                     var list = augmentations_1[_f];
57091                     for (var _g = 0, list_1 = list; _g < list_1.length; _g++) {
57092                         var augmentation = list_1[_g];
57093                         if (!ts.isGlobalScopeAugmentation(augmentation.parent))
57094                             continue;
57095                         mergeModuleAugmentation(augmentation);
57096                     }
57097                 }
57098             }
57099             addToSymbolTable(globals, builtinGlobals, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0);
57100             getSymbolLinks(undefinedSymbol).type = undefinedWideningType;
57101             getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", 0, true);
57102             getSymbolLinks(unknownSymbol).type = errorType;
57103             getSymbolLinks(globalThisSymbol).type = createObjectType(16, globalThisSymbol);
57104             globalArrayType = getGlobalType("Array", 1, true);
57105             globalObjectType = getGlobalType("Object", 0, true);
57106             globalFunctionType = getGlobalType("Function", 0, true);
57107             globalCallableFunctionType = strictBindCallApply && getGlobalType("CallableFunction", 0, true) || globalFunctionType;
57108             globalNewableFunctionType = strictBindCallApply && getGlobalType("NewableFunction", 0, true) || globalFunctionType;
57109             globalStringType = getGlobalType("String", 0, true);
57110             globalNumberType = getGlobalType("Number", 0, true);
57111             globalBooleanType = getGlobalType("Boolean", 0, true);
57112             globalRegExpType = getGlobalType("RegExp", 0, true);
57113             anyArrayType = createArrayType(anyType);
57114             autoArrayType = createArrayType(autoType);
57115             if (autoArrayType === emptyObjectType) {
57116                 autoArrayType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
57117             }
57118             globalReadonlyArrayType = getGlobalTypeOrUndefined("ReadonlyArray", 1) || globalArrayType;
57119             anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType;
57120             globalThisType = getGlobalTypeOrUndefined("ThisType", 1);
57121             if (augmentations) {
57122                 for (var _h = 0, augmentations_2 = augmentations; _h < augmentations_2.length; _h++) {
57123                     var list = augmentations_2[_h];
57124                     for (var _j = 0, list_2 = list; _j < list_2.length; _j++) {
57125                         var augmentation = list_2[_j];
57126                         if (ts.isGlobalScopeAugmentation(augmentation.parent))
57127                             continue;
57128                         mergeModuleAugmentation(augmentation);
57129                     }
57130                 }
57131             }
57132             amalgamatedDuplicates.forEach(function (_a) {
57133                 var firstFile = _a.firstFile, secondFile = _a.secondFile, conflictingSymbols = _a.conflictingSymbols;
57134                 if (conflictingSymbols.size < 8) {
57135                     conflictingSymbols.forEach(function (_a, symbolName) {
57136                         var isBlockScoped = _a.isBlockScoped, firstFileLocations = _a.firstFileLocations, secondFileLocations = _a.secondFileLocations;
57137                         var message = isBlockScoped ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0;
57138                         for (var _i = 0, firstFileLocations_1 = firstFileLocations; _i < firstFileLocations_1.length; _i++) {
57139                             var node = firstFileLocations_1[_i];
57140                             addDuplicateDeclarationError(node, message, symbolName, secondFileLocations);
57141                         }
57142                         for (var _b = 0, secondFileLocations_1 = secondFileLocations; _b < secondFileLocations_1.length; _b++) {
57143                             var node = secondFileLocations_1[_b];
57144                             addDuplicateDeclarationError(node, message, symbolName, firstFileLocations);
57145                         }
57146                     });
57147                 }
57148                 else {
57149                     var list = ts.arrayFrom(conflictingSymbols.keys()).join(", ");
57150                     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)));
57151                     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)));
57152                 }
57153             });
57154             amalgamatedDuplicates = undefined;
57155         }
57156         function checkExternalEmitHelpers(location, helpers) {
57157             if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) {
57158                 var sourceFile = ts.getSourceFileOfNode(location);
57159                 if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608)) {
57160                     var helpersModule = resolveHelpersModule(sourceFile, location);
57161                     if (helpersModule !== unknownSymbol) {
57162                         var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
57163                         for (var helper = 1; helper <= 1048576; helper <<= 1) {
57164                             if (uncheckedHelpers & helper) {
57165                                 var name = getHelperName(helper);
57166                                 var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551);
57167                                 if (!symbol) {
57168                                     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);
57169                                 }
57170                             }
57171                         }
57172                     }
57173                     requestedExternalEmitHelpers |= helpers;
57174                 }
57175             }
57176         }
57177         function getHelperName(helper) {
57178             switch (helper) {
57179                 case 1: return "__extends";
57180                 case 2: return "__assign";
57181                 case 4: return "__rest";
57182                 case 8: return "__decorate";
57183                 case 16: return "__metadata";
57184                 case 32: return "__param";
57185                 case 64: return "__awaiter";
57186                 case 128: return "__generator";
57187                 case 256: return "__values";
57188                 case 512: return "__read";
57189                 case 1024: return "__spread";
57190                 case 2048: return "__spreadArrays";
57191                 case 4096: return "__await";
57192                 case 8192: return "__asyncGenerator";
57193                 case 16384: return "__asyncDelegator";
57194                 case 32768: return "__asyncValues";
57195                 case 65536: return "__exportStar";
57196                 case 131072: return "__makeTemplateObject";
57197                 case 262144: return "__classPrivateFieldGet";
57198                 case 524288: return "__classPrivateFieldSet";
57199                 case 1048576: return "__createBinding";
57200                 default: return ts.Debug.fail("Unrecognized helper");
57201             }
57202         }
57203         function resolveHelpersModule(node, errorNode) {
57204             if (!externalHelpersModule) {
57205                 externalHelpersModule = resolveExternalModule(node, ts.externalHelpersModuleNameText, ts.Diagnostics.This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found, errorNode) || unknownSymbol;
57206             }
57207             return externalHelpersModule;
57208         }
57209         function checkGrammarDecoratorsAndModifiers(node) {
57210             return checkGrammarDecorators(node) || checkGrammarModifiers(node);
57211         }
57212         function checkGrammarDecorators(node) {
57213             if (!node.decorators) {
57214                 return false;
57215             }
57216             if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) {
57217                 if (node.kind === 161 && !ts.nodeIsPresent(node.body)) {
57218                     return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload);
57219                 }
57220                 else {
57221                     return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here);
57222                 }
57223             }
57224             else if (node.kind === 163 || node.kind === 164) {
57225                 var accessors = ts.getAllAccessorDeclarations(node.parent.members, node);
57226                 if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) {
57227                     return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name);
57228                 }
57229             }
57230             return false;
57231         }
57232         function checkGrammarModifiers(node) {
57233             var quickResult = reportObviousModifierErrors(node);
57234             if (quickResult !== undefined) {
57235                 return quickResult;
57236             }
57237             var lastStatic, lastDeclare, lastAsync, lastReadonly;
57238             var flags = 0;
57239             for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
57240                 var modifier = _a[_i];
57241                 if (modifier.kind !== 138) {
57242                     if (node.kind === 158 || node.kind === 160) {
57243                         return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind));
57244                     }
57245                     if (node.kind === 167) {
57246                         return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind));
57247                     }
57248                 }
57249                 switch (modifier.kind) {
57250                     case 81:
57251                         if (node.kind !== 248) {
57252                             return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(81));
57253                         }
57254                         break;
57255                     case 119:
57256                     case 118:
57257                     case 117:
57258                         var text = visibilityToString(ts.modifierToFlag(modifier.kind));
57259                         if (flags & 28) {
57260                             return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen);
57261                         }
57262                         else if (flags & 32) {
57263                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static");
57264                         }
57265                         else if (flags & 64) {
57266                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly");
57267                         }
57268                         else if (flags & 256) {
57269                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async");
57270                         }
57271                         else if (node.parent.kind === 250 || node.parent.kind === 290) {
57272                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text);
57273                         }
57274                         else if (flags & 128) {
57275                             if (modifier.kind === 117) {
57276                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract");
57277                             }
57278                             else {
57279                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract");
57280                             }
57281                         }
57282                         else if (ts.isPrivateIdentifierPropertyDeclaration(node)) {
57283                             return grammarErrorOnNode(modifier, ts.Diagnostics.An_accessibility_modifier_cannot_be_used_with_a_private_identifier);
57284                         }
57285                         flags |= ts.modifierToFlag(modifier.kind);
57286                         break;
57287                     case 120:
57288                         if (flags & 32) {
57289                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static");
57290                         }
57291                         else if (flags & 64) {
57292                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly");
57293                         }
57294                         else if (flags & 256) {
57295                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async");
57296                         }
57297                         else if (node.parent.kind === 250 || node.parent.kind === 290) {
57298                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static");
57299                         }
57300                         else if (node.kind === 156) {
57301                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static");
57302                         }
57303                         else if (flags & 128) {
57304                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract");
57305                         }
57306                         else if (ts.isPrivateIdentifierPropertyDeclaration(node)) {
57307                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "static");
57308                         }
57309                         flags |= 32;
57310                         lastStatic = modifier;
57311                         break;
57312                     case 138:
57313                         if (flags & 64) {
57314                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly");
57315                         }
57316                         else if (node.kind !== 159 && node.kind !== 158 && node.kind !== 167 && node.kind !== 156) {
57317                             return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature);
57318                         }
57319                         flags |= 64;
57320                         lastReadonly = modifier;
57321                         break;
57322                     case 89:
57323                         if (flags & 1) {
57324                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export");
57325                         }
57326                         else if (flags & 2) {
57327                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare");
57328                         }
57329                         else if (flags & 128) {
57330                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract");
57331                         }
57332                         else if (flags & 256) {
57333                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async");
57334                         }
57335                         else if (ts.isClassLike(node.parent)) {
57336                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export");
57337                         }
57338                         else if (node.kind === 156) {
57339                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export");
57340                         }
57341                         flags |= 1;
57342                         break;
57343                     case 84:
57344                         var container = node.parent.kind === 290 ? node.parent : node.parent.parent;
57345                         if (container.kind === 249 && !ts.isAmbientModule(container)) {
57346                             return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module);
57347                         }
57348                         flags |= 512;
57349                         break;
57350                     case 130:
57351                         if (flags & 2) {
57352                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare");
57353                         }
57354                         else if (flags & 256) {
57355                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
57356                         }
57357                         else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) {
57358                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare");
57359                         }
57360                         else if (node.kind === 156) {
57361                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare");
57362                         }
57363                         else if ((node.parent.flags & 8388608) && node.parent.kind === 250) {
57364                             return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context);
57365                         }
57366                         else if (ts.isPrivateIdentifierPropertyDeclaration(node)) {
57367                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare");
57368                         }
57369                         flags |= 2;
57370                         lastDeclare = modifier;
57371                         break;
57372                     case 122:
57373                         if (flags & 128) {
57374                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract");
57375                         }
57376                         if (node.kind !== 245) {
57377                             if (node.kind !== 161 &&
57378                                 node.kind !== 159 &&
57379                                 node.kind !== 163 &&
57380                                 node.kind !== 164) {
57381                                 return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration);
57382                             }
57383                             if (!(node.parent.kind === 245 && ts.hasModifier(node.parent, 128))) {
57384                                 return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class);
57385                             }
57386                             if (flags & 32) {
57387                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract");
57388                             }
57389                             if (flags & 8) {
57390                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract");
57391                             }
57392                         }
57393                         if (ts.isNamedDeclaration(node) && node.name.kind === 76) {
57394                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract");
57395                         }
57396                         flags |= 128;
57397                         break;
57398                     case 126:
57399                         if (flags & 256) {
57400                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async");
57401                         }
57402                         else if (flags & 2 || node.parent.flags & 8388608) {
57403                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
57404                         }
57405                         else if (node.kind === 156) {
57406                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async");
57407                         }
57408                         flags |= 256;
57409                         lastAsync = modifier;
57410                         break;
57411                 }
57412             }
57413             if (node.kind === 162) {
57414                 if (flags & 32) {
57415                     return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static");
57416                 }
57417                 if (flags & 128) {
57418                     return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract");
57419                 }
57420                 else if (flags & 256) {
57421                     return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async");
57422                 }
57423                 else if (flags & 64) {
57424                     return grammarErrorOnNode(lastReadonly, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "readonly");
57425                 }
57426                 return false;
57427             }
57428             else if ((node.kind === 254 || node.kind === 253) && flags & 2) {
57429                 return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare");
57430             }
57431             else if (node.kind === 156 && (flags & 92) && ts.isBindingPattern(node.name)) {
57432                 return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern);
57433             }
57434             else if (node.kind === 156 && (flags & 92) && node.dotDotDotToken) {
57435                 return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter);
57436             }
57437             if (flags & 256) {
57438                 return checkGrammarAsyncModifier(node, lastAsync);
57439             }
57440             return false;
57441         }
57442         function reportObviousModifierErrors(node) {
57443             return !node.modifiers
57444                 ? false
57445                 : shouldReportBadModifier(node)
57446                     ? grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here)
57447                     : undefined;
57448         }
57449         function shouldReportBadModifier(node) {
57450             switch (node.kind) {
57451                 case 163:
57452                 case 164:
57453                 case 162:
57454                 case 159:
57455                 case 158:
57456                 case 161:
57457                 case 160:
57458                 case 167:
57459                 case 249:
57460                 case 254:
57461                 case 253:
57462                 case 260:
57463                 case 259:
57464                 case 201:
57465                 case 202:
57466                 case 156:
57467                     return false;
57468                 default:
57469                     if (node.parent.kind === 250 || node.parent.kind === 290) {
57470                         return false;
57471                     }
57472                     switch (node.kind) {
57473                         case 244:
57474                             return nodeHasAnyModifiersExcept(node, 126);
57475                         case 245:
57476                             return nodeHasAnyModifiersExcept(node, 122);
57477                         case 246:
57478                         case 225:
57479                         case 247:
57480                             return true;
57481                         case 248:
57482                             return nodeHasAnyModifiersExcept(node, 81);
57483                         default:
57484                             ts.Debug.fail();
57485                             return false;
57486                     }
57487             }
57488         }
57489         function nodeHasAnyModifiersExcept(node, allowedModifier) {
57490             return node.modifiers.length > 1 || node.modifiers[0].kind !== allowedModifier;
57491         }
57492         function checkGrammarAsyncModifier(node, asyncModifier) {
57493             switch (node.kind) {
57494                 case 161:
57495                 case 244:
57496                 case 201:
57497                 case 202:
57498                     return false;
57499             }
57500             return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async");
57501         }
57502         function checkGrammarForDisallowedTrailingComma(list, diag) {
57503             if (diag === void 0) { diag = ts.Diagnostics.Trailing_comma_not_allowed; }
57504             if (list && list.hasTrailingComma) {
57505                 return grammarErrorAtPos(list[0], list.end - ",".length, ",".length, diag);
57506             }
57507             return false;
57508         }
57509         function checkGrammarTypeParameterList(typeParameters, file) {
57510             if (typeParameters && typeParameters.length === 0) {
57511                 var start = typeParameters.pos - "<".length;
57512                 var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length;
57513                 return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty);
57514             }
57515             return false;
57516         }
57517         function checkGrammarParameterList(parameters) {
57518             var seenOptionalParameter = false;
57519             var parameterCount = parameters.length;
57520             for (var i = 0; i < parameterCount; i++) {
57521                 var parameter = parameters[i];
57522                 if (parameter.dotDotDotToken) {
57523                     if (i !== (parameterCount - 1)) {
57524                         return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
57525                     }
57526                     if (!(parameter.flags & 8388608)) {
57527                         checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
57528                     }
57529                     if (parameter.questionToken) {
57530                         return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_rest_parameter_cannot_be_optional);
57531                     }
57532                     if (parameter.initializer) {
57533                         return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer);
57534                     }
57535                 }
57536                 else if (parameter.questionToken) {
57537                     seenOptionalParameter = true;
57538                     if (parameter.initializer) {
57539                         return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer);
57540                     }
57541                 }
57542                 else if (seenOptionalParameter && !parameter.initializer) {
57543                     return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter);
57544                 }
57545             }
57546         }
57547         function getNonSimpleParameters(parameters) {
57548             return ts.filter(parameters, function (parameter) { return !!parameter.initializer || ts.isBindingPattern(parameter.name) || ts.isRestParameter(parameter); });
57549         }
57550         function checkGrammarForUseStrictSimpleParameterList(node) {
57551             if (languageVersion >= 3) {
57552                 var useStrictDirective_1 = node.body && ts.isBlock(node.body) && ts.findUseStrictPrologue(node.body.statements);
57553                 if (useStrictDirective_1) {
57554                     var nonSimpleParameters = getNonSimpleParameters(node.parameters);
57555                     if (ts.length(nonSimpleParameters)) {
57556                         ts.forEach(nonSimpleParameters, function (parameter) {
57557                             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));
57558                         });
57559                         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)); });
57560                         ts.addRelatedInfo.apply(void 0, __spreadArrays([error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)], diagnostics_1));
57561                         return true;
57562                     }
57563                 }
57564             }
57565             return false;
57566         }
57567         function checkGrammarFunctionLikeDeclaration(node) {
57568             var file = ts.getSourceFileOfNode(node);
57569             return checkGrammarDecoratorsAndModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) ||
57570                 checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file) ||
57571                 (ts.isFunctionLikeDeclaration(node) && checkGrammarForUseStrictSimpleParameterList(node));
57572         }
57573         function checkGrammarClassLikeDeclaration(node) {
57574             var file = ts.getSourceFileOfNode(node);
57575             return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(node.typeParameters, file);
57576         }
57577         function checkGrammarArrowFunction(node, file) {
57578             if (!ts.isArrowFunction(node)) {
57579                 return false;
57580             }
57581             var equalsGreaterThanToken = node.equalsGreaterThanToken;
57582             var startLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.pos).line;
57583             var endLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.end).line;
57584             return startLine !== endLine && grammarErrorOnNode(equalsGreaterThanToken, ts.Diagnostics.Line_terminator_not_permitted_before_arrow);
57585         }
57586         function checkGrammarIndexSignatureParameters(node) {
57587             var parameter = node.parameters[0];
57588             if (node.parameters.length !== 1) {
57589                 if (parameter) {
57590                     return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter);
57591                 }
57592                 else {
57593                     return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter);
57594                 }
57595             }
57596             checkGrammarForDisallowedTrailingComma(node.parameters, ts.Diagnostics.An_index_signature_cannot_have_a_trailing_comma);
57597             if (parameter.dotDotDotToken) {
57598                 return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter);
57599             }
57600             if (ts.hasModifiers(parameter)) {
57601                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier);
57602             }
57603             if (parameter.questionToken) {
57604                 return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark);
57605             }
57606             if (parameter.initializer) {
57607                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_initializer);
57608             }
57609             if (!parameter.type) {
57610                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation);
57611             }
57612             if (parameter.type.kind !== 143 && parameter.type.kind !== 140) {
57613                 var type = getTypeFromTypeNode(parameter.type);
57614                 if (type.flags & 4 || type.flags & 8) {
57615                     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));
57616                 }
57617                 if (type.flags & 1048576 && allTypesAssignableToKind(type, 384, true)) {
57618                     return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead);
57619                 }
57620                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_either_string_or_number);
57621             }
57622             if (!node.type) {
57623                 return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation);
57624             }
57625             return false;
57626         }
57627         function checkGrammarIndexSignature(node) {
57628             return checkGrammarDecoratorsAndModifiers(node) || checkGrammarIndexSignatureParameters(node);
57629         }
57630         function checkGrammarForAtLeastOneTypeArgument(node, typeArguments) {
57631             if (typeArguments && typeArguments.length === 0) {
57632                 var sourceFile = ts.getSourceFileOfNode(node);
57633                 var start = typeArguments.pos - "<".length;
57634                 var end = ts.skipTrivia(sourceFile.text, typeArguments.end) + ">".length;
57635                 return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty);
57636             }
57637             return false;
57638         }
57639         function checkGrammarTypeArguments(node, typeArguments) {
57640             return checkGrammarForDisallowedTrailingComma(typeArguments) ||
57641                 checkGrammarForAtLeastOneTypeArgument(node, typeArguments);
57642         }
57643         function checkGrammarTaggedTemplateChain(node) {
57644             if (node.questionDotToken || node.flags & 32) {
57645                 return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain);
57646             }
57647             return false;
57648         }
57649         function checkGrammarForOmittedArgument(args) {
57650             if (args) {
57651                 for (var _i = 0, args_4 = args; _i < args_4.length; _i++) {
57652                     var arg = args_4[_i];
57653                     if (arg.kind === 215) {
57654                         return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected);
57655                     }
57656                 }
57657             }
57658             return false;
57659         }
57660         function checkGrammarArguments(args) {
57661             return checkGrammarForOmittedArgument(args);
57662         }
57663         function checkGrammarHeritageClause(node) {
57664             var types = node.types;
57665             if (checkGrammarForDisallowedTrailingComma(types)) {
57666                 return true;
57667             }
57668             if (types && types.length === 0) {
57669                 var listType = ts.tokenToString(node.token);
57670                 return grammarErrorAtPos(node, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType);
57671             }
57672             return ts.some(types, checkGrammarExpressionWithTypeArguments);
57673         }
57674         function checkGrammarExpressionWithTypeArguments(node) {
57675             return checkGrammarTypeArguments(node, node.typeArguments);
57676         }
57677         function checkGrammarClassDeclarationHeritageClauses(node) {
57678             var seenExtendsClause = false;
57679             var seenImplementsClause = false;
57680             if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) {
57681                 for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) {
57682                     var heritageClause = _a[_i];
57683                     if (heritageClause.token === 90) {
57684                         if (seenExtendsClause) {
57685                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen);
57686                         }
57687                         if (seenImplementsClause) {
57688                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_must_precede_implements_clause);
57689                         }
57690                         if (heritageClause.types.length > 1) {
57691                             return grammarErrorOnFirstToken(heritageClause.types[1], ts.Diagnostics.Classes_can_only_extend_a_single_class);
57692                         }
57693                         seenExtendsClause = true;
57694                     }
57695                     else {
57696                         ts.Debug.assert(heritageClause.token === 113);
57697                         if (seenImplementsClause) {
57698                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen);
57699                         }
57700                         seenImplementsClause = true;
57701                     }
57702                     checkGrammarHeritageClause(heritageClause);
57703                 }
57704             }
57705         }
57706         function checkGrammarInterfaceDeclaration(node) {
57707             var seenExtendsClause = false;
57708             if (node.heritageClauses) {
57709                 for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) {
57710                     var heritageClause = _a[_i];
57711                     if (heritageClause.token === 90) {
57712                         if (seenExtendsClause) {
57713                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen);
57714                         }
57715                         seenExtendsClause = true;
57716                     }
57717                     else {
57718                         ts.Debug.assert(heritageClause.token === 113);
57719                         return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause);
57720                     }
57721                     checkGrammarHeritageClause(heritageClause);
57722                 }
57723             }
57724             return false;
57725         }
57726         function checkGrammarComputedPropertyName(node) {
57727             if (node.kind !== 154) {
57728                 return false;
57729             }
57730             var computedPropertyName = node;
57731             if (computedPropertyName.expression.kind === 209 && computedPropertyName.expression.operatorToken.kind === 27) {
57732                 return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name);
57733             }
57734             return false;
57735         }
57736         function checkGrammarForGenerator(node) {
57737             if (node.asteriskToken) {
57738                 ts.Debug.assert(node.kind === 244 ||
57739                     node.kind === 201 ||
57740                     node.kind === 161);
57741                 if (node.flags & 8388608) {
57742                     return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context);
57743                 }
57744                 if (!node.body) {
57745                     return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator);
57746                 }
57747             }
57748         }
57749         function checkGrammarForInvalidQuestionMark(questionToken, message) {
57750             return !!questionToken && grammarErrorOnNode(questionToken, message);
57751         }
57752         function checkGrammarForInvalidExclamationToken(exclamationToken, message) {
57753             return !!exclamationToken && grammarErrorOnNode(exclamationToken, message);
57754         }
57755         function checkGrammarObjectLiteralExpression(node, inDestructuring) {
57756             var seen = ts.createUnderscoreEscapedMap();
57757             for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
57758                 var prop = _a[_i];
57759                 if (prop.kind === 283) {
57760                     if (inDestructuring) {
57761                         var expression = ts.skipParentheses(prop.expression);
57762                         if (ts.isArrayLiteralExpression(expression) || ts.isObjectLiteralExpression(expression)) {
57763                             return grammarErrorOnNode(prop.expression, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern);
57764                         }
57765                     }
57766                     continue;
57767                 }
57768                 var name = prop.name;
57769                 if (name.kind === 154) {
57770                     checkGrammarComputedPropertyName(name);
57771                 }
57772                 if (prop.kind === 282 && !inDestructuring && prop.objectAssignmentInitializer) {
57773                     return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment);
57774                 }
57775                 if (name.kind === 76) {
57776                     return grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
57777                 }
57778                 if (prop.modifiers) {
57779                     for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) {
57780                         var mod = _c[_b];
57781                         if (mod.kind !== 126 || prop.kind !== 161) {
57782                             grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod));
57783                         }
57784                     }
57785                 }
57786                 var currentKind = void 0;
57787                 switch (prop.kind) {
57788                     case 282:
57789                         checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context);
57790                     case 281:
57791                         checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional);
57792                         if (name.kind === 8) {
57793                             checkGrammarNumericLiteral(name);
57794                         }
57795                         currentKind = 4;
57796                         break;
57797                     case 161:
57798                         currentKind = 8;
57799                         break;
57800                     case 163:
57801                         currentKind = 1;
57802                         break;
57803                     case 164:
57804                         currentKind = 2;
57805                         break;
57806                     default:
57807                         throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind);
57808                 }
57809                 if (!inDestructuring) {
57810                     var effectiveName = ts.getPropertyNameForPropertyNameNode(name);
57811                     if (effectiveName === undefined) {
57812                         continue;
57813                     }
57814                     var existingKind = seen.get(effectiveName);
57815                     if (!existingKind) {
57816                         seen.set(effectiveName, currentKind);
57817                     }
57818                     else {
57819                         if ((currentKind & 12) && (existingKind & 12)) {
57820                             grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name));
57821                         }
57822                         else if ((currentKind & 3) && (existingKind & 3)) {
57823                             if (existingKind !== 3 && currentKind !== existingKind) {
57824                                 seen.set(effectiveName, currentKind | existingKind);
57825                             }
57826                             else {
57827                                 return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name);
57828                             }
57829                         }
57830                         else {
57831                             return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name);
57832                         }
57833                     }
57834                 }
57835             }
57836         }
57837         function checkGrammarJsxElement(node) {
57838             checkGrammarTypeArguments(node, node.typeArguments);
57839             var seen = ts.createUnderscoreEscapedMap();
57840             for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) {
57841                 var attr = _a[_i];
57842                 if (attr.kind === 275) {
57843                     continue;
57844                 }
57845                 var name = attr.name, initializer = attr.initializer;
57846                 if (!seen.get(name.escapedText)) {
57847                     seen.set(name.escapedText, true);
57848                 }
57849                 else {
57850                     return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name);
57851                 }
57852                 if (initializer && initializer.kind === 276 && !initializer.expression) {
57853                     return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression);
57854                 }
57855             }
57856         }
57857         function checkGrammarJsxExpression(node) {
57858             if (node.expression && ts.isCommaSequence(node.expression)) {
57859                 return grammarErrorOnNode(node.expression, ts.Diagnostics.JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array);
57860             }
57861         }
57862         function checkGrammarForInOrForOfStatement(forInOrOfStatement) {
57863             if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) {
57864                 return true;
57865             }
57866             if (forInOrOfStatement.kind === 232 && forInOrOfStatement.awaitModifier) {
57867                 if ((forInOrOfStatement.flags & 32768) === 0) {
57868                     var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement);
57869                     if (!hasParseDiagnostics(sourceFile)) {
57870                         var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator);
57871                         var func = ts.getContainingFunction(forInOrOfStatement);
57872                         if (func && func.kind !== 162) {
57873                             ts.Debug.assert((ts.getFunctionFlags(func) & 2) === 0, "Enclosing function should never be an async function.");
57874                             var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
57875                             ts.addRelatedInfo(diagnostic, relatedInfo);
57876                         }
57877                         diagnostics.add(diagnostic);
57878                         return true;
57879                     }
57880                     return false;
57881                 }
57882             }
57883             if (forInOrOfStatement.initializer.kind === 243) {
57884                 var variableList = forInOrOfStatement.initializer;
57885                 if (!checkGrammarVariableDeclarationList(variableList)) {
57886                     var declarations = variableList.declarations;
57887                     if (!declarations.length) {
57888                         return false;
57889                     }
57890                     if (declarations.length > 1) {
57891                         var diagnostic = forInOrOfStatement.kind === 231
57892                             ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement
57893                             : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement;
57894                         return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic);
57895                     }
57896                     var firstDeclaration = declarations[0];
57897                     if (firstDeclaration.initializer) {
57898                         var diagnostic = forInOrOfStatement.kind === 231
57899                             ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer
57900                             : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer;
57901                         return grammarErrorOnNode(firstDeclaration.name, diagnostic);
57902                     }
57903                     if (firstDeclaration.type) {
57904                         var diagnostic = forInOrOfStatement.kind === 231
57905                             ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation
57906                             : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation;
57907                         return grammarErrorOnNode(firstDeclaration, diagnostic);
57908                     }
57909                 }
57910             }
57911             return false;
57912         }
57913         function checkGrammarAccessor(accessor) {
57914             if (!(accessor.flags & 8388608)) {
57915                 if (languageVersion < 1) {
57916                     return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher);
57917                 }
57918                 if (accessor.body === undefined && !ts.hasModifier(accessor, 128)) {
57919                     return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{");
57920                 }
57921             }
57922             if (accessor.body && ts.hasModifier(accessor, 128)) {
57923                 return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation);
57924             }
57925             if (accessor.typeParameters) {
57926                 return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters);
57927             }
57928             if (!doesAccessorHaveCorrectParameterCount(accessor)) {
57929                 return grammarErrorOnNode(accessor.name, accessor.kind === 163 ?
57930                     ts.Diagnostics.A_get_accessor_cannot_have_parameters :
57931                     ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter);
57932             }
57933             if (accessor.kind === 164) {
57934                 if (accessor.type) {
57935                     return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation);
57936                 }
57937                 var parameter = ts.Debug.checkDefined(ts.getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion.");
57938                 if (parameter.dotDotDotToken) {
57939                     return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter);
57940                 }
57941                 if (parameter.questionToken) {
57942                     return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter);
57943                 }
57944                 if (parameter.initializer) {
57945                     return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer);
57946                 }
57947             }
57948             return false;
57949         }
57950         function doesAccessorHaveCorrectParameterCount(accessor) {
57951             return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 163 ? 0 : 1);
57952         }
57953         function getAccessorThisParameter(accessor) {
57954             if (accessor.parameters.length === (accessor.kind === 163 ? 1 : 2)) {
57955                 return ts.getThisParameter(accessor);
57956             }
57957         }
57958         function checkGrammarTypeOperatorNode(node) {
57959             if (node.operator === 147) {
57960                 if (node.type.kind !== 144) {
57961                     return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(144));
57962                 }
57963                 var parent = ts.walkUpParenthesizedTypes(node.parent);
57964                 switch (parent.kind) {
57965                     case 242:
57966                         var decl = parent;
57967                         if (decl.name.kind !== 75) {
57968                             return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name);
57969                         }
57970                         if (!ts.isVariableDeclarationInVariableStatement(decl)) {
57971                             return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement);
57972                         }
57973                         if (!(decl.parent.flags & 2)) {
57974                             return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const);
57975                         }
57976                         break;
57977                     case 159:
57978                         if (!ts.hasModifier(parent, 32) ||
57979                             !ts.hasModifier(parent, 64)) {
57980                             return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly);
57981                         }
57982                         break;
57983                     case 158:
57984                         if (!ts.hasModifier(parent, 64)) {
57985                             return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly);
57986                         }
57987                         break;
57988                     default:
57989                         return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here);
57990                 }
57991             }
57992             else if (node.operator === 138) {
57993                 if (node.type.kind !== 174 && node.type.kind !== 175) {
57994                     return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(144));
57995                 }
57996             }
57997         }
57998         function checkGrammarForInvalidDynamicName(node, message) {
57999             if (isNonBindableDynamicName(node)) {
58000                 return grammarErrorOnNode(node, message);
58001             }
58002         }
58003         function checkGrammarMethod(node) {
58004             if (checkGrammarFunctionLikeDeclaration(node)) {
58005                 return true;
58006             }
58007             if (node.kind === 161) {
58008                 if (node.parent.kind === 193) {
58009                     if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 126)) {
58010                         return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here);
58011                     }
58012                     else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) {
58013                         return true;
58014                     }
58015                     else if (checkGrammarForInvalidExclamationToken(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context)) {
58016                         return true;
58017                     }
58018                     else if (node.body === undefined) {
58019                         return grammarErrorAtPos(node, node.end - 1, ";".length, ts.Diagnostics._0_expected, "{");
58020                     }
58021                 }
58022                 if (checkGrammarForGenerator(node)) {
58023                     return true;
58024                 }
58025             }
58026             if (ts.isClassLike(node.parent)) {
58027                 if (node.flags & 8388608) {
58028                     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);
58029                 }
58030                 else if (node.kind === 161 && !node.body) {
58031                     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);
58032                 }
58033             }
58034             else if (node.parent.kind === 246) {
58035                 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);
58036             }
58037             else if (node.parent.kind === 173) {
58038                 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);
58039             }
58040         }
58041         function checkGrammarBreakOrContinueStatement(node) {
58042             var current = node;
58043             while (current) {
58044                 if (ts.isFunctionLike(current)) {
58045                     return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary);
58046                 }
58047                 switch (current.kind) {
58048                     case 238:
58049                         if (node.label && current.label.escapedText === node.label.escapedText) {
58050                             var isMisplacedContinueLabel = node.kind === 233
58051                                 && !ts.isIterationStatement(current.statement, true);
58052                             if (isMisplacedContinueLabel) {
58053                                 return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement);
58054                             }
58055                             return false;
58056                         }
58057                         break;
58058                     case 237:
58059                         if (node.kind === 234 && !node.label) {
58060                             return false;
58061                         }
58062                         break;
58063                     default:
58064                         if (ts.isIterationStatement(current, false) && !node.label) {
58065                             return false;
58066                         }
58067                         break;
58068                 }
58069                 current = current.parent;
58070             }
58071             if (node.label) {
58072                 var message = node.kind === 234
58073                     ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement
58074                     : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement;
58075                 return grammarErrorOnNode(node, message);
58076             }
58077             else {
58078                 var message = node.kind === 234
58079                     ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement
58080                     : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement;
58081                 return grammarErrorOnNode(node, message);
58082             }
58083         }
58084         function checkGrammarBindingElement(node) {
58085             if (node.dotDotDotToken) {
58086                 var elements = node.parent.elements;
58087                 if (node !== ts.last(elements)) {
58088                     return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
58089                 }
58090                 checkGrammarForDisallowedTrailingComma(elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
58091                 if (node.propertyName) {
58092                     return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_have_a_property_name);
58093                 }
58094                 if (node.initializer) {
58095                     return grammarErrorAtPos(node, node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer);
58096                 }
58097             }
58098         }
58099         function isStringOrNumberLiteralExpression(expr) {
58100             return ts.isStringOrNumericLiteralLike(expr) ||
58101                 expr.kind === 207 && expr.operator === 40 &&
58102                     expr.operand.kind === 8;
58103         }
58104         function isBigIntLiteralExpression(expr) {
58105             return expr.kind === 9 ||
58106                 expr.kind === 207 && expr.operator === 40 &&
58107                     expr.operand.kind === 9;
58108         }
58109         function isSimpleLiteralEnumReference(expr) {
58110             if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) &&
58111                 ts.isEntityNameExpression(expr.expression)) {
58112                 return !!(checkExpressionCached(expr).flags & 1024);
58113             }
58114         }
58115         function checkAmbientInitializer(node) {
58116             var initializer = node.initializer;
58117             if (initializer) {
58118                 var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) ||
58119                     isSimpleLiteralEnumReference(initializer) ||
58120                     initializer.kind === 106 || initializer.kind === 91 ||
58121                     isBigIntLiteralExpression(initializer));
58122                 var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node);
58123                 if (isConstOrReadonly && !node.type) {
58124                     if (isInvalidInitializer) {
58125                         return grammarErrorOnNode(initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference);
58126                     }
58127                 }
58128                 else {
58129                     return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
58130                 }
58131                 if (!isConstOrReadonly || isInvalidInitializer) {
58132                     return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
58133                 }
58134             }
58135         }
58136         function checkGrammarVariableDeclaration(node) {
58137             if (node.parent.parent.kind !== 231 && node.parent.parent.kind !== 232) {
58138                 if (node.flags & 8388608) {
58139                     checkAmbientInitializer(node);
58140                 }
58141                 else if (!node.initializer) {
58142                     if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) {
58143                         return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer);
58144                     }
58145                     if (ts.isVarConst(node)) {
58146                         return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized);
58147                     }
58148                 }
58149             }
58150             if (node.exclamationToken && (node.parent.parent.kind !== 225 || !node.type || node.initializer || node.flags & 8388608)) {
58151                 return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation);
58152             }
58153             var moduleKind = ts.getEmitModuleKind(compilerOptions);
58154             if (moduleKind < ts.ModuleKind.ES2015 && moduleKind !== ts.ModuleKind.System && !compilerOptions.noEmit &&
58155                 !(node.parent.parent.flags & 8388608) && ts.hasModifier(node.parent.parent, 1)) {
58156                 checkESModuleMarker(node.name);
58157             }
58158             var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node));
58159             return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name);
58160         }
58161         function checkESModuleMarker(name) {
58162             if (name.kind === 75) {
58163                 if (ts.idText(name) === "__esModule") {
58164                     return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules);
58165                 }
58166             }
58167             else {
58168                 var elements = name.elements;
58169                 for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) {
58170                     var element = elements_1[_i];
58171                     if (!ts.isOmittedExpression(element)) {
58172                         return checkESModuleMarker(element.name);
58173                     }
58174                 }
58175             }
58176             return false;
58177         }
58178         function checkGrammarNameInLetOrConstDeclarations(name) {
58179             if (name.kind === 75) {
58180                 if (name.originalKeywordKind === 115) {
58181                     return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations);
58182                 }
58183             }
58184             else {
58185                 var elements = name.elements;
58186                 for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) {
58187                     var element = elements_2[_i];
58188                     if (!ts.isOmittedExpression(element)) {
58189                         checkGrammarNameInLetOrConstDeclarations(element.name);
58190                     }
58191                 }
58192             }
58193             return false;
58194         }
58195         function checkGrammarVariableDeclarationList(declarationList) {
58196             var declarations = declarationList.declarations;
58197             if (checkGrammarForDisallowedTrailingComma(declarationList.declarations)) {
58198                 return true;
58199             }
58200             if (!declarationList.declarations.length) {
58201                 return grammarErrorAtPos(declarationList, declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty);
58202             }
58203             return false;
58204         }
58205         function allowLetAndConstDeclarations(parent) {
58206             switch (parent.kind) {
58207                 case 227:
58208                 case 228:
58209                 case 229:
58210                 case 236:
58211                 case 230:
58212                 case 231:
58213                 case 232:
58214                     return false;
58215                 case 238:
58216                     return allowLetAndConstDeclarations(parent.parent);
58217             }
58218             return true;
58219         }
58220         function checkGrammarForDisallowedLetOrConstStatement(node) {
58221             if (!allowLetAndConstDeclarations(node.parent)) {
58222                 if (ts.isLet(node.declarationList)) {
58223                     return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block);
58224                 }
58225                 else if (ts.isVarConst(node.declarationList)) {
58226                     return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block);
58227                 }
58228             }
58229         }
58230         function checkGrammarMetaProperty(node) {
58231             var escapedText = node.name.escapedText;
58232             switch (node.keywordToken) {
58233                 case 99:
58234                     if (escapedText !== "target") {
58235                         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");
58236                     }
58237                     break;
58238                 case 96:
58239                     if (escapedText !== "meta") {
58240                         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");
58241                     }
58242                     break;
58243             }
58244         }
58245         function hasParseDiagnostics(sourceFile) {
58246             return sourceFile.parseDiagnostics.length > 0;
58247         }
58248         function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) {
58249             var sourceFile = ts.getSourceFileOfNode(node);
58250             if (!hasParseDiagnostics(sourceFile)) {
58251                 var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
58252                 diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2));
58253                 return true;
58254             }
58255             return false;
58256         }
58257         function grammarErrorAtPos(nodeForSourceFile, start, length, message, arg0, arg1, arg2) {
58258             var sourceFile = ts.getSourceFileOfNode(nodeForSourceFile);
58259             if (!hasParseDiagnostics(sourceFile)) {
58260                 diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2));
58261                 return true;
58262             }
58263             return false;
58264         }
58265         function grammarErrorOnNode(node, message, arg0, arg1, arg2) {
58266             var sourceFile = ts.getSourceFileOfNode(node);
58267             if (!hasParseDiagnostics(sourceFile)) {
58268                 diagnostics.add(ts.createDiagnosticForNode(node, message, arg0, arg1, arg2));
58269                 return true;
58270             }
58271             return false;
58272         }
58273         function checkGrammarConstructorTypeParameters(node) {
58274             var jsdocTypeParameters = ts.isInJSFile(node) ? ts.getJSDocTypeParameterDeclarations(node) : undefined;
58275             var range = node.typeParameters || jsdocTypeParameters && ts.firstOrUndefined(jsdocTypeParameters);
58276             if (range) {
58277                 var pos = range.pos === range.end ? range.pos : ts.skipTrivia(ts.getSourceFileOfNode(node).text, range.pos);
58278                 return grammarErrorAtPos(node, pos, range.end - pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration);
58279             }
58280         }
58281         function checkGrammarConstructorTypeAnnotation(node) {
58282             var type = ts.getEffectiveReturnTypeNode(node);
58283             if (type) {
58284                 return grammarErrorOnNode(type, ts.Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration);
58285             }
58286         }
58287         function checkGrammarProperty(node) {
58288             if (ts.isClassLike(node.parent)) {
58289                 if (ts.isStringLiteral(node.name) && node.name.text === "constructor") {
58290                     return grammarErrorOnNode(node.name, ts.Diagnostics.Classes_may_not_have_a_field_named_constructor);
58291                 }
58292                 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)) {
58293                     return true;
58294                 }
58295                 if (languageVersion < 2 && ts.isPrivateIdentifier(node.name)) {
58296                     return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher);
58297                 }
58298             }
58299             else if (node.parent.kind === 246) {
58300                 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)) {
58301                     return true;
58302                 }
58303                 if (node.initializer) {
58304                     return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer);
58305                 }
58306             }
58307             else if (node.parent.kind === 173) {
58308                 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)) {
58309                     return true;
58310                 }
58311                 if (node.initializer) {
58312                     return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer);
58313                 }
58314             }
58315             if (node.flags & 8388608) {
58316                 checkAmbientInitializer(node);
58317             }
58318             if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer ||
58319                 node.flags & 8388608 || ts.hasModifier(node, 32 | 128))) {
58320                 return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context);
58321             }
58322         }
58323         function checkGrammarTopLevelElementForRequiredDeclareModifier(node) {
58324             if (node.kind === 246 ||
58325                 node.kind === 247 ||
58326                 node.kind === 254 ||
58327                 node.kind === 253 ||
58328                 node.kind === 260 ||
58329                 node.kind === 259 ||
58330                 node.kind === 252 ||
58331                 ts.hasModifier(node, 2 | 1 | 512)) {
58332                 return false;
58333             }
58334             return grammarErrorOnFirstToken(node, ts.Diagnostics.Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier);
58335         }
58336         function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) {
58337             for (var _i = 0, _a = file.statements; _i < _a.length; _i++) {
58338                 var decl = _a[_i];
58339                 if (ts.isDeclaration(decl) || decl.kind === 225) {
58340                     if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) {
58341                         return true;
58342                     }
58343                 }
58344             }
58345             return false;
58346         }
58347         function checkGrammarSourceFile(node) {
58348             return !!(node.flags & 8388608) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
58349         }
58350         function checkGrammarStatementInAmbientContext(node) {
58351             if (node.flags & 8388608) {
58352                 var links = getNodeLinks(node);
58353                 if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) {
58354                     return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts);
58355                 }
58356                 if (node.parent.kind === 223 || node.parent.kind === 250 || node.parent.kind === 290) {
58357                     var links_2 = getNodeLinks(node.parent);
58358                     if (!links_2.hasReportedStatementInAmbientContext) {
58359                         return links_2.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts);
58360                     }
58361                 }
58362                 else {
58363                 }
58364             }
58365             return false;
58366         }
58367         function checkGrammarNumericLiteral(node) {
58368             if (node.numericLiteralFlags & 32) {
58369                 var diagnosticMessage = void 0;
58370                 if (languageVersion >= 1) {
58371                     diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0;
58372                 }
58373                 else if (ts.isChildOfNodeWithKind(node, 187)) {
58374                     diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0;
58375                 }
58376                 else if (ts.isChildOfNodeWithKind(node, 284)) {
58377                     diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0;
58378                 }
58379                 if (diagnosticMessage) {
58380                     var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40;
58381                     var literal = (withMinus ? "-" : "") + "0o" + node.text;
58382                     return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal);
58383                 }
58384             }
58385             checkNumericLiteralValueSize(node);
58386             return false;
58387         }
58388         function checkNumericLiteralValueSize(node) {
58389             if (node.numericLiteralFlags & 16 || node.text.length <= 15 || node.text.indexOf(".") !== -1) {
58390                 return;
58391             }
58392             var apparentValue = +ts.getTextOfNode(node);
58393             if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) {
58394                 return;
58395             }
58396             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));
58397         }
58398         function checkGrammarBigIntLiteral(node) {
58399             var literalType = ts.isLiteralTypeNode(node.parent) ||
58400                 ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent);
58401             if (!literalType) {
58402                 if (languageVersion < 7) {
58403                     if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) {
58404                         return true;
58405                     }
58406                 }
58407             }
58408             return false;
58409         }
58410         function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) {
58411             var sourceFile = ts.getSourceFileOfNode(node);
58412             if (!hasParseDiagnostics(sourceFile)) {
58413                 var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
58414                 diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), 0, message, arg0, arg1, arg2));
58415                 return true;
58416             }
58417             return false;
58418         }
58419         function getAmbientModules() {
58420             if (!ambientModulesCache) {
58421                 ambientModulesCache = [];
58422                 globals.forEach(function (global, sym) {
58423                     if (ambientModuleSymbolRegex.test(sym)) {
58424                         ambientModulesCache.push(global);
58425                     }
58426                 });
58427             }
58428             return ambientModulesCache;
58429         }
58430         function checkGrammarImportClause(node) {
58431             if (node.isTypeOnly && node.name && node.namedBindings) {
58432                 return grammarErrorOnNode(node, ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both);
58433             }
58434             return false;
58435         }
58436         function checkGrammarImportCallExpression(node) {
58437             if (moduleKind === ts.ModuleKind.ES2015) {
58438                 return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system_or_umd);
58439             }
58440             if (node.typeArguments) {
58441                 return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
58442             }
58443             var nodeArguments = node.arguments;
58444             if (nodeArguments.length !== 1) {
58445                 return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_must_have_one_specifier_as_an_argument);
58446             }
58447             checkGrammarForDisallowedTrailingComma(nodeArguments);
58448             if (ts.isSpreadElement(nodeArguments[0])) {
58449                 return grammarErrorOnNode(nodeArguments[0], ts.Diagnostics.Specifier_of_dynamic_import_cannot_be_spread_element);
58450             }
58451             return false;
58452         }
58453         function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) {
58454             var sourceObjectFlags = ts.getObjectFlags(source);
58455             if (sourceObjectFlags & (4 | 16) && unionTarget.flags & 1048576) {
58456                 return ts.find(unionTarget.types, function (target) {
58457                     if (target.flags & 524288) {
58458                         var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target);
58459                         if (overlapObjFlags & 4) {
58460                             return source.target === target.target;
58461                         }
58462                         if (overlapObjFlags & 16) {
58463                             return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol;
58464                         }
58465                     }
58466                     return false;
58467                 });
58468             }
58469         }
58470         function findBestTypeForObjectLiteral(source, unionTarget) {
58471             if (ts.getObjectFlags(source) & 128 && forEachType(unionTarget, isArrayLikeType)) {
58472                 return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); });
58473             }
58474         }
58475         function findBestTypeForInvokable(source, unionTarget) {
58476             var signatureKind = 0;
58477             var hasSignatures = getSignaturesOfType(source, signatureKind).length > 0 ||
58478                 (signatureKind = 1, getSignaturesOfType(source, signatureKind).length > 0);
58479             if (hasSignatures) {
58480                 return ts.find(unionTarget.types, function (t) { return getSignaturesOfType(t, signatureKind).length > 0; });
58481             }
58482         }
58483         function findMostOverlappyType(source, unionTarget) {
58484             var bestMatch;
58485             var matchingCount = 0;
58486             for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
58487                 var target = _a[_i];
58488                 var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
58489                 if (overlap.flags & 4194304) {
58490                     bestMatch = target;
58491                     matchingCount = Infinity;
58492                 }
58493                 else if (overlap.flags & 1048576) {
58494                     var len = ts.length(ts.filter(overlap.types, isUnitType));
58495                     if (len >= matchingCount) {
58496                         bestMatch = target;
58497                         matchingCount = len;
58498                     }
58499                 }
58500                 else if (isUnitType(overlap) && 1 >= matchingCount) {
58501                     bestMatch = target;
58502                     matchingCount = 1;
58503                 }
58504             }
58505             return bestMatch;
58506         }
58507         function filterPrimitivesIfContainsNonPrimitive(type) {
58508             if (maybeTypeOfKind(type, 67108864)) {
58509                 var result = filterType(type, function (t) { return !(t.flags & 131068); });
58510                 if (!(result.flags & 131072)) {
58511                     return result;
58512                 }
58513             }
58514             return type;
58515         }
58516         function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) {
58517             if (target.flags & 1048576 && source.flags & (2097152 | 524288)) {
58518                 var sourceProperties = getPropertiesOfType(source);
58519                 if (sourceProperties) {
58520                     var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
58521                     if (sourcePropertiesFiltered) {
58522                         return discriminateTypeByDiscriminableItems(target, ts.map(sourcePropertiesFiltered, function (p) { return [function () { return getTypeOfSymbol(p); }, p.escapedName]; }), isRelatedTo, undefined, skipPartial);
58523                     }
58524                 }
58525             }
58526             return undefined;
58527         }
58528     }
58529     ts.createTypeChecker = createTypeChecker;
58530     function isNotAccessor(declaration) {
58531         return !ts.isAccessor(declaration);
58532     }
58533     function isNotOverload(declaration) {
58534         return (declaration.kind !== 244 && declaration.kind !== 161) ||
58535             !!declaration.body;
58536     }
58537     function isDeclarationNameOrImportPropertyName(name) {
58538         switch (name.parent.kind) {
58539             case 258:
58540             case 263:
58541                 return ts.isIdentifier(name);
58542             default:
58543                 return ts.isDeclarationName(name);
58544         }
58545     }
58546     function isSomeImportDeclaration(decl) {
58547         switch (decl.kind) {
58548             case 255:
58549             case 253:
58550             case 256:
58551             case 258:
58552                 return true;
58553             case 75:
58554                 return decl.parent.kind === 258;
58555             default:
58556                 return false;
58557         }
58558     }
58559     var JsxNames;
58560     (function (JsxNames) {
58561         JsxNames.JSX = "JSX";
58562         JsxNames.IntrinsicElements = "IntrinsicElements";
58563         JsxNames.ElementClass = "ElementClass";
58564         JsxNames.ElementAttributesPropertyNameContainer = "ElementAttributesProperty";
58565         JsxNames.ElementChildrenAttributeNameContainer = "ElementChildrenAttribute";
58566         JsxNames.Element = "Element";
58567         JsxNames.IntrinsicAttributes = "IntrinsicAttributes";
58568         JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes";
58569         JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes";
58570     })(JsxNames || (JsxNames = {}));
58571     function getIterationTypesKeyFromIterationTypeKind(typeKind) {
58572         switch (typeKind) {
58573             case 0: return "yieldType";
58574             case 1: return "returnType";
58575             case 2: return "nextType";
58576         }
58577     }
58578     function signatureHasRestParameter(s) {
58579         return !!(s.flags & 1);
58580     }
58581     ts.signatureHasRestParameter = signatureHasRestParameter;
58582     function signatureHasLiteralTypes(s) {
58583         return !!(s.flags & 2);
58584     }
58585     ts.signatureHasLiteralTypes = signatureHasLiteralTypes;
58586 })(ts || (ts = {}));
58587 var ts;
58588 (function (ts) {
58589     function createSynthesizedNode(kind) {
58590         var node = ts.createNode(kind, -1, -1);
58591         node.flags |= 8;
58592         return node;
58593     }
58594     function updateNode(updated, original) {
58595         if (updated !== original) {
58596             setOriginalNode(updated, original);
58597             setTextRange(updated, original);
58598             ts.aggregateTransformFlags(updated);
58599         }
58600         return updated;
58601     }
58602     ts.updateNode = updateNode;
58603     function createNodeArray(elements, hasTrailingComma) {
58604         if (!elements || elements === ts.emptyArray) {
58605             elements = [];
58606         }
58607         else if (ts.isNodeArray(elements)) {
58608             return elements;
58609         }
58610         var array = elements;
58611         array.pos = -1;
58612         array.end = -1;
58613         array.hasTrailingComma = hasTrailingComma;
58614         return array;
58615     }
58616     ts.createNodeArray = createNodeArray;
58617     function getSynthesizedClone(node) {
58618         if (node === undefined) {
58619             return node;
58620         }
58621         var clone = createSynthesizedNode(node.kind);
58622         clone.flags |= node.flags;
58623         setOriginalNode(clone, node);
58624         for (var key in node) {
58625             if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) {
58626                 continue;
58627             }
58628             clone[key] = node[key];
58629         }
58630         return clone;
58631     }
58632     ts.getSynthesizedClone = getSynthesizedClone;
58633     function createLiteral(value, isSingleQuote) {
58634         if (typeof value === "number") {
58635             return createNumericLiteral(value + "");
58636         }
58637         if (typeof value === "object" && "base10Value" in value) {
58638             return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n");
58639         }
58640         if (typeof value === "boolean") {
58641             return value ? createTrue() : createFalse();
58642         }
58643         if (ts.isString(value)) {
58644             var res = createStringLiteral(value);
58645             if (isSingleQuote)
58646                 res.singleQuote = true;
58647             return res;
58648         }
58649         return createLiteralFromNode(value);
58650     }
58651     ts.createLiteral = createLiteral;
58652     function createNumericLiteral(value, numericLiteralFlags) {
58653         if (numericLiteralFlags === void 0) { numericLiteralFlags = 0; }
58654         var node = createSynthesizedNode(8);
58655         node.text = value;
58656         node.numericLiteralFlags = numericLiteralFlags;
58657         return node;
58658     }
58659     ts.createNumericLiteral = createNumericLiteral;
58660     function createBigIntLiteral(value) {
58661         var node = createSynthesizedNode(9);
58662         node.text = value;
58663         return node;
58664     }
58665     ts.createBigIntLiteral = createBigIntLiteral;
58666     function createStringLiteral(text) {
58667         var node = createSynthesizedNode(10);
58668         node.text = text;
58669         return node;
58670     }
58671     ts.createStringLiteral = createStringLiteral;
58672     function createRegularExpressionLiteral(text) {
58673         var node = createSynthesizedNode(13);
58674         node.text = text;
58675         return node;
58676     }
58677     ts.createRegularExpressionLiteral = createRegularExpressionLiteral;
58678     function createLiteralFromNode(sourceNode) {
58679         var node = createStringLiteral(ts.getTextOfIdentifierOrLiteral(sourceNode));
58680         node.textSourceNode = sourceNode;
58681         return node;
58682     }
58683     function createIdentifier(text, typeArguments) {
58684         var node = createSynthesizedNode(75);
58685         node.escapedText = ts.escapeLeadingUnderscores(text);
58686         node.originalKeywordKind = text ? ts.stringToToken(text) : 0;
58687         node.autoGenerateFlags = 0;
58688         node.autoGenerateId = 0;
58689         if (typeArguments) {
58690             node.typeArguments = createNodeArray(typeArguments);
58691         }
58692         return node;
58693     }
58694     ts.createIdentifier = createIdentifier;
58695     function updateIdentifier(node, typeArguments) {
58696         return node.typeArguments !== typeArguments
58697             ? updateNode(createIdentifier(ts.idText(node), typeArguments), node)
58698             : node;
58699     }
58700     ts.updateIdentifier = updateIdentifier;
58701     var nextAutoGenerateId = 0;
58702     function createTempVariable(recordTempVariable, reservedInNestedScopes) {
58703         var name = createIdentifier("");
58704         name.autoGenerateFlags = 1;
58705         name.autoGenerateId = nextAutoGenerateId;
58706         nextAutoGenerateId++;
58707         if (recordTempVariable) {
58708             recordTempVariable(name);
58709         }
58710         if (reservedInNestedScopes) {
58711             name.autoGenerateFlags |= 8;
58712         }
58713         return name;
58714     }
58715     ts.createTempVariable = createTempVariable;
58716     function createLoopVariable() {
58717         var name = createIdentifier("");
58718         name.autoGenerateFlags = 2;
58719         name.autoGenerateId = nextAutoGenerateId;
58720         nextAutoGenerateId++;
58721         return name;
58722     }
58723     ts.createLoopVariable = createLoopVariable;
58724     function createUniqueName(text) {
58725         var name = createIdentifier(text);
58726         name.autoGenerateFlags = 3;
58727         name.autoGenerateId = nextAutoGenerateId;
58728         nextAutoGenerateId++;
58729         return name;
58730     }
58731     ts.createUniqueName = createUniqueName;
58732     function createOptimisticUniqueName(text) {
58733         var name = createIdentifier(text);
58734         name.autoGenerateFlags = 3 | 16;
58735         name.autoGenerateId = nextAutoGenerateId;
58736         nextAutoGenerateId++;
58737         return name;
58738     }
58739     ts.createOptimisticUniqueName = createOptimisticUniqueName;
58740     function createFileLevelUniqueName(text) {
58741         var name = createOptimisticUniqueName(text);
58742         name.autoGenerateFlags |= 32;
58743         return name;
58744     }
58745     ts.createFileLevelUniqueName = createFileLevelUniqueName;
58746     function getGeneratedNameForNode(node, flags) {
58747         var name = createIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "");
58748         name.autoGenerateFlags = 4 | flags;
58749         name.autoGenerateId = nextAutoGenerateId;
58750         name.original = node;
58751         nextAutoGenerateId++;
58752         return name;
58753     }
58754     ts.getGeneratedNameForNode = getGeneratedNameForNode;
58755     function createPrivateIdentifier(text) {
58756         if (text[0] !== "#") {
58757             ts.Debug.fail("First character of private identifier must be #: " + text);
58758         }
58759         var node = createSynthesizedNode(76);
58760         node.escapedText = ts.escapeLeadingUnderscores(text);
58761         return node;
58762     }
58763     ts.createPrivateIdentifier = createPrivateIdentifier;
58764     function createToken(token) {
58765         return createSynthesizedNode(token);
58766     }
58767     ts.createToken = createToken;
58768     function createSuper() {
58769         return createSynthesizedNode(102);
58770     }
58771     ts.createSuper = createSuper;
58772     function createThis() {
58773         return createSynthesizedNode(104);
58774     }
58775     ts.createThis = createThis;
58776     function createNull() {
58777         return createSynthesizedNode(100);
58778     }
58779     ts.createNull = createNull;
58780     function createTrue() {
58781         return createSynthesizedNode(106);
58782     }
58783     ts.createTrue = createTrue;
58784     function createFalse() {
58785         return createSynthesizedNode(91);
58786     }
58787     ts.createFalse = createFalse;
58788     function createModifier(kind) {
58789         return createToken(kind);
58790     }
58791     ts.createModifier = createModifier;
58792     function createModifiersFromModifierFlags(flags) {
58793         var result = [];
58794         if (flags & 1) {
58795             result.push(createModifier(89));
58796         }
58797         if (flags & 2) {
58798             result.push(createModifier(130));
58799         }
58800         if (flags & 512) {
58801             result.push(createModifier(84));
58802         }
58803         if (flags & 2048) {
58804             result.push(createModifier(81));
58805         }
58806         if (flags & 4) {
58807             result.push(createModifier(119));
58808         }
58809         if (flags & 8) {
58810             result.push(createModifier(117));
58811         }
58812         if (flags & 16) {
58813             result.push(createModifier(118));
58814         }
58815         if (flags & 128) {
58816             result.push(createModifier(122));
58817         }
58818         if (flags & 32) {
58819             result.push(createModifier(120));
58820         }
58821         if (flags & 64) {
58822             result.push(createModifier(138));
58823         }
58824         if (flags & 256) {
58825             result.push(createModifier(126));
58826         }
58827         return result;
58828     }
58829     ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags;
58830     function createQualifiedName(left, right) {
58831         var node = createSynthesizedNode(153);
58832         node.left = left;
58833         node.right = asName(right);
58834         return node;
58835     }
58836     ts.createQualifiedName = createQualifiedName;
58837     function updateQualifiedName(node, left, right) {
58838         return node.left !== left
58839             || node.right !== right
58840             ? updateNode(createQualifiedName(left, right), node)
58841             : node;
58842     }
58843     ts.updateQualifiedName = updateQualifiedName;
58844     function parenthesizeForComputedName(expression) {
58845         return ts.isCommaSequence(expression)
58846             ? createParen(expression)
58847             : expression;
58848     }
58849     function createComputedPropertyName(expression) {
58850         var node = createSynthesizedNode(154);
58851         node.expression = parenthesizeForComputedName(expression);
58852         return node;
58853     }
58854     ts.createComputedPropertyName = createComputedPropertyName;
58855     function updateComputedPropertyName(node, expression) {
58856         return node.expression !== expression
58857             ? updateNode(createComputedPropertyName(expression), node)
58858             : node;
58859     }
58860     ts.updateComputedPropertyName = updateComputedPropertyName;
58861     function createTypeParameterDeclaration(name, constraint, defaultType) {
58862         var node = createSynthesizedNode(155);
58863         node.name = asName(name);
58864         node.constraint = constraint;
58865         node.default = defaultType;
58866         return node;
58867     }
58868     ts.createTypeParameterDeclaration = createTypeParameterDeclaration;
58869     function updateTypeParameterDeclaration(node, name, constraint, defaultType) {
58870         return node.name !== name
58871             || node.constraint !== constraint
58872             || node.default !== defaultType
58873             ? updateNode(createTypeParameterDeclaration(name, constraint, defaultType), node)
58874             : node;
58875     }
58876     ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration;
58877     function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) {
58878         var node = createSynthesizedNode(156);
58879         node.decorators = asNodeArray(decorators);
58880         node.modifiers = asNodeArray(modifiers);
58881         node.dotDotDotToken = dotDotDotToken;
58882         node.name = asName(name);
58883         node.questionToken = questionToken;
58884         node.type = type;
58885         node.initializer = initializer ? ts.parenthesizeExpressionForList(initializer) : undefined;
58886         return node;
58887     }
58888     ts.createParameter = createParameter;
58889     function updateParameter(node, decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) {
58890         return node.decorators !== decorators
58891             || node.modifiers !== modifiers
58892             || node.dotDotDotToken !== dotDotDotToken
58893             || node.name !== name
58894             || node.questionToken !== questionToken
58895             || node.type !== type
58896             || node.initializer !== initializer
58897             ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer), node)
58898             : node;
58899     }
58900     ts.updateParameter = updateParameter;
58901     function createDecorator(expression) {
58902         var node = createSynthesizedNode(157);
58903         node.expression = ts.parenthesizeForAccess(expression);
58904         return node;
58905     }
58906     ts.createDecorator = createDecorator;
58907     function updateDecorator(node, expression) {
58908         return node.expression !== expression
58909             ? updateNode(createDecorator(expression), node)
58910             : node;
58911     }
58912     ts.updateDecorator = updateDecorator;
58913     function createPropertySignature(modifiers, name, questionToken, type, initializer) {
58914         var node = createSynthesizedNode(158);
58915         node.modifiers = asNodeArray(modifiers);
58916         node.name = asName(name);
58917         node.questionToken = questionToken;
58918         node.type = type;
58919         node.initializer = initializer;
58920         return node;
58921     }
58922     ts.createPropertySignature = createPropertySignature;
58923     function updatePropertySignature(node, modifiers, name, questionToken, type, initializer) {
58924         return node.modifiers !== modifiers
58925             || node.name !== name
58926             || node.questionToken !== questionToken
58927             || node.type !== type
58928             || node.initializer !== initializer
58929             ? updateNode(createPropertySignature(modifiers, name, questionToken, type, initializer), node)
58930             : node;
58931     }
58932     ts.updatePropertySignature = updatePropertySignature;
58933     function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) {
58934         var node = createSynthesizedNode(159);
58935         node.decorators = asNodeArray(decorators);
58936         node.modifiers = asNodeArray(modifiers);
58937         node.name = asName(name);
58938         node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 ? questionOrExclamationToken : undefined;
58939         node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 ? questionOrExclamationToken : undefined;
58940         node.type = type;
58941         node.initializer = initializer;
58942         return node;
58943     }
58944     ts.createProperty = createProperty;
58945     function updateProperty(node, decorators, modifiers, name, questionOrExclamationToken, type, initializer) {
58946         return node.decorators !== decorators
58947             || node.modifiers !== modifiers
58948             || node.name !== name
58949             || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 ? questionOrExclamationToken : undefined)
58950             || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 ? questionOrExclamationToken : undefined)
58951             || node.type !== type
58952             || node.initializer !== initializer
58953             ? updateNode(createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node)
58954             : node;
58955     }
58956     ts.updateProperty = updateProperty;
58957     function createMethodSignature(typeParameters, parameters, type, name, questionToken) {
58958         var node = createSignatureDeclaration(160, typeParameters, parameters, type);
58959         node.name = asName(name);
58960         node.questionToken = questionToken;
58961         return node;
58962     }
58963     ts.createMethodSignature = createMethodSignature;
58964     function updateMethodSignature(node, typeParameters, parameters, type, name, questionToken) {
58965         return node.typeParameters !== typeParameters
58966             || node.parameters !== parameters
58967             || node.type !== type
58968             || node.name !== name
58969             || node.questionToken !== questionToken
58970             ? updateNode(createMethodSignature(typeParameters, parameters, type, name, questionToken), node)
58971             : node;
58972     }
58973     ts.updateMethodSignature = updateMethodSignature;
58974     function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) {
58975         var node = createSynthesizedNode(161);
58976         node.decorators = asNodeArray(decorators);
58977         node.modifiers = asNodeArray(modifiers);
58978         node.asteriskToken = asteriskToken;
58979         node.name = asName(name);
58980         node.questionToken = questionToken;
58981         node.typeParameters = asNodeArray(typeParameters);
58982         node.parameters = createNodeArray(parameters);
58983         node.type = type;
58984         node.body = body;
58985         return node;
58986     }
58987     ts.createMethod = createMethod;
58988     function createMethodCall(object, methodName, argumentsList) {
58989         return createCall(createPropertyAccess(object, asName(methodName)), undefined, argumentsList);
58990     }
58991     function createGlobalMethodCall(globalObjectName, methodName, argumentsList) {
58992         return createMethodCall(createIdentifier(globalObjectName), methodName, argumentsList);
58993     }
58994     function createObjectDefinePropertyCall(target, propertyName, attributes) {
58995         return createGlobalMethodCall("Object", "defineProperty", [target, asExpression(propertyName), attributes]);
58996     }
58997     ts.createObjectDefinePropertyCall = createObjectDefinePropertyCall;
58998     function tryAddPropertyAssignment(properties, propertyName, expression) {
58999         if (expression) {
59000             properties.push(createPropertyAssignment(propertyName, expression));
59001             return true;
59002         }
59003         return false;
59004     }
59005     function createPropertyDescriptor(attributes, singleLine) {
59006         var properties = [];
59007         tryAddPropertyAssignment(properties, "enumerable", asExpression(attributes.enumerable));
59008         tryAddPropertyAssignment(properties, "configurable", asExpression(attributes.configurable));
59009         var isData = tryAddPropertyAssignment(properties, "writable", asExpression(attributes.writable));
59010         isData = tryAddPropertyAssignment(properties, "value", attributes.value) || isData;
59011         var isAccessor = tryAddPropertyAssignment(properties, "get", attributes.get);
59012         isAccessor = tryAddPropertyAssignment(properties, "set", attributes.set) || isAccessor;
59013         ts.Debug.assert(!(isData && isAccessor), "A PropertyDescriptor may not be both an accessor descriptor and a data descriptor.");
59014         return createObjectLiteral(properties, !singleLine);
59015     }
59016     ts.createPropertyDescriptor = createPropertyDescriptor;
59017     function updateMethod(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) {
59018         return node.decorators !== decorators
59019             || node.modifiers !== modifiers
59020             || node.asteriskToken !== asteriskToken
59021             || node.name !== name
59022             || node.questionToken !== questionToken
59023             || node.typeParameters !== typeParameters
59024             || node.parameters !== parameters
59025             || node.type !== type
59026             || node.body !== body
59027             ? updateNode(createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body), node)
59028             : node;
59029     }
59030     ts.updateMethod = updateMethod;
59031     function createConstructor(decorators, modifiers, parameters, body) {
59032         var node = createSynthesizedNode(162);
59033         node.decorators = asNodeArray(decorators);
59034         node.modifiers = asNodeArray(modifiers);
59035         node.typeParameters = undefined;
59036         node.parameters = createNodeArray(parameters);
59037         node.type = undefined;
59038         node.body = body;
59039         return node;
59040     }
59041     ts.createConstructor = createConstructor;
59042     function updateConstructor(node, decorators, modifiers, parameters, body) {
59043         return node.decorators !== decorators
59044             || node.modifiers !== modifiers
59045             || node.parameters !== parameters
59046             || node.body !== body
59047             ? updateNode(createConstructor(decorators, modifiers, parameters, body), node)
59048             : node;
59049     }
59050     ts.updateConstructor = updateConstructor;
59051     function createGetAccessor(decorators, modifiers, name, parameters, type, body) {
59052         var node = createSynthesizedNode(163);
59053         node.decorators = asNodeArray(decorators);
59054         node.modifiers = asNodeArray(modifiers);
59055         node.name = asName(name);
59056         node.typeParameters = undefined;
59057         node.parameters = createNodeArray(parameters);
59058         node.type = type;
59059         node.body = body;
59060         return node;
59061     }
59062     ts.createGetAccessor = createGetAccessor;
59063     function updateGetAccessor(node, decorators, modifiers, name, parameters, type, body) {
59064         return node.decorators !== decorators
59065             || node.modifiers !== modifiers
59066             || node.name !== name
59067             || node.parameters !== parameters
59068             || node.type !== type
59069             || node.body !== body
59070             ? updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body), node)
59071             : node;
59072     }
59073     ts.updateGetAccessor = updateGetAccessor;
59074     function createSetAccessor(decorators, modifiers, name, parameters, body) {
59075         var node = createSynthesizedNode(164);
59076         node.decorators = asNodeArray(decorators);
59077         node.modifiers = asNodeArray(modifiers);
59078         node.name = asName(name);
59079         node.typeParameters = undefined;
59080         node.parameters = createNodeArray(parameters);
59081         node.body = body;
59082         return node;
59083     }
59084     ts.createSetAccessor = createSetAccessor;
59085     function updateSetAccessor(node, decorators, modifiers, name, parameters, body) {
59086         return node.decorators !== decorators
59087             || node.modifiers !== modifiers
59088             || node.name !== name
59089             || node.parameters !== parameters
59090             || node.body !== body
59091             ? updateNode(createSetAccessor(decorators, modifiers, name, parameters, body), node)
59092             : node;
59093     }
59094     ts.updateSetAccessor = updateSetAccessor;
59095     function createCallSignature(typeParameters, parameters, type) {
59096         return createSignatureDeclaration(165, typeParameters, parameters, type);
59097     }
59098     ts.createCallSignature = createCallSignature;
59099     function updateCallSignature(node, typeParameters, parameters, type) {
59100         return updateSignatureDeclaration(node, typeParameters, parameters, type);
59101     }
59102     ts.updateCallSignature = updateCallSignature;
59103     function createConstructSignature(typeParameters, parameters, type) {
59104         return createSignatureDeclaration(166, typeParameters, parameters, type);
59105     }
59106     ts.createConstructSignature = createConstructSignature;
59107     function updateConstructSignature(node, typeParameters, parameters, type) {
59108         return updateSignatureDeclaration(node, typeParameters, parameters, type);
59109     }
59110     ts.updateConstructSignature = updateConstructSignature;
59111     function createIndexSignature(decorators, modifiers, parameters, type) {
59112         var node = createSynthesizedNode(167);
59113         node.decorators = asNodeArray(decorators);
59114         node.modifiers = asNodeArray(modifiers);
59115         node.parameters = createNodeArray(parameters);
59116         node.type = type;
59117         return node;
59118     }
59119     ts.createIndexSignature = createIndexSignature;
59120     function updateIndexSignature(node, decorators, modifiers, parameters, type) {
59121         return node.parameters !== parameters
59122             || node.type !== type
59123             || node.decorators !== decorators
59124             || node.modifiers !== modifiers
59125             ? updateNode(createIndexSignature(decorators, modifiers, parameters, type), node)
59126             : node;
59127     }
59128     ts.updateIndexSignature = updateIndexSignature;
59129     function createSignatureDeclaration(kind, typeParameters, parameters, type, typeArguments) {
59130         var node = createSynthesizedNode(kind);
59131         node.typeParameters = asNodeArray(typeParameters);
59132         node.parameters = asNodeArray(parameters);
59133         node.type = type;
59134         node.typeArguments = asNodeArray(typeArguments);
59135         return node;
59136     }
59137     ts.createSignatureDeclaration = createSignatureDeclaration;
59138     function updateSignatureDeclaration(node, typeParameters, parameters, type) {
59139         return node.typeParameters !== typeParameters
59140             || node.parameters !== parameters
59141             || node.type !== type
59142             ? updateNode(createSignatureDeclaration(node.kind, typeParameters, parameters, type), node)
59143             : node;
59144     }
59145     function createKeywordTypeNode(kind) {
59146         return createSynthesizedNode(kind);
59147     }
59148     ts.createKeywordTypeNode = createKeywordTypeNode;
59149     function createTypePredicateNode(parameterName, type) {
59150         return createTypePredicateNodeWithModifier(undefined, parameterName, type);
59151     }
59152     ts.createTypePredicateNode = createTypePredicateNode;
59153     function createTypePredicateNodeWithModifier(assertsModifier, parameterName, type) {
59154         var node = createSynthesizedNode(168);
59155         node.assertsModifier = assertsModifier;
59156         node.parameterName = asName(parameterName);
59157         node.type = type;
59158         return node;
59159     }
59160     ts.createTypePredicateNodeWithModifier = createTypePredicateNodeWithModifier;
59161     function updateTypePredicateNode(node, parameterName, type) {
59162         return updateTypePredicateNodeWithModifier(node, node.assertsModifier, parameterName, type);
59163     }
59164     ts.updateTypePredicateNode = updateTypePredicateNode;
59165     function updateTypePredicateNodeWithModifier(node, assertsModifier, parameterName, type) {
59166         return node.assertsModifier !== assertsModifier
59167             || node.parameterName !== parameterName
59168             || node.type !== type
59169             ? updateNode(createTypePredicateNodeWithModifier(assertsModifier, parameterName, type), node)
59170             : node;
59171     }
59172     ts.updateTypePredicateNodeWithModifier = updateTypePredicateNodeWithModifier;
59173     function createTypeReferenceNode(typeName, typeArguments) {
59174         var node = createSynthesizedNode(169);
59175         node.typeName = asName(typeName);
59176         node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments);
59177         return node;
59178     }
59179     ts.createTypeReferenceNode = createTypeReferenceNode;
59180     function updateTypeReferenceNode(node, typeName, typeArguments) {
59181         return node.typeName !== typeName
59182             || node.typeArguments !== typeArguments
59183             ? updateNode(createTypeReferenceNode(typeName, typeArguments), node)
59184             : node;
59185     }
59186     ts.updateTypeReferenceNode = updateTypeReferenceNode;
59187     function createFunctionTypeNode(typeParameters, parameters, type) {
59188         return createSignatureDeclaration(170, typeParameters, parameters, type);
59189     }
59190     ts.createFunctionTypeNode = createFunctionTypeNode;
59191     function updateFunctionTypeNode(node, typeParameters, parameters, type) {
59192         return updateSignatureDeclaration(node, typeParameters, parameters, type);
59193     }
59194     ts.updateFunctionTypeNode = updateFunctionTypeNode;
59195     function createConstructorTypeNode(typeParameters, parameters, type) {
59196         return createSignatureDeclaration(171, typeParameters, parameters, type);
59197     }
59198     ts.createConstructorTypeNode = createConstructorTypeNode;
59199     function updateConstructorTypeNode(node, typeParameters, parameters, type) {
59200         return updateSignatureDeclaration(node, typeParameters, parameters, type);
59201     }
59202     ts.updateConstructorTypeNode = updateConstructorTypeNode;
59203     function createTypeQueryNode(exprName) {
59204         var node = createSynthesizedNode(172);
59205         node.exprName = exprName;
59206         return node;
59207     }
59208     ts.createTypeQueryNode = createTypeQueryNode;
59209     function updateTypeQueryNode(node, exprName) {
59210         return node.exprName !== exprName
59211             ? updateNode(createTypeQueryNode(exprName), node)
59212             : node;
59213     }
59214     ts.updateTypeQueryNode = updateTypeQueryNode;
59215     function createTypeLiteralNode(members) {
59216         var node = createSynthesizedNode(173);
59217         node.members = createNodeArray(members);
59218         return node;
59219     }
59220     ts.createTypeLiteralNode = createTypeLiteralNode;
59221     function updateTypeLiteralNode(node, members) {
59222         return node.members !== members
59223             ? updateNode(createTypeLiteralNode(members), node)
59224             : node;
59225     }
59226     ts.updateTypeLiteralNode = updateTypeLiteralNode;
59227     function createArrayTypeNode(elementType) {
59228         var node = createSynthesizedNode(174);
59229         node.elementType = ts.parenthesizeArrayTypeMember(elementType);
59230         return node;
59231     }
59232     ts.createArrayTypeNode = createArrayTypeNode;
59233     function updateArrayTypeNode(node, elementType) {
59234         return node.elementType !== elementType
59235             ? updateNode(createArrayTypeNode(elementType), node)
59236             : node;
59237     }
59238     ts.updateArrayTypeNode = updateArrayTypeNode;
59239     function createTupleTypeNode(elementTypes) {
59240         var node = createSynthesizedNode(175);
59241         node.elementTypes = createNodeArray(elementTypes);
59242         return node;
59243     }
59244     ts.createTupleTypeNode = createTupleTypeNode;
59245     function updateTupleTypeNode(node, elementTypes) {
59246         return node.elementTypes !== elementTypes
59247             ? updateNode(createTupleTypeNode(elementTypes), node)
59248             : node;
59249     }
59250     ts.updateTupleTypeNode = updateTupleTypeNode;
59251     function createOptionalTypeNode(type) {
59252         var node = createSynthesizedNode(176);
59253         node.type = ts.parenthesizeArrayTypeMember(type);
59254         return node;
59255     }
59256     ts.createOptionalTypeNode = createOptionalTypeNode;
59257     function updateOptionalTypeNode(node, type) {
59258         return node.type !== type
59259             ? updateNode(createOptionalTypeNode(type), node)
59260             : node;
59261     }
59262     ts.updateOptionalTypeNode = updateOptionalTypeNode;
59263     function createRestTypeNode(type) {
59264         var node = createSynthesizedNode(177);
59265         node.type = type;
59266         return node;
59267     }
59268     ts.createRestTypeNode = createRestTypeNode;
59269     function updateRestTypeNode(node, type) {
59270         return node.type !== type
59271             ? updateNode(createRestTypeNode(type), node)
59272             : node;
59273     }
59274     ts.updateRestTypeNode = updateRestTypeNode;
59275     function createUnionTypeNode(types) {
59276         return createUnionOrIntersectionTypeNode(178, types);
59277     }
59278     ts.createUnionTypeNode = createUnionTypeNode;
59279     function updateUnionTypeNode(node, types) {
59280         return updateUnionOrIntersectionTypeNode(node, types);
59281     }
59282     ts.updateUnionTypeNode = updateUnionTypeNode;
59283     function createIntersectionTypeNode(types) {
59284         return createUnionOrIntersectionTypeNode(179, types);
59285     }
59286     ts.createIntersectionTypeNode = createIntersectionTypeNode;
59287     function updateIntersectionTypeNode(node, types) {
59288         return updateUnionOrIntersectionTypeNode(node, types);
59289     }
59290     ts.updateIntersectionTypeNode = updateIntersectionTypeNode;
59291     function createUnionOrIntersectionTypeNode(kind, types) {
59292         var node = createSynthesizedNode(kind);
59293         node.types = ts.parenthesizeElementTypeMembers(types);
59294         return node;
59295     }
59296     ts.createUnionOrIntersectionTypeNode = createUnionOrIntersectionTypeNode;
59297     function updateUnionOrIntersectionTypeNode(node, types) {
59298         return node.types !== types
59299             ? updateNode(createUnionOrIntersectionTypeNode(node.kind, types), node)
59300             : node;
59301     }
59302     function createConditionalTypeNode(checkType, extendsType, trueType, falseType) {
59303         var node = createSynthesizedNode(180);
59304         node.checkType = ts.parenthesizeConditionalTypeMember(checkType);
59305         node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType);
59306         node.trueType = trueType;
59307         node.falseType = falseType;
59308         return node;
59309     }
59310     ts.createConditionalTypeNode = createConditionalTypeNode;
59311     function updateConditionalTypeNode(node, checkType, extendsType, trueType, falseType) {
59312         return node.checkType !== checkType
59313             || node.extendsType !== extendsType
59314             || node.trueType !== trueType
59315             || node.falseType !== falseType
59316             ? updateNode(createConditionalTypeNode(checkType, extendsType, trueType, falseType), node)
59317             : node;
59318     }
59319     ts.updateConditionalTypeNode = updateConditionalTypeNode;
59320     function createInferTypeNode(typeParameter) {
59321         var node = createSynthesizedNode(181);
59322         node.typeParameter = typeParameter;
59323         return node;
59324     }
59325     ts.createInferTypeNode = createInferTypeNode;
59326     function updateInferTypeNode(node, typeParameter) {
59327         return node.typeParameter !== typeParameter
59328             ? updateNode(createInferTypeNode(typeParameter), node)
59329             : node;
59330     }
59331     ts.updateInferTypeNode = updateInferTypeNode;
59332     function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) {
59333         var node = createSynthesizedNode(188);
59334         node.argument = argument;
59335         node.qualifier = qualifier;
59336         node.typeArguments = ts.parenthesizeTypeParameters(typeArguments);
59337         node.isTypeOf = isTypeOf;
59338         return node;
59339     }
59340     ts.createImportTypeNode = createImportTypeNode;
59341     function updateImportTypeNode(node, argument, qualifier, typeArguments, isTypeOf) {
59342         return node.argument !== argument
59343             || node.qualifier !== qualifier
59344             || node.typeArguments !== typeArguments
59345             || node.isTypeOf !== isTypeOf
59346             ? updateNode(createImportTypeNode(argument, qualifier, typeArguments, isTypeOf), node)
59347             : node;
59348     }
59349     ts.updateImportTypeNode = updateImportTypeNode;
59350     function createParenthesizedType(type) {
59351         var node = createSynthesizedNode(182);
59352         node.type = type;
59353         return node;
59354     }
59355     ts.createParenthesizedType = createParenthesizedType;
59356     function updateParenthesizedType(node, type) {
59357         return node.type !== type
59358             ? updateNode(createParenthesizedType(type), node)
59359             : node;
59360     }
59361     ts.updateParenthesizedType = updateParenthesizedType;
59362     function createThisTypeNode() {
59363         return createSynthesizedNode(183);
59364     }
59365     ts.createThisTypeNode = createThisTypeNode;
59366     function createTypeOperatorNode(operatorOrType, type) {
59367         var node = createSynthesizedNode(184);
59368         node.operator = typeof operatorOrType === "number" ? operatorOrType : 134;
59369         node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType);
59370         return node;
59371     }
59372     ts.createTypeOperatorNode = createTypeOperatorNode;
59373     function updateTypeOperatorNode(node, type) {
59374         return node.type !== type ? updateNode(createTypeOperatorNode(node.operator, type), node) : node;
59375     }
59376     ts.updateTypeOperatorNode = updateTypeOperatorNode;
59377     function createIndexedAccessTypeNode(objectType, indexType) {
59378         var node = createSynthesizedNode(185);
59379         node.objectType = ts.parenthesizeElementTypeMember(objectType);
59380         node.indexType = indexType;
59381         return node;
59382     }
59383     ts.createIndexedAccessTypeNode = createIndexedAccessTypeNode;
59384     function updateIndexedAccessTypeNode(node, objectType, indexType) {
59385         return node.objectType !== objectType
59386             || node.indexType !== indexType
59387             ? updateNode(createIndexedAccessTypeNode(objectType, indexType), node)
59388             : node;
59389     }
59390     ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode;
59391     function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) {
59392         var node = createSynthesizedNode(186);
59393         node.readonlyToken = readonlyToken;
59394         node.typeParameter = typeParameter;
59395         node.questionToken = questionToken;
59396         node.type = type;
59397         return node;
59398     }
59399     ts.createMappedTypeNode = createMappedTypeNode;
59400     function updateMappedTypeNode(node, readonlyToken, typeParameter, questionToken, type) {
59401         return node.readonlyToken !== readonlyToken
59402             || node.typeParameter !== typeParameter
59403             || node.questionToken !== questionToken
59404             || node.type !== type
59405             ? updateNode(createMappedTypeNode(readonlyToken, typeParameter, questionToken, type), node)
59406             : node;
59407     }
59408     ts.updateMappedTypeNode = updateMappedTypeNode;
59409     function createLiteralTypeNode(literal) {
59410         var node = createSynthesizedNode(187);
59411         node.literal = literal;
59412         return node;
59413     }
59414     ts.createLiteralTypeNode = createLiteralTypeNode;
59415     function updateLiteralTypeNode(node, literal) {
59416         return node.literal !== literal
59417             ? updateNode(createLiteralTypeNode(literal), node)
59418             : node;
59419     }
59420     ts.updateLiteralTypeNode = updateLiteralTypeNode;
59421     function createObjectBindingPattern(elements) {
59422         var node = createSynthesizedNode(189);
59423         node.elements = createNodeArray(elements);
59424         return node;
59425     }
59426     ts.createObjectBindingPattern = createObjectBindingPattern;
59427     function updateObjectBindingPattern(node, elements) {
59428         return node.elements !== elements
59429             ? updateNode(createObjectBindingPattern(elements), node)
59430             : node;
59431     }
59432     ts.updateObjectBindingPattern = updateObjectBindingPattern;
59433     function createArrayBindingPattern(elements) {
59434         var node = createSynthesizedNode(190);
59435         node.elements = createNodeArray(elements);
59436         return node;
59437     }
59438     ts.createArrayBindingPattern = createArrayBindingPattern;
59439     function updateArrayBindingPattern(node, elements) {
59440         return node.elements !== elements
59441             ? updateNode(createArrayBindingPattern(elements), node)
59442             : node;
59443     }
59444     ts.updateArrayBindingPattern = updateArrayBindingPattern;
59445     function createBindingElement(dotDotDotToken, propertyName, name, initializer) {
59446         var node = createSynthesizedNode(191);
59447         node.dotDotDotToken = dotDotDotToken;
59448         node.propertyName = asName(propertyName);
59449         node.name = asName(name);
59450         node.initializer = initializer;
59451         return node;
59452     }
59453     ts.createBindingElement = createBindingElement;
59454     function updateBindingElement(node, dotDotDotToken, propertyName, name, initializer) {
59455         return node.propertyName !== propertyName
59456             || node.dotDotDotToken !== dotDotDotToken
59457             || node.name !== name
59458             || node.initializer !== initializer
59459             ? updateNode(createBindingElement(dotDotDotToken, propertyName, name, initializer), node)
59460             : node;
59461     }
59462     ts.updateBindingElement = updateBindingElement;
59463     function createArrayLiteral(elements, multiLine) {
59464         var node = createSynthesizedNode(192);
59465         node.elements = ts.parenthesizeListElements(createNodeArray(elements));
59466         if (multiLine)
59467             node.multiLine = true;
59468         return node;
59469     }
59470     ts.createArrayLiteral = createArrayLiteral;
59471     function updateArrayLiteral(node, elements) {
59472         return node.elements !== elements
59473             ? updateNode(createArrayLiteral(elements, node.multiLine), node)
59474             : node;
59475     }
59476     ts.updateArrayLiteral = updateArrayLiteral;
59477     function createObjectLiteral(properties, multiLine) {
59478         var node = createSynthesizedNode(193);
59479         node.properties = createNodeArray(properties);
59480         if (multiLine)
59481             node.multiLine = true;
59482         return node;
59483     }
59484     ts.createObjectLiteral = createObjectLiteral;
59485     function updateObjectLiteral(node, properties) {
59486         return node.properties !== properties
59487             ? updateNode(createObjectLiteral(properties, node.multiLine), node)
59488             : node;
59489     }
59490     ts.updateObjectLiteral = updateObjectLiteral;
59491     function createPropertyAccess(expression, name) {
59492         var node = createSynthesizedNode(194);
59493         node.expression = ts.parenthesizeForAccess(expression);
59494         node.name = asName(name);
59495         setEmitFlags(node, 131072);
59496         return node;
59497     }
59498     ts.createPropertyAccess = createPropertyAccess;
59499     function updatePropertyAccess(node, expression, name) {
59500         if (ts.isPropertyAccessChain(node)) {
59501             return updatePropertyAccessChain(node, expression, node.questionDotToken, ts.cast(name, ts.isIdentifier));
59502         }
59503         return node.expression !== expression
59504             || node.name !== name
59505             ? updateNode(setEmitFlags(createPropertyAccess(expression, name), ts.getEmitFlags(node)), node)
59506             : node;
59507     }
59508     ts.updatePropertyAccess = updatePropertyAccess;
59509     function createPropertyAccessChain(expression, questionDotToken, name) {
59510         var node = createSynthesizedNode(194);
59511         node.flags |= 32;
59512         node.expression = ts.parenthesizeForAccess(expression);
59513         node.questionDotToken = questionDotToken;
59514         node.name = asName(name);
59515         setEmitFlags(node, 131072);
59516         return node;
59517     }
59518     ts.createPropertyAccessChain = createPropertyAccessChain;
59519     function updatePropertyAccessChain(node, expression, questionDotToken, name) {
59520         ts.Debug.assert(!!(node.flags & 32), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead.");
59521         return node.expression !== expression
59522             || node.questionDotToken !== questionDotToken
59523             || node.name !== name
59524             ? updateNode(setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), ts.getEmitFlags(node)), node)
59525             : node;
59526     }
59527     ts.updatePropertyAccessChain = updatePropertyAccessChain;
59528     function createElementAccess(expression, index) {
59529         var node = createSynthesizedNode(195);
59530         node.expression = ts.parenthesizeForAccess(expression);
59531         node.argumentExpression = asExpression(index);
59532         return node;
59533     }
59534     ts.createElementAccess = createElementAccess;
59535     function updateElementAccess(node, expression, argumentExpression) {
59536         if (ts.isOptionalChain(node)) {
59537             return updateElementAccessChain(node, expression, node.questionDotToken, argumentExpression);
59538         }
59539         return node.expression !== expression
59540             || node.argumentExpression !== argumentExpression
59541             ? updateNode(createElementAccess(expression, argumentExpression), node)
59542             : node;
59543     }
59544     ts.updateElementAccess = updateElementAccess;
59545     function createElementAccessChain(expression, questionDotToken, index) {
59546         var node = createSynthesizedNode(195);
59547         node.flags |= 32;
59548         node.expression = ts.parenthesizeForAccess(expression);
59549         node.questionDotToken = questionDotToken;
59550         node.argumentExpression = asExpression(index);
59551         return node;
59552     }
59553     ts.createElementAccessChain = createElementAccessChain;
59554     function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) {
59555         ts.Debug.assert(!!(node.flags & 32), "Cannot update an ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead.");
59556         return node.expression !== expression
59557             || node.questionDotToken !== questionDotToken
59558             || node.argumentExpression !== argumentExpression
59559             ? updateNode(createElementAccessChain(expression, questionDotToken, argumentExpression), node)
59560             : node;
59561     }
59562     ts.updateElementAccessChain = updateElementAccessChain;
59563     function createCall(expression, typeArguments, argumentsArray) {
59564         var node = createSynthesizedNode(196);
59565         node.expression = ts.parenthesizeForAccess(expression);
59566         node.typeArguments = asNodeArray(typeArguments);
59567         node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray));
59568         return node;
59569     }
59570     ts.createCall = createCall;
59571     function updateCall(node, expression, typeArguments, argumentsArray) {
59572         if (ts.isOptionalChain(node)) {
59573             return updateCallChain(node, expression, node.questionDotToken, typeArguments, argumentsArray);
59574         }
59575         return node.expression !== expression
59576             || node.typeArguments !== typeArguments
59577             || node.arguments !== argumentsArray
59578             ? updateNode(createCall(expression, typeArguments, argumentsArray), node)
59579             : node;
59580     }
59581     ts.updateCall = updateCall;
59582     function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) {
59583         var node = createSynthesizedNode(196);
59584         node.flags |= 32;
59585         node.expression = ts.parenthesizeForAccess(expression);
59586         node.questionDotToken = questionDotToken;
59587         node.typeArguments = asNodeArray(typeArguments);
59588         node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray));
59589         return node;
59590     }
59591     ts.createCallChain = createCallChain;
59592     function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) {
59593         ts.Debug.assert(!!(node.flags & 32), "Cannot update a CallExpression using updateCallChain. Use updateCall instead.");
59594         return node.expression !== expression
59595             || node.questionDotToken !== questionDotToken
59596             || node.typeArguments !== typeArguments
59597             || node.arguments !== argumentsArray
59598             ? updateNode(createCallChain(expression, questionDotToken, typeArguments, argumentsArray), node)
59599             : node;
59600     }
59601     ts.updateCallChain = updateCallChain;
59602     function createNew(expression, typeArguments, argumentsArray) {
59603         var node = createSynthesizedNode(197);
59604         node.expression = ts.parenthesizeForNew(expression);
59605         node.typeArguments = asNodeArray(typeArguments);
59606         node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined;
59607         return node;
59608     }
59609     ts.createNew = createNew;
59610     function updateNew(node, expression, typeArguments, argumentsArray) {
59611         return node.expression !== expression
59612             || node.typeArguments !== typeArguments
59613             || node.arguments !== argumentsArray
59614             ? updateNode(createNew(expression, typeArguments, argumentsArray), node)
59615             : node;
59616     }
59617     ts.updateNew = updateNew;
59618     function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) {
59619         var node = createSynthesizedNode(198);
59620         node.tag = ts.parenthesizeForAccess(tag);
59621         if (template) {
59622             node.typeArguments = asNodeArray(typeArgumentsOrTemplate);
59623             node.template = template;
59624         }
59625         else {
59626             node.typeArguments = undefined;
59627             node.template = typeArgumentsOrTemplate;
59628         }
59629         return node;
59630     }
59631     ts.createTaggedTemplate = createTaggedTemplate;
59632     function updateTaggedTemplate(node, tag, typeArgumentsOrTemplate, template) {
59633         return node.tag !== tag
59634             || (template
59635                 ? node.typeArguments !== typeArgumentsOrTemplate || node.template !== template
59636                 : node.typeArguments !== undefined || node.template !== typeArgumentsOrTemplate)
59637             ? updateNode(createTaggedTemplate(tag, typeArgumentsOrTemplate, template), node)
59638             : node;
59639     }
59640     ts.updateTaggedTemplate = updateTaggedTemplate;
59641     function createTypeAssertion(type, expression) {
59642         var node = createSynthesizedNode(199);
59643         node.type = type;
59644         node.expression = ts.parenthesizePrefixOperand(expression);
59645         return node;
59646     }
59647     ts.createTypeAssertion = createTypeAssertion;
59648     function updateTypeAssertion(node, type, expression) {
59649         return node.type !== type
59650             || node.expression !== expression
59651             ? updateNode(createTypeAssertion(type, expression), node)
59652             : node;
59653     }
59654     ts.updateTypeAssertion = updateTypeAssertion;
59655     function createParen(expression) {
59656         var node = createSynthesizedNode(200);
59657         node.expression = expression;
59658         return node;
59659     }
59660     ts.createParen = createParen;
59661     function updateParen(node, expression) {
59662         return node.expression !== expression
59663             ? updateNode(createParen(expression), node)
59664             : node;
59665     }
59666     ts.updateParen = updateParen;
59667     function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
59668         var node = createSynthesizedNode(201);
59669         node.modifiers = asNodeArray(modifiers);
59670         node.asteriskToken = asteriskToken;
59671         node.name = asName(name);
59672         node.typeParameters = asNodeArray(typeParameters);
59673         node.parameters = createNodeArray(parameters);
59674         node.type = type;
59675         node.body = body;
59676         return node;
59677     }
59678     ts.createFunctionExpression = createFunctionExpression;
59679     function updateFunctionExpression(node, modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
59680         return node.name !== name
59681             || node.modifiers !== modifiers
59682             || node.asteriskToken !== asteriskToken
59683             || node.typeParameters !== typeParameters
59684             || node.parameters !== parameters
59685             || node.type !== type
59686             || node.body !== body
59687             ? updateNode(createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body), node)
59688             : node;
59689     }
59690     ts.updateFunctionExpression = updateFunctionExpression;
59691     function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) {
59692         var node = createSynthesizedNode(202);
59693         node.modifiers = asNodeArray(modifiers);
59694         node.typeParameters = asNodeArray(typeParameters);
59695         node.parameters = createNodeArray(parameters);
59696         node.type = type;
59697         node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(38);
59698         node.body = ts.parenthesizeConciseBody(body);
59699         return node;
59700     }
59701     ts.createArrowFunction = createArrowFunction;
59702     function updateArrowFunction(node, modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) {
59703         return node.modifiers !== modifiers
59704             || node.typeParameters !== typeParameters
59705             || node.parameters !== parameters
59706             || node.type !== type
59707             || node.equalsGreaterThanToken !== equalsGreaterThanToken
59708             || node.body !== body
59709             ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body), node)
59710             : node;
59711     }
59712     ts.updateArrowFunction = updateArrowFunction;
59713     function createDelete(expression) {
59714         var node = createSynthesizedNode(203);
59715         node.expression = ts.parenthesizePrefixOperand(expression);
59716         return node;
59717     }
59718     ts.createDelete = createDelete;
59719     function updateDelete(node, expression) {
59720         return node.expression !== expression
59721             ? updateNode(createDelete(expression), node)
59722             : node;
59723     }
59724     ts.updateDelete = updateDelete;
59725     function createTypeOf(expression) {
59726         var node = createSynthesizedNode(204);
59727         node.expression = ts.parenthesizePrefixOperand(expression);
59728         return node;
59729     }
59730     ts.createTypeOf = createTypeOf;
59731     function updateTypeOf(node, expression) {
59732         return node.expression !== expression
59733             ? updateNode(createTypeOf(expression), node)
59734             : node;
59735     }
59736     ts.updateTypeOf = updateTypeOf;
59737     function createVoid(expression) {
59738         var node = createSynthesizedNode(205);
59739         node.expression = ts.parenthesizePrefixOperand(expression);
59740         return node;
59741     }
59742     ts.createVoid = createVoid;
59743     function updateVoid(node, expression) {
59744         return node.expression !== expression
59745             ? updateNode(createVoid(expression), node)
59746             : node;
59747     }
59748     ts.updateVoid = updateVoid;
59749     function createAwait(expression) {
59750         var node = createSynthesizedNode(206);
59751         node.expression = ts.parenthesizePrefixOperand(expression);
59752         return node;
59753     }
59754     ts.createAwait = createAwait;
59755     function updateAwait(node, expression) {
59756         return node.expression !== expression
59757             ? updateNode(createAwait(expression), node)
59758             : node;
59759     }
59760     ts.updateAwait = updateAwait;
59761     function createPrefix(operator, operand) {
59762         var node = createSynthesizedNode(207);
59763         node.operator = operator;
59764         node.operand = ts.parenthesizePrefixOperand(operand);
59765         return node;
59766     }
59767     ts.createPrefix = createPrefix;
59768     function updatePrefix(node, operand) {
59769         return node.operand !== operand
59770             ? updateNode(createPrefix(node.operator, operand), node)
59771             : node;
59772     }
59773     ts.updatePrefix = updatePrefix;
59774     function createPostfix(operand, operator) {
59775         var node = createSynthesizedNode(208);
59776         node.operand = ts.parenthesizePostfixOperand(operand);
59777         node.operator = operator;
59778         return node;
59779     }
59780     ts.createPostfix = createPostfix;
59781     function updatePostfix(node, operand) {
59782         return node.operand !== operand
59783             ? updateNode(createPostfix(operand, node.operator), node)
59784             : node;
59785     }
59786     ts.updatePostfix = updatePostfix;
59787     function createBinary(left, operator, right) {
59788         var node = createSynthesizedNode(209);
59789         var operatorToken = asToken(operator);
59790         var operatorKind = operatorToken.kind;
59791         node.left = ts.parenthesizeBinaryOperand(operatorKind, left, true, undefined);
59792         node.operatorToken = operatorToken;
59793         node.right = ts.parenthesizeBinaryOperand(operatorKind, right, false, node.left);
59794         return node;
59795     }
59796     ts.createBinary = createBinary;
59797     function updateBinary(node, left, right, operator) {
59798         return node.left !== left
59799             || node.right !== right
59800             ? updateNode(createBinary(left, operator || node.operatorToken, right), node)
59801             : node;
59802     }
59803     ts.updateBinary = updateBinary;
59804     function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) {
59805         var node = createSynthesizedNode(210);
59806         node.condition = ts.parenthesizeForConditionalHead(condition);
59807         node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(57);
59808         node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue);
59809         node.colonToken = whenFalse ? colonToken : createToken(58);
59810         node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse);
59811         return node;
59812     }
59813     ts.createConditional = createConditional;
59814     function updateConditional(node, condition, questionToken, whenTrue, colonToken, whenFalse) {
59815         return node.condition !== condition
59816             || node.questionToken !== questionToken
59817             || node.whenTrue !== whenTrue
59818             || node.colonToken !== colonToken
59819             || node.whenFalse !== whenFalse
59820             ? updateNode(createConditional(condition, questionToken, whenTrue, colonToken, whenFalse), node)
59821             : node;
59822     }
59823     ts.updateConditional = updateConditional;
59824     function createTemplateExpression(head, templateSpans) {
59825         var node = createSynthesizedNode(211);
59826         node.head = head;
59827         node.templateSpans = createNodeArray(templateSpans);
59828         return node;
59829     }
59830     ts.createTemplateExpression = createTemplateExpression;
59831     function updateTemplateExpression(node, head, templateSpans) {
59832         return node.head !== head
59833             || node.templateSpans !== templateSpans
59834             ? updateNode(createTemplateExpression(head, templateSpans), node)
59835             : node;
59836     }
59837     ts.updateTemplateExpression = updateTemplateExpression;
59838     var rawTextScanner;
59839     var invalidValueSentinel = {};
59840     function getCookedText(kind, rawText) {
59841         if (!rawTextScanner) {
59842             rawTextScanner = ts.createScanner(99, false, 0);
59843         }
59844         switch (kind) {
59845             case 14:
59846                 rawTextScanner.setText("`" + rawText + "`");
59847                 break;
59848             case 15:
59849                 rawTextScanner.setText("`" + rawText + "${");
59850                 break;
59851             case 16:
59852                 rawTextScanner.setText("}" + rawText + "${");
59853                 break;
59854             case 17:
59855                 rawTextScanner.setText("}" + rawText + "`");
59856                 break;
59857         }
59858         var token = rawTextScanner.scan();
59859         if (token === 23) {
59860             token = rawTextScanner.reScanTemplateToken(false);
59861         }
59862         if (rawTextScanner.isUnterminated()) {
59863             rawTextScanner.setText(undefined);
59864             return invalidValueSentinel;
59865         }
59866         var tokenValue;
59867         switch (token) {
59868             case 14:
59869             case 15:
59870             case 16:
59871             case 17:
59872                 tokenValue = rawTextScanner.getTokenValue();
59873                 break;
59874         }
59875         if (rawTextScanner.scan() !== 1) {
59876             rawTextScanner.setText(undefined);
59877             return invalidValueSentinel;
59878         }
59879         rawTextScanner.setText(undefined);
59880         return tokenValue;
59881     }
59882     function createTemplateLiteralLikeNode(kind, text, rawText) {
59883         var node = createSynthesizedNode(kind);
59884         node.text = text;
59885         if (rawText === undefined || text === rawText) {
59886             node.rawText = rawText;
59887         }
59888         else {
59889             var cooked = getCookedText(kind, rawText);
59890             if (typeof cooked === "object") {
59891                 return ts.Debug.fail("Invalid raw text");
59892             }
59893             ts.Debug.assert(text === cooked, "Expected argument 'text' to be the normalized (i.e. 'cooked') version of argument 'rawText'.");
59894             node.rawText = rawText;
59895         }
59896         return node;
59897     }
59898     function createTemplateHead(text, rawText) {
59899         var node = createTemplateLiteralLikeNode(15, text, rawText);
59900         node.text = text;
59901         return node;
59902     }
59903     ts.createTemplateHead = createTemplateHead;
59904     function createTemplateMiddle(text, rawText) {
59905         var node = createTemplateLiteralLikeNode(16, text, rawText);
59906         node.text = text;
59907         return node;
59908     }
59909     ts.createTemplateMiddle = createTemplateMiddle;
59910     function createTemplateTail(text, rawText) {
59911         var node = createTemplateLiteralLikeNode(17, text, rawText);
59912         node.text = text;
59913         return node;
59914     }
59915     ts.createTemplateTail = createTemplateTail;
59916     function createNoSubstitutionTemplateLiteral(text, rawText) {
59917         var node = createTemplateLiteralLikeNode(14, text, rawText);
59918         return node;
59919     }
59920     ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral;
59921     function createYield(asteriskTokenOrExpression, expression) {
59922         var asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 41 ? asteriskTokenOrExpression : undefined;
59923         expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 41 ? asteriskTokenOrExpression : expression;
59924         var node = createSynthesizedNode(212);
59925         node.asteriskToken = asteriskToken;
59926         node.expression = expression && ts.parenthesizeExpressionForList(expression);
59927         return node;
59928     }
59929     ts.createYield = createYield;
59930     function updateYield(node, asteriskToken, expression) {
59931         return node.expression !== expression
59932             || node.asteriskToken !== asteriskToken
59933             ? updateNode(createYield(asteriskToken, expression), node)
59934             : node;
59935     }
59936     ts.updateYield = updateYield;
59937     function createSpread(expression) {
59938         var node = createSynthesizedNode(213);
59939         node.expression = ts.parenthesizeExpressionForList(expression);
59940         return node;
59941     }
59942     ts.createSpread = createSpread;
59943     function updateSpread(node, expression) {
59944         return node.expression !== expression
59945             ? updateNode(createSpread(expression), node)
59946             : node;
59947     }
59948     ts.updateSpread = updateSpread;
59949     function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) {
59950         var node = createSynthesizedNode(214);
59951         node.decorators = undefined;
59952         node.modifiers = asNodeArray(modifiers);
59953         node.name = asName(name);
59954         node.typeParameters = asNodeArray(typeParameters);
59955         node.heritageClauses = asNodeArray(heritageClauses);
59956         node.members = createNodeArray(members);
59957         return node;
59958     }
59959     ts.createClassExpression = createClassExpression;
59960     function updateClassExpression(node, modifiers, name, typeParameters, heritageClauses, members) {
59961         return node.modifiers !== modifiers
59962             || node.name !== name
59963             || node.typeParameters !== typeParameters
59964             || node.heritageClauses !== heritageClauses
59965             || node.members !== members
59966             ? updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members), node)
59967             : node;
59968     }
59969     ts.updateClassExpression = updateClassExpression;
59970     function createOmittedExpression() {
59971         return createSynthesizedNode(215);
59972     }
59973     ts.createOmittedExpression = createOmittedExpression;
59974     function createExpressionWithTypeArguments(typeArguments, expression) {
59975         var node = createSynthesizedNode(216);
59976         node.expression = ts.parenthesizeForAccess(expression);
59977         node.typeArguments = asNodeArray(typeArguments);
59978         return node;
59979     }
59980     ts.createExpressionWithTypeArguments = createExpressionWithTypeArguments;
59981     function updateExpressionWithTypeArguments(node, typeArguments, expression) {
59982         return node.typeArguments !== typeArguments
59983             || node.expression !== expression
59984             ? updateNode(createExpressionWithTypeArguments(typeArguments, expression), node)
59985             : node;
59986     }
59987     ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments;
59988     function createAsExpression(expression, type) {
59989         var node = createSynthesizedNode(217);
59990         node.expression = expression;
59991         node.type = type;
59992         return node;
59993     }
59994     ts.createAsExpression = createAsExpression;
59995     function updateAsExpression(node, expression, type) {
59996         return node.expression !== expression
59997             || node.type !== type
59998             ? updateNode(createAsExpression(expression, type), node)
59999             : node;
60000     }
60001     ts.updateAsExpression = updateAsExpression;
60002     function createNonNullExpression(expression) {
60003         var node = createSynthesizedNode(218);
60004         node.expression = ts.parenthesizeForAccess(expression);
60005         return node;
60006     }
60007     ts.createNonNullExpression = createNonNullExpression;
60008     function updateNonNullExpression(node, expression) {
60009         if (ts.isNonNullChain(node)) {
60010             return updateNonNullChain(node, expression);
60011         }
60012         return node.expression !== expression
60013             ? updateNode(createNonNullExpression(expression), node)
60014             : node;
60015     }
60016     ts.updateNonNullExpression = updateNonNullExpression;
60017     function createNonNullChain(expression) {
60018         var node = createSynthesizedNode(218);
60019         node.flags |= 32;
60020         node.expression = ts.parenthesizeForAccess(expression);
60021         return node;
60022     }
60023     ts.createNonNullChain = createNonNullChain;
60024     function updateNonNullChain(node, expression) {
60025         ts.Debug.assert(!!(node.flags & 32), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead.");
60026         return node.expression !== expression
60027             ? updateNode(createNonNullChain(expression), node)
60028             : node;
60029     }
60030     ts.updateNonNullChain = updateNonNullChain;
60031     function createMetaProperty(keywordToken, name) {
60032         var node = createSynthesizedNode(219);
60033         node.keywordToken = keywordToken;
60034         node.name = name;
60035         return node;
60036     }
60037     ts.createMetaProperty = createMetaProperty;
60038     function updateMetaProperty(node, name) {
60039         return node.name !== name
60040             ? updateNode(createMetaProperty(node.keywordToken, name), node)
60041             : node;
60042     }
60043     ts.updateMetaProperty = updateMetaProperty;
60044     function createTemplateSpan(expression, literal) {
60045         var node = createSynthesizedNode(221);
60046         node.expression = expression;
60047         node.literal = literal;
60048         return node;
60049     }
60050     ts.createTemplateSpan = createTemplateSpan;
60051     function updateTemplateSpan(node, expression, literal) {
60052         return node.expression !== expression
60053             || node.literal !== literal
60054             ? updateNode(createTemplateSpan(expression, literal), node)
60055             : node;
60056     }
60057     ts.updateTemplateSpan = updateTemplateSpan;
60058     function createSemicolonClassElement() {
60059         return createSynthesizedNode(222);
60060     }
60061     ts.createSemicolonClassElement = createSemicolonClassElement;
60062     function createBlock(statements, multiLine) {
60063         var block = createSynthesizedNode(223);
60064         block.statements = createNodeArray(statements);
60065         if (multiLine)
60066             block.multiLine = multiLine;
60067         return block;
60068     }
60069     ts.createBlock = createBlock;
60070     function updateBlock(node, statements) {
60071         return node.statements !== statements
60072             ? updateNode(createBlock(statements, node.multiLine), node)
60073             : node;
60074     }
60075     ts.updateBlock = updateBlock;
60076     function createVariableStatement(modifiers, declarationList) {
60077         var node = createSynthesizedNode(225);
60078         node.decorators = undefined;
60079         node.modifiers = asNodeArray(modifiers);
60080         node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList;
60081         return node;
60082     }
60083     ts.createVariableStatement = createVariableStatement;
60084     function updateVariableStatement(node, modifiers, declarationList) {
60085         return node.modifiers !== modifiers
60086             || node.declarationList !== declarationList
60087             ? updateNode(createVariableStatement(modifiers, declarationList), node)
60088             : node;
60089     }
60090     ts.updateVariableStatement = updateVariableStatement;
60091     function createEmptyStatement() {
60092         return createSynthesizedNode(224);
60093     }
60094     ts.createEmptyStatement = createEmptyStatement;
60095     function createExpressionStatement(expression) {
60096         var node = createSynthesizedNode(226);
60097         node.expression = ts.parenthesizeExpressionForExpressionStatement(expression);
60098         return node;
60099     }
60100     ts.createExpressionStatement = createExpressionStatement;
60101     function updateExpressionStatement(node, expression) {
60102         return node.expression !== expression
60103             ? updateNode(createExpressionStatement(expression), node)
60104             : node;
60105     }
60106     ts.updateExpressionStatement = updateExpressionStatement;
60107     ts.createStatement = createExpressionStatement;
60108     ts.updateStatement = updateExpressionStatement;
60109     function createIf(expression, thenStatement, elseStatement) {
60110         var node = createSynthesizedNode(227);
60111         node.expression = expression;
60112         node.thenStatement = asEmbeddedStatement(thenStatement);
60113         node.elseStatement = asEmbeddedStatement(elseStatement);
60114         return node;
60115     }
60116     ts.createIf = createIf;
60117     function updateIf(node, expression, thenStatement, elseStatement) {
60118         return node.expression !== expression
60119             || node.thenStatement !== thenStatement
60120             || node.elseStatement !== elseStatement
60121             ? updateNode(createIf(expression, thenStatement, elseStatement), node)
60122             : node;
60123     }
60124     ts.updateIf = updateIf;
60125     function createDo(statement, expression) {
60126         var node = createSynthesizedNode(228);
60127         node.statement = asEmbeddedStatement(statement);
60128         node.expression = expression;
60129         return node;
60130     }
60131     ts.createDo = createDo;
60132     function updateDo(node, statement, expression) {
60133         return node.statement !== statement
60134             || node.expression !== expression
60135             ? updateNode(createDo(statement, expression), node)
60136             : node;
60137     }
60138     ts.updateDo = updateDo;
60139     function createWhile(expression, statement) {
60140         var node = createSynthesizedNode(229);
60141         node.expression = expression;
60142         node.statement = asEmbeddedStatement(statement);
60143         return node;
60144     }
60145     ts.createWhile = createWhile;
60146     function updateWhile(node, expression, statement) {
60147         return node.expression !== expression
60148             || node.statement !== statement
60149             ? updateNode(createWhile(expression, statement), node)
60150             : node;
60151     }
60152     ts.updateWhile = updateWhile;
60153     function createFor(initializer, condition, incrementor, statement) {
60154         var node = createSynthesizedNode(230);
60155         node.initializer = initializer;
60156         node.condition = condition;
60157         node.incrementor = incrementor;
60158         node.statement = asEmbeddedStatement(statement);
60159         return node;
60160     }
60161     ts.createFor = createFor;
60162     function updateFor(node, initializer, condition, incrementor, statement) {
60163         return node.initializer !== initializer
60164             || node.condition !== condition
60165             || node.incrementor !== incrementor
60166             || node.statement !== statement
60167             ? updateNode(createFor(initializer, condition, incrementor, statement), node)
60168             : node;
60169     }
60170     ts.updateFor = updateFor;
60171     function createForIn(initializer, expression, statement) {
60172         var node = createSynthesizedNode(231);
60173         node.initializer = initializer;
60174         node.expression = expression;
60175         node.statement = asEmbeddedStatement(statement);
60176         return node;
60177     }
60178     ts.createForIn = createForIn;
60179     function updateForIn(node, initializer, expression, statement) {
60180         return node.initializer !== initializer
60181             || node.expression !== expression
60182             || node.statement !== statement
60183             ? updateNode(createForIn(initializer, expression, statement), node)
60184             : node;
60185     }
60186     ts.updateForIn = updateForIn;
60187     function createForOf(awaitModifier, initializer, expression, statement) {
60188         var node = createSynthesizedNode(232);
60189         node.awaitModifier = awaitModifier;
60190         node.initializer = initializer;
60191         node.expression = ts.isCommaSequence(expression) ? createParen(expression) : expression;
60192         node.statement = asEmbeddedStatement(statement);
60193         return node;
60194     }
60195     ts.createForOf = createForOf;
60196     function updateForOf(node, awaitModifier, initializer, expression, statement) {
60197         return node.awaitModifier !== awaitModifier
60198             || node.initializer !== initializer
60199             || node.expression !== expression
60200             || node.statement !== statement
60201             ? updateNode(createForOf(awaitModifier, initializer, expression, statement), node)
60202             : node;
60203     }
60204     ts.updateForOf = updateForOf;
60205     function createContinue(label) {
60206         var node = createSynthesizedNode(233);
60207         node.label = asName(label);
60208         return node;
60209     }
60210     ts.createContinue = createContinue;
60211     function updateContinue(node, label) {
60212         return node.label !== label
60213             ? updateNode(createContinue(label), node)
60214             : node;
60215     }
60216     ts.updateContinue = updateContinue;
60217     function createBreak(label) {
60218         var node = createSynthesizedNode(234);
60219         node.label = asName(label);
60220         return node;
60221     }
60222     ts.createBreak = createBreak;
60223     function updateBreak(node, label) {
60224         return node.label !== label
60225             ? updateNode(createBreak(label), node)
60226             : node;
60227     }
60228     ts.updateBreak = updateBreak;
60229     function createReturn(expression) {
60230         var node = createSynthesizedNode(235);
60231         node.expression = expression;
60232         return node;
60233     }
60234     ts.createReturn = createReturn;
60235     function updateReturn(node, expression) {
60236         return node.expression !== expression
60237             ? updateNode(createReturn(expression), node)
60238             : node;
60239     }
60240     ts.updateReturn = updateReturn;
60241     function createWith(expression, statement) {
60242         var node = createSynthesizedNode(236);
60243         node.expression = expression;
60244         node.statement = asEmbeddedStatement(statement);
60245         return node;
60246     }
60247     ts.createWith = createWith;
60248     function updateWith(node, expression, statement) {
60249         return node.expression !== expression
60250             || node.statement !== statement
60251             ? updateNode(createWith(expression, statement), node)
60252             : node;
60253     }
60254     ts.updateWith = updateWith;
60255     function createSwitch(expression, caseBlock) {
60256         var node = createSynthesizedNode(237);
60257         node.expression = ts.parenthesizeExpressionForList(expression);
60258         node.caseBlock = caseBlock;
60259         return node;
60260     }
60261     ts.createSwitch = createSwitch;
60262     function updateSwitch(node, expression, caseBlock) {
60263         return node.expression !== expression
60264             || node.caseBlock !== caseBlock
60265             ? updateNode(createSwitch(expression, caseBlock), node)
60266             : node;
60267     }
60268     ts.updateSwitch = updateSwitch;
60269     function createLabel(label, statement) {
60270         var node = createSynthesizedNode(238);
60271         node.label = asName(label);
60272         node.statement = asEmbeddedStatement(statement);
60273         return node;
60274     }
60275     ts.createLabel = createLabel;
60276     function updateLabel(node, label, statement) {
60277         return node.label !== label
60278             || node.statement !== statement
60279             ? updateNode(createLabel(label, statement), node)
60280             : node;
60281     }
60282     ts.updateLabel = updateLabel;
60283     function createThrow(expression) {
60284         var node = createSynthesizedNode(239);
60285         node.expression = expression;
60286         return node;
60287     }
60288     ts.createThrow = createThrow;
60289     function updateThrow(node, expression) {
60290         return node.expression !== expression
60291             ? updateNode(createThrow(expression), node)
60292             : node;
60293     }
60294     ts.updateThrow = updateThrow;
60295     function createTry(tryBlock, catchClause, finallyBlock) {
60296         var node = createSynthesizedNode(240);
60297         node.tryBlock = tryBlock;
60298         node.catchClause = catchClause;
60299         node.finallyBlock = finallyBlock;
60300         return node;
60301     }
60302     ts.createTry = createTry;
60303     function updateTry(node, tryBlock, catchClause, finallyBlock) {
60304         return node.tryBlock !== tryBlock
60305             || node.catchClause !== catchClause
60306             || node.finallyBlock !== finallyBlock
60307             ? updateNode(createTry(tryBlock, catchClause, finallyBlock), node)
60308             : node;
60309     }
60310     ts.updateTry = updateTry;
60311     function createDebuggerStatement() {
60312         return createSynthesizedNode(241);
60313     }
60314     ts.createDebuggerStatement = createDebuggerStatement;
60315     function createVariableDeclaration(name, type, initializer) {
60316         var node = createSynthesizedNode(242);
60317         node.name = asName(name);
60318         node.type = type;
60319         node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined;
60320         return node;
60321     }
60322     ts.createVariableDeclaration = createVariableDeclaration;
60323     function updateVariableDeclaration(node, name, type, initializer) {
60324         return node.name !== name
60325             || node.type !== type
60326             || node.initializer !== initializer
60327             ? updateNode(createVariableDeclaration(name, type, initializer), node)
60328             : node;
60329     }
60330     ts.updateVariableDeclaration = updateVariableDeclaration;
60331     function createTypeScriptVariableDeclaration(name, exclaimationToken, type, initializer) {
60332         var node = createSynthesizedNode(242);
60333         node.name = asName(name);
60334         node.type = type;
60335         node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined;
60336         node.exclamationToken = exclaimationToken;
60337         return node;
60338     }
60339     ts.createTypeScriptVariableDeclaration = createTypeScriptVariableDeclaration;
60340     function updateTypeScriptVariableDeclaration(node, name, exclaimationToken, type, initializer) {
60341         return node.name !== name
60342             || node.type !== type
60343             || node.initializer !== initializer
60344             || node.exclamationToken !== exclaimationToken
60345             ? updateNode(createTypeScriptVariableDeclaration(name, exclaimationToken, type, initializer), node)
60346             : node;
60347     }
60348     ts.updateTypeScriptVariableDeclaration = updateTypeScriptVariableDeclaration;
60349     function createVariableDeclarationList(declarations, flags) {
60350         if (flags === void 0) { flags = 0; }
60351         var node = createSynthesizedNode(243);
60352         node.flags |= flags & 3;
60353         node.declarations = createNodeArray(declarations);
60354         return node;
60355     }
60356     ts.createVariableDeclarationList = createVariableDeclarationList;
60357     function updateVariableDeclarationList(node, declarations) {
60358         return node.declarations !== declarations
60359             ? updateNode(createVariableDeclarationList(declarations, node.flags), node)
60360             : node;
60361     }
60362     ts.updateVariableDeclarationList = updateVariableDeclarationList;
60363     function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
60364         var node = createSynthesizedNode(244);
60365         node.decorators = asNodeArray(decorators);
60366         node.modifiers = asNodeArray(modifiers);
60367         node.asteriskToken = asteriskToken;
60368         node.name = asName(name);
60369         node.typeParameters = asNodeArray(typeParameters);
60370         node.parameters = createNodeArray(parameters);
60371         node.type = type;
60372         node.body = body;
60373         return node;
60374     }
60375     ts.createFunctionDeclaration = createFunctionDeclaration;
60376     function updateFunctionDeclaration(node, decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
60377         return node.decorators !== decorators
60378             || node.modifiers !== modifiers
60379             || node.asteriskToken !== asteriskToken
60380             || node.name !== name
60381             || node.typeParameters !== typeParameters
60382             || node.parameters !== parameters
60383             || node.type !== type
60384             || node.body !== body
60385             ? updateNode(createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body), node)
60386             : node;
60387     }
60388     ts.updateFunctionDeclaration = updateFunctionDeclaration;
60389     function updateFunctionLikeBody(declaration, body) {
60390         switch (declaration.kind) {
60391             case 244:
60392                 return createFunctionDeclaration(declaration.decorators, declaration.modifiers, declaration.asteriskToken, declaration.name, declaration.typeParameters, declaration.parameters, declaration.type, body);
60393             case 161:
60394                 return createMethod(declaration.decorators, declaration.modifiers, declaration.asteriskToken, declaration.name, declaration.questionToken, declaration.typeParameters, declaration.parameters, declaration.type, body);
60395             case 163:
60396                 return createGetAccessor(declaration.decorators, declaration.modifiers, declaration.name, declaration.parameters, declaration.type, body);
60397             case 164:
60398                 return createSetAccessor(declaration.decorators, declaration.modifiers, declaration.name, declaration.parameters, body);
60399             case 162:
60400                 return createConstructor(declaration.decorators, declaration.modifiers, declaration.parameters, body);
60401             case 201:
60402                 return createFunctionExpression(declaration.modifiers, declaration.asteriskToken, declaration.name, declaration.typeParameters, declaration.parameters, declaration.type, body);
60403             case 202:
60404                 return createArrowFunction(declaration.modifiers, declaration.typeParameters, declaration.parameters, declaration.type, declaration.equalsGreaterThanToken, body);
60405         }
60406     }
60407     ts.updateFunctionLikeBody = updateFunctionLikeBody;
60408     function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) {
60409         var node = createSynthesizedNode(245);
60410         node.decorators = asNodeArray(decorators);
60411         node.modifiers = asNodeArray(modifiers);
60412         node.name = asName(name);
60413         node.typeParameters = asNodeArray(typeParameters);
60414         node.heritageClauses = asNodeArray(heritageClauses);
60415         node.members = createNodeArray(members);
60416         return node;
60417     }
60418     ts.createClassDeclaration = createClassDeclaration;
60419     function updateClassDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) {
60420         return node.decorators !== decorators
60421             || node.modifiers !== modifiers
60422             || node.name !== name
60423             || node.typeParameters !== typeParameters
60424             || node.heritageClauses !== heritageClauses
60425             || node.members !== members
60426             ? updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node)
60427             : node;
60428     }
60429     ts.updateClassDeclaration = updateClassDeclaration;
60430     function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) {
60431         var node = createSynthesizedNode(246);
60432         node.decorators = asNodeArray(decorators);
60433         node.modifiers = asNodeArray(modifiers);
60434         node.name = asName(name);
60435         node.typeParameters = asNodeArray(typeParameters);
60436         node.heritageClauses = asNodeArray(heritageClauses);
60437         node.members = createNodeArray(members);
60438         return node;
60439     }
60440     ts.createInterfaceDeclaration = createInterfaceDeclaration;
60441     function updateInterfaceDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) {
60442         return node.decorators !== decorators
60443             || node.modifiers !== modifiers
60444             || node.name !== name
60445             || node.typeParameters !== typeParameters
60446             || node.heritageClauses !== heritageClauses
60447             || node.members !== members
60448             ? updateNode(createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node)
60449             : node;
60450     }
60451     ts.updateInterfaceDeclaration = updateInterfaceDeclaration;
60452     function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) {
60453         var node = createSynthesizedNode(247);
60454         node.decorators = asNodeArray(decorators);
60455         node.modifiers = asNodeArray(modifiers);
60456         node.name = asName(name);
60457         node.typeParameters = asNodeArray(typeParameters);
60458         node.type = type;
60459         return node;
60460     }
60461     ts.createTypeAliasDeclaration = createTypeAliasDeclaration;
60462     function updateTypeAliasDeclaration(node, decorators, modifiers, name, typeParameters, type) {
60463         return node.decorators !== decorators
60464             || node.modifiers !== modifiers
60465             || node.name !== name
60466             || node.typeParameters !== typeParameters
60467             || node.type !== type
60468             ? updateNode(createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type), node)
60469             : node;
60470     }
60471     ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration;
60472     function createEnumDeclaration(decorators, modifiers, name, members) {
60473         var node = createSynthesizedNode(248);
60474         node.decorators = asNodeArray(decorators);
60475         node.modifiers = asNodeArray(modifiers);
60476         node.name = asName(name);
60477         node.members = createNodeArray(members);
60478         return node;
60479     }
60480     ts.createEnumDeclaration = createEnumDeclaration;
60481     function updateEnumDeclaration(node, decorators, modifiers, name, members) {
60482         return node.decorators !== decorators
60483             || node.modifiers !== modifiers
60484             || node.name !== name
60485             || node.members !== members
60486             ? updateNode(createEnumDeclaration(decorators, modifiers, name, members), node)
60487             : node;
60488     }
60489     ts.updateEnumDeclaration = updateEnumDeclaration;
60490     function createModuleDeclaration(decorators, modifiers, name, body, flags) {
60491         if (flags === void 0) { flags = 0; }
60492         var node = createSynthesizedNode(249);
60493         node.flags |= flags & (16 | 4 | 1024);
60494         node.decorators = asNodeArray(decorators);
60495         node.modifiers = asNodeArray(modifiers);
60496         node.name = name;
60497         node.body = body;
60498         return node;
60499     }
60500     ts.createModuleDeclaration = createModuleDeclaration;
60501     function updateModuleDeclaration(node, decorators, modifiers, name, body) {
60502         return node.decorators !== decorators
60503             || node.modifiers !== modifiers
60504             || node.name !== name
60505             || node.body !== body
60506             ? updateNode(createModuleDeclaration(decorators, modifiers, name, body, node.flags), node)
60507             : node;
60508     }
60509     ts.updateModuleDeclaration = updateModuleDeclaration;
60510     function createModuleBlock(statements) {
60511         var node = createSynthesizedNode(250);
60512         node.statements = createNodeArray(statements);
60513         return node;
60514     }
60515     ts.createModuleBlock = createModuleBlock;
60516     function updateModuleBlock(node, statements) {
60517         return node.statements !== statements
60518             ? updateNode(createModuleBlock(statements), node)
60519             : node;
60520     }
60521     ts.updateModuleBlock = updateModuleBlock;
60522     function createCaseBlock(clauses) {
60523         var node = createSynthesizedNode(251);
60524         node.clauses = createNodeArray(clauses);
60525         return node;
60526     }
60527     ts.createCaseBlock = createCaseBlock;
60528     function updateCaseBlock(node, clauses) {
60529         return node.clauses !== clauses
60530             ? updateNode(createCaseBlock(clauses), node)
60531             : node;
60532     }
60533     ts.updateCaseBlock = updateCaseBlock;
60534     function createNamespaceExportDeclaration(name) {
60535         var node = createSynthesizedNode(252);
60536         node.name = asName(name);
60537         return node;
60538     }
60539     ts.createNamespaceExportDeclaration = createNamespaceExportDeclaration;
60540     function updateNamespaceExportDeclaration(node, name) {
60541         return node.name !== name
60542             ? updateNode(createNamespaceExportDeclaration(name), node)
60543             : node;
60544     }
60545     ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration;
60546     function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) {
60547         var node = createSynthesizedNode(253);
60548         node.decorators = asNodeArray(decorators);
60549         node.modifiers = asNodeArray(modifiers);
60550         node.name = asName(name);
60551         node.moduleReference = moduleReference;
60552         return node;
60553     }
60554     ts.createImportEqualsDeclaration = createImportEqualsDeclaration;
60555     function updateImportEqualsDeclaration(node, decorators, modifiers, name, moduleReference) {
60556         return node.decorators !== decorators
60557             || node.modifiers !== modifiers
60558             || node.name !== name
60559             || node.moduleReference !== moduleReference
60560             ? updateNode(createImportEqualsDeclaration(decorators, modifiers, name, moduleReference), node)
60561             : node;
60562     }
60563     ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration;
60564     function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) {
60565         var node = createSynthesizedNode(254);
60566         node.decorators = asNodeArray(decorators);
60567         node.modifiers = asNodeArray(modifiers);
60568         node.importClause = importClause;
60569         node.moduleSpecifier = moduleSpecifier;
60570         return node;
60571     }
60572     ts.createImportDeclaration = createImportDeclaration;
60573     function updateImportDeclaration(node, decorators, modifiers, importClause, moduleSpecifier) {
60574         return node.decorators !== decorators
60575             || node.modifiers !== modifiers
60576             || node.importClause !== importClause
60577             || node.moduleSpecifier !== moduleSpecifier
60578             ? updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier), node)
60579             : node;
60580     }
60581     ts.updateImportDeclaration = updateImportDeclaration;
60582     function createImportClause(name, namedBindings, isTypeOnly) {
60583         if (isTypeOnly === void 0) { isTypeOnly = false; }
60584         var node = createSynthesizedNode(255);
60585         node.name = name;
60586         node.namedBindings = namedBindings;
60587         node.isTypeOnly = isTypeOnly;
60588         return node;
60589     }
60590     ts.createImportClause = createImportClause;
60591     function updateImportClause(node, name, namedBindings, isTypeOnly) {
60592         return node.name !== name
60593             || node.namedBindings !== namedBindings
60594             || node.isTypeOnly !== isTypeOnly
60595             ? updateNode(createImportClause(name, namedBindings, isTypeOnly), node)
60596             : node;
60597     }
60598     ts.updateImportClause = updateImportClause;
60599     function createNamespaceImport(name) {
60600         var node = createSynthesizedNode(256);
60601         node.name = name;
60602         return node;
60603     }
60604     ts.createNamespaceImport = createNamespaceImport;
60605     function createNamespaceExport(name) {
60606         var node = createSynthesizedNode(262);
60607         node.name = name;
60608         return node;
60609     }
60610     ts.createNamespaceExport = createNamespaceExport;
60611     function updateNamespaceImport(node, name) {
60612         return node.name !== name
60613             ? updateNode(createNamespaceImport(name), node)
60614             : node;
60615     }
60616     ts.updateNamespaceImport = updateNamespaceImport;
60617     function updateNamespaceExport(node, name) {
60618         return node.name !== name
60619             ? updateNode(createNamespaceExport(name), node)
60620             : node;
60621     }
60622     ts.updateNamespaceExport = updateNamespaceExport;
60623     function createNamedImports(elements) {
60624         var node = createSynthesizedNode(257);
60625         node.elements = createNodeArray(elements);
60626         return node;
60627     }
60628     ts.createNamedImports = createNamedImports;
60629     function updateNamedImports(node, elements) {
60630         return node.elements !== elements
60631             ? updateNode(createNamedImports(elements), node)
60632             : node;
60633     }
60634     ts.updateNamedImports = updateNamedImports;
60635     function createImportSpecifier(propertyName, name) {
60636         var node = createSynthesizedNode(258);
60637         node.propertyName = propertyName;
60638         node.name = name;
60639         return node;
60640     }
60641     ts.createImportSpecifier = createImportSpecifier;
60642     function updateImportSpecifier(node, propertyName, name) {
60643         return node.propertyName !== propertyName
60644             || node.name !== name
60645             ? updateNode(createImportSpecifier(propertyName, name), node)
60646             : node;
60647     }
60648     ts.updateImportSpecifier = updateImportSpecifier;
60649     function createExportAssignment(decorators, modifiers, isExportEquals, expression) {
60650         var node = createSynthesizedNode(259);
60651         node.decorators = asNodeArray(decorators);
60652         node.modifiers = asNodeArray(modifiers);
60653         node.isExportEquals = isExportEquals;
60654         node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(62, expression, false, undefined) : ts.parenthesizeDefaultExpression(expression);
60655         return node;
60656     }
60657     ts.createExportAssignment = createExportAssignment;
60658     function updateExportAssignment(node, decorators, modifiers, expression) {
60659         return node.decorators !== decorators
60660             || node.modifiers !== modifiers
60661             || node.expression !== expression
60662             ? updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression), node)
60663             : node;
60664     }
60665     ts.updateExportAssignment = updateExportAssignment;
60666     function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, isTypeOnly) {
60667         if (isTypeOnly === void 0) { isTypeOnly = false; }
60668         var node = createSynthesizedNode(260);
60669         node.decorators = asNodeArray(decorators);
60670         node.modifiers = asNodeArray(modifiers);
60671         node.isTypeOnly = isTypeOnly;
60672         node.exportClause = exportClause;
60673         node.moduleSpecifier = moduleSpecifier;
60674         return node;
60675     }
60676     ts.createExportDeclaration = createExportDeclaration;
60677     function updateExportDeclaration(node, decorators, modifiers, exportClause, moduleSpecifier, isTypeOnly) {
60678         return node.decorators !== decorators
60679             || node.modifiers !== modifiers
60680             || node.isTypeOnly !== isTypeOnly
60681             || node.exportClause !== exportClause
60682             || node.moduleSpecifier !== moduleSpecifier
60683             ? updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, isTypeOnly), node)
60684             : node;
60685     }
60686     ts.updateExportDeclaration = updateExportDeclaration;
60687     function createEmptyExports() {
60688         return createExportDeclaration(undefined, undefined, createNamedExports([]), undefined);
60689     }
60690     ts.createEmptyExports = createEmptyExports;
60691     function createNamedExports(elements) {
60692         var node = createSynthesizedNode(261);
60693         node.elements = createNodeArray(elements);
60694         return node;
60695     }
60696     ts.createNamedExports = createNamedExports;
60697     function updateNamedExports(node, elements) {
60698         return node.elements !== elements
60699             ? updateNode(createNamedExports(elements), node)
60700             : node;
60701     }
60702     ts.updateNamedExports = updateNamedExports;
60703     function createExportSpecifier(propertyName, name) {
60704         var node = createSynthesizedNode(263);
60705         node.propertyName = asName(propertyName);
60706         node.name = asName(name);
60707         return node;
60708     }
60709     ts.createExportSpecifier = createExportSpecifier;
60710     function updateExportSpecifier(node, propertyName, name) {
60711         return node.propertyName !== propertyName
60712             || node.name !== name
60713             ? updateNode(createExportSpecifier(propertyName, name), node)
60714             : node;
60715     }
60716     ts.updateExportSpecifier = updateExportSpecifier;
60717     function createExternalModuleReference(expression) {
60718         var node = createSynthesizedNode(265);
60719         node.expression = expression;
60720         return node;
60721     }
60722     ts.createExternalModuleReference = createExternalModuleReference;
60723     function updateExternalModuleReference(node, expression) {
60724         return node.expression !== expression
60725             ? updateNode(createExternalModuleReference(expression), node)
60726             : node;
60727     }
60728     ts.updateExternalModuleReference = updateExternalModuleReference;
60729     function createJSDocTypeExpression(type) {
60730         var node = createSynthesizedNode(294);
60731         node.type = type;
60732         return node;
60733     }
60734     ts.createJSDocTypeExpression = createJSDocTypeExpression;
60735     function createJSDocTypeTag(typeExpression, comment) {
60736         var tag = createJSDocTag(320, "type");
60737         tag.typeExpression = typeExpression;
60738         tag.comment = comment;
60739         return tag;
60740     }
60741     ts.createJSDocTypeTag = createJSDocTypeTag;
60742     function createJSDocReturnTag(typeExpression, comment) {
60743         var tag = createJSDocTag(318, "returns");
60744         tag.typeExpression = typeExpression;
60745         tag.comment = comment;
60746         return tag;
60747     }
60748     ts.createJSDocReturnTag = createJSDocReturnTag;
60749     function createJSDocThisTag(typeExpression) {
60750         var tag = createJSDocTag(319, "this");
60751         tag.typeExpression = typeExpression;
60752         return tag;
60753     }
60754     ts.createJSDocThisTag = createJSDocThisTag;
60755     function createJSDocParamTag(name, isBracketed, typeExpression, comment) {
60756         var tag = createJSDocTag(317, "param");
60757         tag.typeExpression = typeExpression;
60758         tag.name = name;
60759         tag.isBracketed = isBracketed;
60760         tag.comment = comment;
60761         return tag;
60762     }
60763     ts.createJSDocParamTag = createJSDocParamTag;
60764     function createJSDocClassTag() {
60765         return createJSDocTag(310, "class");
60766     }
60767     ts.createJSDocClassTag = createJSDocClassTag;
60768     function createJSDocComment(comment, tags) {
60769         var node = createSynthesizedNode(303);
60770         node.comment = comment;
60771         node.tags = tags;
60772         return node;
60773     }
60774     ts.createJSDocComment = createJSDocComment;
60775     function createJSDocTag(kind, tagName) {
60776         var node = createSynthesizedNode(kind);
60777         node.tagName = createIdentifier(tagName);
60778         return node;
60779     }
60780     function createJsxElement(openingElement, children, closingElement) {
60781         var node = createSynthesizedNode(266);
60782         node.openingElement = openingElement;
60783         node.children = createNodeArray(children);
60784         node.closingElement = closingElement;
60785         return node;
60786     }
60787     ts.createJsxElement = createJsxElement;
60788     function updateJsxElement(node, openingElement, children, closingElement) {
60789         return node.openingElement !== openingElement
60790             || node.children !== children
60791             || node.closingElement !== closingElement
60792             ? updateNode(createJsxElement(openingElement, children, closingElement), node)
60793             : node;
60794     }
60795     ts.updateJsxElement = updateJsxElement;
60796     function createJsxSelfClosingElement(tagName, typeArguments, attributes) {
60797         var node = createSynthesizedNode(267);
60798         node.tagName = tagName;
60799         node.typeArguments = asNodeArray(typeArguments);
60800         node.attributes = attributes;
60801         return node;
60802     }
60803     ts.createJsxSelfClosingElement = createJsxSelfClosingElement;
60804     function updateJsxSelfClosingElement(node, tagName, typeArguments, attributes) {
60805         return node.tagName !== tagName
60806             || node.typeArguments !== typeArguments
60807             || node.attributes !== attributes
60808             ? updateNode(createJsxSelfClosingElement(tagName, typeArguments, attributes), node)
60809             : node;
60810     }
60811     ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement;
60812     function createJsxOpeningElement(tagName, typeArguments, attributes) {
60813         var node = createSynthesizedNode(268);
60814         node.tagName = tagName;
60815         node.typeArguments = asNodeArray(typeArguments);
60816         node.attributes = attributes;
60817         return node;
60818     }
60819     ts.createJsxOpeningElement = createJsxOpeningElement;
60820     function updateJsxOpeningElement(node, tagName, typeArguments, attributes) {
60821         return node.tagName !== tagName
60822             || node.typeArguments !== typeArguments
60823             || node.attributes !== attributes
60824             ? updateNode(createJsxOpeningElement(tagName, typeArguments, attributes), node)
60825             : node;
60826     }
60827     ts.updateJsxOpeningElement = updateJsxOpeningElement;
60828     function createJsxClosingElement(tagName) {
60829         var node = createSynthesizedNode(269);
60830         node.tagName = tagName;
60831         return node;
60832     }
60833     ts.createJsxClosingElement = createJsxClosingElement;
60834     function updateJsxClosingElement(node, tagName) {
60835         return node.tagName !== tagName
60836             ? updateNode(createJsxClosingElement(tagName), node)
60837             : node;
60838     }
60839     ts.updateJsxClosingElement = updateJsxClosingElement;
60840     function createJsxFragment(openingFragment, children, closingFragment) {
60841         var node = createSynthesizedNode(270);
60842         node.openingFragment = openingFragment;
60843         node.children = createNodeArray(children);
60844         node.closingFragment = closingFragment;
60845         return node;
60846     }
60847     ts.createJsxFragment = createJsxFragment;
60848     function createJsxText(text, containsOnlyTriviaWhiteSpaces) {
60849         var node = createSynthesizedNode(11);
60850         node.text = text;
60851         node.containsOnlyTriviaWhiteSpaces = !!containsOnlyTriviaWhiteSpaces;
60852         return node;
60853     }
60854     ts.createJsxText = createJsxText;
60855     function updateJsxText(node, text, containsOnlyTriviaWhiteSpaces) {
60856         return node.text !== text
60857             || node.containsOnlyTriviaWhiteSpaces !== containsOnlyTriviaWhiteSpaces
60858             ? updateNode(createJsxText(text, containsOnlyTriviaWhiteSpaces), node)
60859             : node;
60860     }
60861     ts.updateJsxText = updateJsxText;
60862     function createJsxOpeningFragment() {
60863         return createSynthesizedNode(271);
60864     }
60865     ts.createJsxOpeningFragment = createJsxOpeningFragment;
60866     function createJsxJsxClosingFragment() {
60867         return createSynthesizedNode(272);
60868     }
60869     ts.createJsxJsxClosingFragment = createJsxJsxClosingFragment;
60870     function updateJsxFragment(node, openingFragment, children, closingFragment) {
60871         return node.openingFragment !== openingFragment
60872             || node.children !== children
60873             || node.closingFragment !== closingFragment
60874             ? updateNode(createJsxFragment(openingFragment, children, closingFragment), node)
60875             : node;
60876     }
60877     ts.updateJsxFragment = updateJsxFragment;
60878     function createJsxAttribute(name, initializer) {
60879         var node = createSynthesizedNode(273);
60880         node.name = name;
60881         node.initializer = initializer;
60882         return node;
60883     }
60884     ts.createJsxAttribute = createJsxAttribute;
60885     function updateJsxAttribute(node, name, initializer) {
60886         return node.name !== name
60887             || node.initializer !== initializer
60888             ? updateNode(createJsxAttribute(name, initializer), node)
60889             : node;
60890     }
60891     ts.updateJsxAttribute = updateJsxAttribute;
60892     function createJsxAttributes(properties) {
60893         var node = createSynthesizedNode(274);
60894         node.properties = createNodeArray(properties);
60895         return node;
60896     }
60897     ts.createJsxAttributes = createJsxAttributes;
60898     function updateJsxAttributes(node, properties) {
60899         return node.properties !== properties
60900             ? updateNode(createJsxAttributes(properties), node)
60901             : node;
60902     }
60903     ts.updateJsxAttributes = updateJsxAttributes;
60904     function createJsxSpreadAttribute(expression) {
60905         var node = createSynthesizedNode(275);
60906         node.expression = expression;
60907         return node;
60908     }
60909     ts.createJsxSpreadAttribute = createJsxSpreadAttribute;
60910     function updateJsxSpreadAttribute(node, expression) {
60911         return node.expression !== expression
60912             ? updateNode(createJsxSpreadAttribute(expression), node)
60913             : node;
60914     }
60915     ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute;
60916     function createJsxExpression(dotDotDotToken, expression) {
60917         var node = createSynthesizedNode(276);
60918         node.dotDotDotToken = dotDotDotToken;
60919         node.expression = expression;
60920         return node;
60921     }
60922     ts.createJsxExpression = createJsxExpression;
60923     function updateJsxExpression(node, expression) {
60924         return node.expression !== expression
60925             ? updateNode(createJsxExpression(node.dotDotDotToken, expression), node)
60926             : node;
60927     }
60928     ts.updateJsxExpression = updateJsxExpression;
60929     function createCaseClause(expression, statements) {
60930         var node = createSynthesizedNode(277);
60931         node.expression = ts.parenthesizeExpressionForList(expression);
60932         node.statements = createNodeArray(statements);
60933         return node;
60934     }
60935     ts.createCaseClause = createCaseClause;
60936     function updateCaseClause(node, expression, statements) {
60937         return node.expression !== expression
60938             || node.statements !== statements
60939             ? updateNode(createCaseClause(expression, statements), node)
60940             : node;
60941     }
60942     ts.updateCaseClause = updateCaseClause;
60943     function createDefaultClause(statements) {
60944         var node = createSynthesizedNode(278);
60945         node.statements = createNodeArray(statements);
60946         return node;
60947     }
60948     ts.createDefaultClause = createDefaultClause;
60949     function updateDefaultClause(node, statements) {
60950         return node.statements !== statements
60951             ? updateNode(createDefaultClause(statements), node)
60952             : node;
60953     }
60954     ts.updateDefaultClause = updateDefaultClause;
60955     function createHeritageClause(token, types) {
60956         var node = createSynthesizedNode(279);
60957         node.token = token;
60958         node.types = createNodeArray(types);
60959         return node;
60960     }
60961     ts.createHeritageClause = createHeritageClause;
60962     function updateHeritageClause(node, types) {
60963         return node.types !== types
60964             ? updateNode(createHeritageClause(node.token, types), node)
60965             : node;
60966     }
60967     ts.updateHeritageClause = updateHeritageClause;
60968     function createCatchClause(variableDeclaration, block) {
60969         var node = createSynthesizedNode(280);
60970         node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration;
60971         node.block = block;
60972         return node;
60973     }
60974     ts.createCatchClause = createCatchClause;
60975     function updateCatchClause(node, variableDeclaration, block) {
60976         return node.variableDeclaration !== variableDeclaration
60977             || node.block !== block
60978             ? updateNode(createCatchClause(variableDeclaration, block), node)
60979             : node;
60980     }
60981     ts.updateCatchClause = updateCatchClause;
60982     function createPropertyAssignment(name, initializer) {
60983         var node = createSynthesizedNode(281);
60984         node.name = asName(name);
60985         node.questionToken = undefined;
60986         node.initializer = ts.parenthesizeExpressionForList(initializer);
60987         return node;
60988     }
60989     ts.createPropertyAssignment = createPropertyAssignment;
60990     function updatePropertyAssignment(node, name, initializer) {
60991         return node.name !== name
60992             || node.initializer !== initializer
60993             ? updateNode(createPropertyAssignment(name, initializer), node)
60994             : node;
60995     }
60996     ts.updatePropertyAssignment = updatePropertyAssignment;
60997     function createShorthandPropertyAssignment(name, objectAssignmentInitializer) {
60998         var node = createSynthesizedNode(282);
60999         node.name = asName(name);
61000         node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined;
61001         return node;
61002     }
61003     ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment;
61004     function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) {
61005         return node.name !== name
61006             || node.objectAssignmentInitializer !== objectAssignmentInitializer
61007             ? updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node)
61008             : node;
61009     }
61010     ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment;
61011     function createSpreadAssignment(expression) {
61012         var node = createSynthesizedNode(283);
61013         node.expression = ts.parenthesizeExpressionForList(expression);
61014         return node;
61015     }
61016     ts.createSpreadAssignment = createSpreadAssignment;
61017     function updateSpreadAssignment(node, expression) {
61018         return node.expression !== expression
61019             ? updateNode(createSpreadAssignment(expression), node)
61020             : node;
61021     }
61022     ts.updateSpreadAssignment = updateSpreadAssignment;
61023     function createEnumMember(name, initializer) {
61024         var node = createSynthesizedNode(284);
61025         node.name = asName(name);
61026         node.initializer = initializer && ts.parenthesizeExpressionForList(initializer);
61027         return node;
61028     }
61029     ts.createEnumMember = createEnumMember;
61030     function updateEnumMember(node, name, initializer) {
61031         return node.name !== name
61032             || node.initializer !== initializer
61033             ? updateNode(createEnumMember(name, initializer), node)
61034             : node;
61035     }
61036     ts.updateEnumMember = updateEnumMember;
61037     function updateSourceFileNode(node, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) {
61038         if (node.statements !== statements ||
61039             (isDeclarationFile !== undefined && node.isDeclarationFile !== isDeclarationFile) ||
61040             (referencedFiles !== undefined && node.referencedFiles !== referencedFiles) ||
61041             (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) ||
61042             (libReferences !== undefined && node.libReferenceDirectives !== libReferences) ||
61043             (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) {
61044             var updated = createSynthesizedNode(290);
61045             updated.flags |= node.flags;
61046             updated.statements = createNodeArray(statements);
61047             updated.endOfFileToken = node.endOfFileToken;
61048             updated.fileName = node.fileName;
61049             updated.path = node.path;
61050             updated.text = node.text;
61051             updated.isDeclarationFile = isDeclarationFile === undefined ? node.isDeclarationFile : isDeclarationFile;
61052             updated.referencedFiles = referencedFiles === undefined ? node.referencedFiles : referencedFiles;
61053             updated.typeReferenceDirectives = typeReferences === undefined ? node.typeReferenceDirectives : typeReferences;
61054             updated.hasNoDefaultLib = hasNoDefaultLib === undefined ? node.hasNoDefaultLib : hasNoDefaultLib;
61055             updated.libReferenceDirectives = libReferences === undefined ? node.libReferenceDirectives : libReferences;
61056             if (node.amdDependencies !== undefined)
61057                 updated.amdDependencies = node.amdDependencies;
61058             if (node.moduleName !== undefined)
61059                 updated.moduleName = node.moduleName;
61060             if (node.languageVariant !== undefined)
61061                 updated.languageVariant = node.languageVariant;
61062             if (node.renamedDependencies !== undefined)
61063                 updated.renamedDependencies = node.renamedDependencies;
61064             if (node.languageVersion !== undefined)
61065                 updated.languageVersion = node.languageVersion;
61066             if (node.scriptKind !== undefined)
61067                 updated.scriptKind = node.scriptKind;
61068             if (node.externalModuleIndicator !== undefined)
61069                 updated.externalModuleIndicator = node.externalModuleIndicator;
61070             if (node.commonJsModuleIndicator !== undefined)
61071                 updated.commonJsModuleIndicator = node.commonJsModuleIndicator;
61072             if (node.identifiers !== undefined)
61073                 updated.identifiers = node.identifiers;
61074             if (node.nodeCount !== undefined)
61075                 updated.nodeCount = node.nodeCount;
61076             if (node.identifierCount !== undefined)
61077                 updated.identifierCount = node.identifierCount;
61078             if (node.symbolCount !== undefined)
61079                 updated.symbolCount = node.symbolCount;
61080             if (node.parseDiagnostics !== undefined)
61081                 updated.parseDiagnostics = node.parseDiagnostics;
61082             if (node.bindDiagnostics !== undefined)
61083                 updated.bindDiagnostics = node.bindDiagnostics;
61084             if (node.bindSuggestionDiagnostics !== undefined)
61085                 updated.bindSuggestionDiagnostics = node.bindSuggestionDiagnostics;
61086             if (node.lineMap !== undefined)
61087                 updated.lineMap = node.lineMap;
61088             if (node.classifiableNames !== undefined)
61089                 updated.classifiableNames = node.classifiableNames;
61090             if (node.resolvedModules !== undefined)
61091                 updated.resolvedModules = node.resolvedModules;
61092             if (node.resolvedTypeReferenceDirectiveNames !== undefined)
61093                 updated.resolvedTypeReferenceDirectiveNames = node.resolvedTypeReferenceDirectiveNames;
61094             if (node.imports !== undefined)
61095                 updated.imports = node.imports;
61096             if (node.moduleAugmentations !== undefined)
61097                 updated.moduleAugmentations = node.moduleAugmentations;
61098             if (node.pragmas !== undefined)
61099                 updated.pragmas = node.pragmas;
61100             if (node.localJsxFactory !== undefined)
61101                 updated.localJsxFactory = node.localJsxFactory;
61102             if (node.localJsxNamespace !== undefined)
61103                 updated.localJsxNamespace = node.localJsxNamespace;
61104             return updateNode(updated, node);
61105         }
61106         return node;
61107     }
61108     ts.updateSourceFileNode = updateSourceFileNode;
61109     function getMutableClone(node) {
61110         var clone = getSynthesizedClone(node);
61111         clone.pos = node.pos;
61112         clone.end = node.end;
61113         clone.parent = node.parent;
61114         return clone;
61115     }
61116     ts.getMutableClone = getMutableClone;
61117     function createNotEmittedStatement(original) {
61118         var node = createSynthesizedNode(325);
61119         node.original = original;
61120         setTextRange(node, original);
61121         return node;
61122     }
61123     ts.createNotEmittedStatement = createNotEmittedStatement;
61124     function createEndOfDeclarationMarker(original) {
61125         var node = createSynthesizedNode(329);
61126         node.emitNode = {};
61127         node.original = original;
61128         return node;
61129     }
61130     ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker;
61131     function createMergeDeclarationMarker(original) {
61132         var node = createSynthesizedNode(328);
61133         node.emitNode = {};
61134         node.original = original;
61135         return node;
61136     }
61137     ts.createMergeDeclarationMarker = createMergeDeclarationMarker;
61138     function createPartiallyEmittedExpression(expression, original) {
61139         var node = createSynthesizedNode(326);
61140         node.expression = expression;
61141         node.original = original;
61142         setTextRange(node, original);
61143         return node;
61144     }
61145     ts.createPartiallyEmittedExpression = createPartiallyEmittedExpression;
61146     function updatePartiallyEmittedExpression(node, expression) {
61147         if (node.expression !== expression) {
61148             return updateNode(createPartiallyEmittedExpression(expression, node.original), node);
61149         }
61150         return node;
61151     }
61152     ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression;
61153     function flattenCommaElements(node) {
61154         if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) {
61155             if (node.kind === 327) {
61156                 return node.elements;
61157             }
61158             if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27) {
61159                 return [node.left, node.right];
61160             }
61161         }
61162         return node;
61163     }
61164     function createCommaList(elements) {
61165         var node = createSynthesizedNode(327);
61166         node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements));
61167         return node;
61168     }
61169     ts.createCommaList = createCommaList;
61170     function updateCommaList(node, elements) {
61171         return node.elements !== elements
61172             ? updateNode(createCommaList(elements), node)
61173             : node;
61174     }
61175     ts.updateCommaList = updateCommaList;
61176     function createSyntheticReferenceExpression(expression, thisArg) {
61177         var node = createSynthesizedNode(330);
61178         node.expression = expression;
61179         node.thisArg = thisArg;
61180         return node;
61181     }
61182     ts.createSyntheticReferenceExpression = createSyntheticReferenceExpression;
61183     function updateSyntheticReferenceExpression(node, expression, thisArg) {
61184         return node.expression !== expression
61185             || node.thisArg !== thisArg
61186             ? updateNode(createSyntheticReferenceExpression(expression, thisArg), node)
61187             : node;
61188     }
61189     ts.updateSyntheticReferenceExpression = updateSyntheticReferenceExpression;
61190     function createBundle(sourceFiles, prepends) {
61191         if (prepends === void 0) { prepends = ts.emptyArray; }
61192         var node = ts.createNode(291);
61193         node.prepends = prepends;
61194         node.sourceFiles = sourceFiles;
61195         return node;
61196     }
61197     ts.createBundle = createBundle;
61198     var allUnscopedEmitHelpers;
61199     function getAllUnscopedEmitHelpers() {
61200         return allUnscopedEmitHelpers || (allUnscopedEmitHelpers = ts.arrayToMap([
61201             ts.valuesHelper,
61202             ts.readHelper,
61203             ts.spreadHelper,
61204             ts.spreadArraysHelper,
61205             ts.restHelper,
61206             ts.decorateHelper,
61207             ts.metadataHelper,
61208             ts.paramHelper,
61209             ts.awaiterHelper,
61210             ts.assignHelper,
61211             ts.awaitHelper,
61212             ts.asyncGeneratorHelper,
61213             ts.asyncDelegator,
61214             ts.asyncValues,
61215             ts.extendsHelper,
61216             ts.templateObjectHelper,
61217             ts.generatorHelper,
61218             ts.importStarHelper,
61219             ts.importDefaultHelper,
61220             ts.classPrivateFieldGetHelper,
61221             ts.classPrivateFieldSetHelper,
61222             ts.createBindingHelper,
61223             ts.setModuleDefaultHelper
61224         ], function (helper) { return helper.name; }));
61225     }
61226     function createUnparsedSource() {
61227         var node = ts.createNode(292);
61228         node.prologues = ts.emptyArray;
61229         node.referencedFiles = ts.emptyArray;
61230         node.libReferenceDirectives = ts.emptyArray;
61231         node.getLineAndCharacterOfPosition = function (pos) { return ts.getLineAndCharacterOfPosition(node, pos); };
61232         return node;
61233     }
61234     function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, mapTextOrStripInternal) {
61235         var node = createUnparsedSource();
61236         var stripInternal;
61237         var bundleFileInfo;
61238         if (!ts.isString(textOrInputFiles)) {
61239             ts.Debug.assert(mapPathOrType === "js" || mapPathOrType === "dts");
61240             node.fileName = (mapPathOrType === "js" ? textOrInputFiles.javascriptPath : textOrInputFiles.declarationPath) || "";
61241             node.sourceMapPath = mapPathOrType === "js" ? textOrInputFiles.javascriptMapPath : textOrInputFiles.declarationMapPath;
61242             Object.defineProperties(node, {
61243                 text: { get: function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptText : textOrInputFiles.declarationText; } },
61244                 sourceMapText: { get: function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptMapText : textOrInputFiles.declarationMapText; } },
61245             });
61246             if (textOrInputFiles.buildInfo && textOrInputFiles.buildInfo.bundle) {
61247                 node.oldFileOfCurrentEmit = textOrInputFiles.oldFileOfCurrentEmit;
61248                 ts.Debug.assert(mapTextOrStripInternal === undefined || typeof mapTextOrStripInternal === "boolean");
61249                 stripInternal = mapTextOrStripInternal;
61250                 bundleFileInfo = mapPathOrType === "js" ? textOrInputFiles.buildInfo.bundle.js : textOrInputFiles.buildInfo.bundle.dts;
61251                 if (node.oldFileOfCurrentEmit) {
61252                     parseOldFileOfCurrentEmit(node, ts.Debug.checkDefined(bundleFileInfo));
61253                     return node;
61254                 }
61255             }
61256         }
61257         else {
61258             node.fileName = "";
61259             node.text = textOrInputFiles;
61260             node.sourceMapPath = mapPathOrType;
61261             node.sourceMapText = mapTextOrStripInternal;
61262         }
61263         ts.Debug.assert(!node.oldFileOfCurrentEmit);
61264         parseUnparsedSourceFile(node, bundleFileInfo, stripInternal);
61265         return node;
61266     }
61267     ts.createUnparsedSourceFile = createUnparsedSourceFile;
61268     function parseUnparsedSourceFile(node, bundleFileInfo, stripInternal) {
61269         var prologues;
61270         var helpers;
61271         var referencedFiles;
61272         var typeReferenceDirectives;
61273         var libReferenceDirectives;
61274         var texts;
61275         for (var _i = 0, _a = bundleFileInfo ? bundleFileInfo.sections : ts.emptyArray; _i < _a.length; _i++) {
61276             var section = _a[_i];
61277             switch (section.kind) {
61278                 case "prologue":
61279                     (prologues || (prologues = [])).push(createUnparsedNode(section, node));
61280                     break;
61281                 case "emitHelpers":
61282                     (helpers || (helpers = [])).push(getAllUnscopedEmitHelpers().get(section.data));
61283                     break;
61284                 case "no-default-lib":
61285                     node.hasNoDefaultLib = true;
61286                     break;
61287                 case "reference":
61288                     (referencedFiles || (referencedFiles = [])).push({ pos: -1, end: -1, fileName: section.data });
61289                     break;
61290                 case "type":
61291                     (typeReferenceDirectives || (typeReferenceDirectives = [])).push(section.data);
61292                     break;
61293                 case "lib":
61294                     (libReferenceDirectives || (libReferenceDirectives = [])).push({ pos: -1, end: -1, fileName: section.data });
61295                     break;
61296                 case "prepend":
61297                     var prependNode = createUnparsedNode(section, node);
61298                     var prependTexts = void 0;
61299                     for (var _b = 0, _c = section.texts; _b < _c.length; _b++) {
61300                         var text = _c[_b];
61301                         if (!stripInternal || text.kind !== "internal") {
61302                             (prependTexts || (prependTexts = [])).push(createUnparsedNode(text, node));
61303                         }
61304                     }
61305                     prependNode.texts = prependTexts || ts.emptyArray;
61306                     (texts || (texts = [])).push(prependNode);
61307                     break;
61308                 case "internal":
61309                     if (stripInternal) {
61310                         if (!texts)
61311                             texts = [];
61312                         break;
61313                     }
61314                 case "text":
61315                     (texts || (texts = [])).push(createUnparsedNode(section, node));
61316                     break;
61317                 default:
61318                     ts.Debug.assertNever(section);
61319             }
61320         }
61321         node.prologues = prologues || ts.emptyArray;
61322         node.helpers = helpers;
61323         node.referencedFiles = referencedFiles || ts.emptyArray;
61324         node.typeReferenceDirectives = typeReferenceDirectives;
61325         node.libReferenceDirectives = libReferenceDirectives || ts.emptyArray;
61326         node.texts = texts || [createUnparsedNode({ kind: "text", pos: 0, end: node.text.length }, node)];
61327     }
61328     function parseOldFileOfCurrentEmit(node, bundleFileInfo) {
61329         ts.Debug.assert(!!node.oldFileOfCurrentEmit);
61330         var texts;
61331         var syntheticReferences;
61332         for (var _i = 0, _a = bundleFileInfo.sections; _i < _a.length; _i++) {
61333             var section = _a[_i];
61334             switch (section.kind) {
61335                 case "internal":
61336                 case "text":
61337                     (texts || (texts = [])).push(createUnparsedNode(section, node));
61338                     break;
61339                 case "no-default-lib":
61340                 case "reference":
61341                 case "type":
61342                 case "lib":
61343                     (syntheticReferences || (syntheticReferences = [])).push(createUnparsedSyntheticReference(section, node));
61344                     break;
61345                 case "prologue":
61346                 case "emitHelpers":
61347                 case "prepend":
61348                     break;
61349                 default:
61350                     ts.Debug.assertNever(section);
61351             }
61352         }
61353         node.texts = texts || ts.emptyArray;
61354         node.helpers = ts.map(bundleFileInfo.sources && bundleFileInfo.sources.helpers, function (name) { return getAllUnscopedEmitHelpers().get(name); });
61355         node.syntheticReferences = syntheticReferences;
61356         return node;
61357     }
61358     function mapBundleFileSectionKindToSyntaxKind(kind) {
61359         switch (kind) {
61360             case "prologue": return 285;
61361             case "prepend": return 286;
61362             case "internal": return 288;
61363             case "text": return 287;
61364             case "emitHelpers":
61365             case "no-default-lib":
61366             case "reference":
61367             case "type":
61368             case "lib":
61369                 return ts.Debug.fail("BundleFileSectionKind: " + kind + " not yet mapped to SyntaxKind");
61370             default:
61371                 return ts.Debug.assertNever(kind);
61372         }
61373     }
61374     function createUnparsedNode(section, parent) {
61375         var node = ts.createNode(mapBundleFileSectionKindToSyntaxKind(section.kind), section.pos, section.end);
61376         node.parent = parent;
61377         node.data = section.data;
61378         return node;
61379     }
61380     function createUnparsedSyntheticReference(section, parent) {
61381         var node = ts.createNode(289, section.pos, section.end);
61382         node.parent = parent;
61383         node.data = section.data;
61384         node.section = section;
61385         return node;
61386     }
61387     function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) {
61388         var node = ts.createNode(293);
61389         if (!ts.isString(javascriptTextOrReadFileText)) {
61390             var cache_1 = ts.createMap();
61391             var textGetter_1 = function (path) {
61392                 if (path === undefined)
61393                     return undefined;
61394                 var value = cache_1.get(path);
61395                 if (value === undefined) {
61396                     value = javascriptTextOrReadFileText(path);
61397                     cache_1.set(path, value !== undefined ? value : false);
61398                 }
61399                 return value !== false ? value : undefined;
61400             };
61401             var definedTextGetter_1 = function (path) {
61402                 var result = textGetter_1(path);
61403                 return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n";
61404             };
61405             var buildInfo_1;
61406             var getAndCacheBuildInfo_1 = function (getText) {
61407                 if (buildInfo_1 === undefined) {
61408                     var result = getText();
61409                     buildInfo_1 = result !== undefined ? ts.getBuildInfo(result) : false;
61410                 }
61411                 return buildInfo_1 || undefined;
61412             };
61413             node.javascriptPath = declarationTextOrJavascriptPath;
61414             node.javascriptMapPath = javascriptMapPath;
61415             node.declarationPath = ts.Debug.checkDefined(javascriptMapTextOrDeclarationPath);
61416             node.declarationMapPath = declarationMapPath;
61417             node.buildInfoPath = declarationMapTextOrBuildInfoPath;
61418             Object.defineProperties(node, {
61419                 javascriptText: { get: function () { return definedTextGetter_1(declarationTextOrJavascriptPath); } },
61420                 javascriptMapText: { get: function () { return textGetter_1(javascriptMapPath); } },
61421                 declarationText: { get: function () { return definedTextGetter_1(ts.Debug.checkDefined(javascriptMapTextOrDeclarationPath)); } },
61422                 declarationMapText: { get: function () { return textGetter_1(declarationMapPath); } },
61423                 buildInfo: { get: function () { return getAndCacheBuildInfo_1(function () { return textGetter_1(declarationMapTextOrBuildInfoPath); }); } }
61424             });
61425         }
61426         else {
61427             node.javascriptText = javascriptTextOrReadFileText;
61428             node.javascriptMapPath = javascriptMapPath;
61429             node.javascriptMapText = javascriptMapTextOrDeclarationPath;
61430             node.declarationText = declarationTextOrJavascriptPath;
61431             node.declarationMapPath = declarationMapPath;
61432             node.declarationMapText = declarationMapTextOrBuildInfoPath;
61433             node.javascriptPath = javascriptPath;
61434             node.declarationPath = declarationPath;
61435             node.buildInfoPath = buildInfoPath;
61436             node.buildInfo = buildInfo;
61437             node.oldFileOfCurrentEmit = oldFileOfCurrentEmit;
61438         }
61439         return node;
61440     }
61441     ts.createInputFiles = createInputFiles;
61442     function updateBundle(node, sourceFiles, prepends) {
61443         if (prepends === void 0) { prepends = ts.emptyArray; }
61444         if (node.sourceFiles !== sourceFiles || node.prepends !== prepends) {
61445             return createBundle(sourceFiles, prepends);
61446         }
61447         return node;
61448     }
61449     ts.updateBundle = updateBundle;
61450     function createImmediatelyInvokedFunctionExpression(statements, param, paramValue) {
61451         return createCall(createFunctionExpression(undefined, undefined, undefined, undefined, param ? [param] : [], undefined, createBlock(statements, true)), undefined, paramValue ? [paramValue] : []);
61452     }
61453     ts.createImmediatelyInvokedFunctionExpression = createImmediatelyInvokedFunctionExpression;
61454     function createImmediatelyInvokedArrowFunction(statements, param, paramValue) {
61455         return createCall(createArrowFunction(undefined, undefined, param ? [param] : [], undefined, undefined, createBlock(statements, true)), undefined, paramValue ? [paramValue] : []);
61456     }
61457     ts.createImmediatelyInvokedArrowFunction = createImmediatelyInvokedArrowFunction;
61458     function createComma(left, right) {
61459         return createBinary(left, 27, right);
61460     }
61461     ts.createComma = createComma;
61462     function createLessThan(left, right) {
61463         return createBinary(left, 29, right);
61464     }
61465     ts.createLessThan = createLessThan;
61466     function createAssignment(left, right) {
61467         return createBinary(left, 62, right);
61468     }
61469     ts.createAssignment = createAssignment;
61470     function createStrictEquality(left, right) {
61471         return createBinary(left, 36, right);
61472     }
61473     ts.createStrictEquality = createStrictEquality;
61474     function createStrictInequality(left, right) {
61475         return createBinary(left, 37, right);
61476     }
61477     ts.createStrictInequality = createStrictInequality;
61478     function createAdd(left, right) {
61479         return createBinary(left, 39, right);
61480     }
61481     ts.createAdd = createAdd;
61482     function createSubtract(left, right) {
61483         return createBinary(left, 40, right);
61484     }
61485     ts.createSubtract = createSubtract;
61486     function createPostfixIncrement(operand) {
61487         return createPostfix(operand, 45);
61488     }
61489     ts.createPostfixIncrement = createPostfixIncrement;
61490     function createLogicalAnd(left, right) {
61491         return createBinary(left, 55, right);
61492     }
61493     ts.createLogicalAnd = createLogicalAnd;
61494     function createLogicalOr(left, right) {
61495         return createBinary(left, 56, right);
61496     }
61497     ts.createLogicalOr = createLogicalOr;
61498     function createNullishCoalesce(left, right) {
61499         return createBinary(left, 60, right);
61500     }
61501     ts.createNullishCoalesce = createNullishCoalesce;
61502     function createLogicalNot(operand) {
61503         return createPrefix(53, operand);
61504     }
61505     ts.createLogicalNot = createLogicalNot;
61506     function createVoidZero() {
61507         return createVoid(createLiteral(0));
61508     }
61509     ts.createVoidZero = createVoidZero;
61510     function createExportDefault(expression) {
61511         return createExportAssignment(undefined, undefined, false, expression);
61512     }
61513     ts.createExportDefault = createExportDefault;
61514     function createExternalModuleExport(exportName) {
61515         return createExportDeclaration(undefined, undefined, createNamedExports([createExportSpecifier(undefined, exportName)]));
61516     }
61517     ts.createExternalModuleExport = createExternalModuleExport;
61518     function asName(name) {
61519         return ts.isString(name) ? createIdentifier(name) : name;
61520     }
61521     function asExpression(value) {
61522         return typeof value === "string" ? createStringLiteral(value) :
61523             typeof value === "number" ? createNumericLiteral("" + value) :
61524                 typeof value === "boolean" ? value ? createTrue() : createFalse() :
61525                     value;
61526     }
61527     function asNodeArray(array) {
61528         return array ? createNodeArray(array) : undefined;
61529     }
61530     function asToken(value) {
61531         return typeof value === "number" ? createToken(value) : value;
61532     }
61533     function asEmbeddedStatement(statement) {
61534         return statement && ts.isNotEmittedStatement(statement) ? setTextRange(setOriginalNode(createEmptyStatement(), statement), statement) : statement;
61535     }
61536     function disposeEmitNodes(sourceFile) {
61537         sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile));
61538         var emitNode = sourceFile && sourceFile.emitNode;
61539         var annotatedNodes = emitNode && emitNode.annotatedNodes;
61540         if (annotatedNodes) {
61541             for (var _i = 0, annotatedNodes_1 = annotatedNodes; _i < annotatedNodes_1.length; _i++) {
61542                 var node = annotatedNodes_1[_i];
61543                 node.emitNode = undefined;
61544             }
61545         }
61546     }
61547     ts.disposeEmitNodes = disposeEmitNodes;
61548     function getOrCreateEmitNode(node) {
61549         if (!node.emitNode) {
61550             if (ts.isParseTreeNode(node)) {
61551                 if (node.kind === 290) {
61552                     return node.emitNode = { annotatedNodes: [node] };
61553                 }
61554                 var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node)));
61555                 getOrCreateEmitNode(sourceFile).annotatedNodes.push(node);
61556             }
61557             node.emitNode = {};
61558         }
61559         return node.emitNode;
61560     }
61561     ts.getOrCreateEmitNode = getOrCreateEmitNode;
61562     function removeAllComments(node) {
61563         var emitNode = getOrCreateEmitNode(node);
61564         emitNode.flags |= 1536;
61565         emitNode.leadingComments = undefined;
61566         emitNode.trailingComments = undefined;
61567         return node;
61568     }
61569     ts.removeAllComments = removeAllComments;
61570     function setTextRange(range, location) {
61571         if (location) {
61572             range.pos = location.pos;
61573             range.end = location.end;
61574         }
61575         return range;
61576     }
61577     ts.setTextRange = setTextRange;
61578     function setEmitFlags(node, emitFlags) {
61579         getOrCreateEmitNode(node).flags = emitFlags;
61580         return node;
61581     }
61582     ts.setEmitFlags = setEmitFlags;
61583     function addEmitFlags(node, emitFlags) {
61584         var emitNode = getOrCreateEmitNode(node);
61585         emitNode.flags = emitNode.flags | emitFlags;
61586         return node;
61587     }
61588     ts.addEmitFlags = addEmitFlags;
61589     function getSourceMapRange(node) {
61590         var emitNode = node.emitNode;
61591         return (emitNode && emitNode.sourceMapRange) || node;
61592     }
61593     ts.getSourceMapRange = getSourceMapRange;
61594     function setSourceMapRange(node, range) {
61595         getOrCreateEmitNode(node).sourceMapRange = range;
61596         return node;
61597     }
61598     ts.setSourceMapRange = setSourceMapRange;
61599     var SourceMapSource;
61600     function createSourceMapSource(fileName, text, skipTrivia) {
61601         return new (SourceMapSource || (SourceMapSource = ts.objectAllocator.getSourceMapSourceConstructor()))(fileName, text, skipTrivia);
61602     }
61603     ts.createSourceMapSource = createSourceMapSource;
61604     function getTokenSourceMapRange(node, token) {
61605         var emitNode = node.emitNode;
61606         var tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges;
61607         return tokenSourceMapRanges && tokenSourceMapRanges[token];
61608     }
61609     ts.getTokenSourceMapRange = getTokenSourceMapRange;
61610     function setTokenSourceMapRange(node, token, range) {
61611         var emitNode = getOrCreateEmitNode(node);
61612         var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = []);
61613         tokenSourceMapRanges[token] = range;
61614         return node;
61615     }
61616     ts.setTokenSourceMapRange = setTokenSourceMapRange;
61617     function getStartsOnNewLine(node) {
61618         var emitNode = node.emitNode;
61619         return emitNode && emitNode.startsOnNewLine;
61620     }
61621     ts.getStartsOnNewLine = getStartsOnNewLine;
61622     function setStartsOnNewLine(node, newLine) {
61623         getOrCreateEmitNode(node).startsOnNewLine = newLine;
61624         return node;
61625     }
61626     ts.setStartsOnNewLine = setStartsOnNewLine;
61627     function getCommentRange(node) {
61628         var emitNode = node.emitNode;
61629         return (emitNode && emitNode.commentRange) || node;
61630     }
61631     ts.getCommentRange = getCommentRange;
61632     function setCommentRange(node, range) {
61633         getOrCreateEmitNode(node).commentRange = range;
61634         return node;
61635     }
61636     ts.setCommentRange = setCommentRange;
61637     function getSyntheticLeadingComments(node) {
61638         var emitNode = node.emitNode;
61639         return emitNode && emitNode.leadingComments;
61640     }
61641     ts.getSyntheticLeadingComments = getSyntheticLeadingComments;
61642     function setSyntheticLeadingComments(node, comments) {
61643         getOrCreateEmitNode(node).leadingComments = comments;
61644         return node;
61645     }
61646     ts.setSyntheticLeadingComments = setSyntheticLeadingComments;
61647     function addSyntheticLeadingComment(node, kind, text, hasTrailingNewLine) {
61648         return setSyntheticLeadingComments(node, ts.append(getSyntheticLeadingComments(node), { kind: kind, pos: -1, end: -1, hasTrailingNewLine: hasTrailingNewLine, text: text }));
61649     }
61650     ts.addSyntheticLeadingComment = addSyntheticLeadingComment;
61651     function getSyntheticTrailingComments(node) {
61652         var emitNode = node.emitNode;
61653         return emitNode && emitNode.trailingComments;
61654     }
61655     ts.getSyntheticTrailingComments = getSyntheticTrailingComments;
61656     function setSyntheticTrailingComments(node, comments) {
61657         getOrCreateEmitNode(node).trailingComments = comments;
61658         return node;
61659     }
61660     ts.setSyntheticTrailingComments = setSyntheticTrailingComments;
61661     function addSyntheticTrailingComment(node, kind, text, hasTrailingNewLine) {
61662         return setSyntheticTrailingComments(node, ts.append(getSyntheticTrailingComments(node), { kind: kind, pos: -1, end: -1, hasTrailingNewLine: hasTrailingNewLine, text: text }));
61663     }
61664     ts.addSyntheticTrailingComment = addSyntheticTrailingComment;
61665     function moveSyntheticComments(node, original) {
61666         setSyntheticLeadingComments(node, getSyntheticLeadingComments(original));
61667         setSyntheticTrailingComments(node, getSyntheticTrailingComments(original));
61668         var emit = getOrCreateEmitNode(original);
61669         emit.leadingComments = undefined;
61670         emit.trailingComments = undefined;
61671         return node;
61672     }
61673     ts.moveSyntheticComments = moveSyntheticComments;
61674     function ignoreSourceNewlines(node) {
61675         getOrCreateEmitNode(node).flags |= 134217728;
61676         return node;
61677     }
61678     ts.ignoreSourceNewlines = ignoreSourceNewlines;
61679     function getConstantValue(node) {
61680         var emitNode = node.emitNode;
61681         return emitNode && emitNode.constantValue;
61682     }
61683     ts.getConstantValue = getConstantValue;
61684     function setConstantValue(node, value) {
61685         var emitNode = getOrCreateEmitNode(node);
61686         emitNode.constantValue = value;
61687         return node;
61688     }
61689     ts.setConstantValue = setConstantValue;
61690     function addEmitHelper(node, helper) {
61691         var emitNode = getOrCreateEmitNode(node);
61692         emitNode.helpers = ts.append(emitNode.helpers, helper);
61693         return node;
61694     }
61695     ts.addEmitHelper = addEmitHelper;
61696     function addEmitHelpers(node, helpers) {
61697         if (ts.some(helpers)) {
61698             var emitNode = getOrCreateEmitNode(node);
61699             for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) {
61700                 var helper = helpers_1[_i];
61701                 emitNode.helpers = ts.appendIfUnique(emitNode.helpers, helper);
61702             }
61703         }
61704         return node;
61705     }
61706     ts.addEmitHelpers = addEmitHelpers;
61707     function removeEmitHelper(node, helper) {
61708         var emitNode = node.emitNode;
61709         if (emitNode) {
61710             var helpers = emitNode.helpers;
61711             if (helpers) {
61712                 return ts.orderedRemoveItem(helpers, helper);
61713             }
61714         }
61715         return false;
61716     }
61717     ts.removeEmitHelper = removeEmitHelper;
61718     function getEmitHelpers(node) {
61719         var emitNode = node.emitNode;
61720         return emitNode && emitNode.helpers;
61721     }
61722     ts.getEmitHelpers = getEmitHelpers;
61723     function moveEmitHelpers(source, target, predicate) {
61724         var sourceEmitNode = source.emitNode;
61725         var sourceEmitHelpers = sourceEmitNode && sourceEmitNode.helpers;
61726         if (!ts.some(sourceEmitHelpers))
61727             return;
61728         var targetEmitNode = getOrCreateEmitNode(target);
61729         var helpersRemoved = 0;
61730         for (var i = 0; i < sourceEmitHelpers.length; i++) {
61731             var helper = sourceEmitHelpers[i];
61732             if (predicate(helper)) {
61733                 helpersRemoved++;
61734                 targetEmitNode.helpers = ts.appendIfUnique(targetEmitNode.helpers, helper);
61735             }
61736             else if (helpersRemoved > 0) {
61737                 sourceEmitHelpers[i - helpersRemoved] = helper;
61738             }
61739         }
61740         if (helpersRemoved > 0) {
61741             sourceEmitHelpers.length -= helpersRemoved;
61742         }
61743     }
61744     ts.moveEmitHelpers = moveEmitHelpers;
61745     function compareEmitHelpers(x, y) {
61746         if (x === y)
61747             return 0;
61748         if (x.priority === y.priority)
61749             return 0;
61750         if (x.priority === undefined)
61751             return 1;
61752         if (y.priority === undefined)
61753             return -1;
61754         return ts.compareValues(x.priority, y.priority);
61755     }
61756     ts.compareEmitHelpers = compareEmitHelpers;
61757     function setOriginalNode(node, original) {
61758         node.original = original;
61759         if (original) {
61760             var emitNode = original.emitNode;
61761             if (emitNode)
61762                 node.emitNode = mergeEmitNode(emitNode, node.emitNode);
61763         }
61764         return node;
61765     }
61766     ts.setOriginalNode = setOriginalNode;
61767     function mergeEmitNode(sourceEmitNode, destEmitNode) {
61768         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;
61769         if (!destEmitNode)
61770             destEmitNode = {};
61771         if (leadingComments)
61772             destEmitNode.leadingComments = ts.addRange(leadingComments.slice(), destEmitNode.leadingComments);
61773         if (trailingComments)
61774             destEmitNode.trailingComments = ts.addRange(trailingComments.slice(), destEmitNode.trailingComments);
61775         if (flags)
61776             destEmitNode.flags = flags;
61777         if (commentRange)
61778             destEmitNode.commentRange = commentRange;
61779         if (sourceMapRange)
61780             destEmitNode.sourceMapRange = sourceMapRange;
61781         if (tokenSourceMapRanges)
61782             destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges);
61783         if (constantValue !== undefined)
61784             destEmitNode.constantValue = constantValue;
61785         if (helpers)
61786             destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers);
61787         if (startsOnNewLine !== undefined)
61788             destEmitNode.startsOnNewLine = startsOnNewLine;
61789         return destEmitNode;
61790     }
61791     function mergeTokenSourceMapRanges(sourceRanges, destRanges) {
61792         if (!destRanges)
61793             destRanges = [];
61794         for (var key in sourceRanges) {
61795             destRanges[key] = sourceRanges[key];
61796         }
61797         return destRanges;
61798     }
61799 })(ts || (ts = {}));
61800 var ts;
61801 (function (ts) {
61802     ts.nullTransformationContext = {
61803         enableEmitNotification: ts.noop,
61804         enableSubstitution: ts.noop,
61805         endLexicalEnvironment: ts.returnUndefined,
61806         getCompilerOptions: function () { return ({}); },
61807         getEmitHost: ts.notImplemented,
61808         getEmitResolver: ts.notImplemented,
61809         setLexicalEnvironmentFlags: ts.noop,
61810         getLexicalEnvironmentFlags: function () { return 0; },
61811         hoistFunctionDeclaration: ts.noop,
61812         hoistVariableDeclaration: ts.noop,
61813         addInitializationStatement: ts.noop,
61814         isEmitNotificationEnabled: ts.notImplemented,
61815         isSubstitutionEnabled: ts.notImplemented,
61816         onEmitNode: ts.noop,
61817         onSubstituteNode: ts.notImplemented,
61818         readEmitHelpers: ts.notImplemented,
61819         requestEmitHelper: ts.noop,
61820         resumeLexicalEnvironment: ts.noop,
61821         startLexicalEnvironment: ts.noop,
61822         suspendLexicalEnvironment: ts.noop,
61823         addDiagnostic: ts.noop,
61824     };
61825     function createTypeCheck(value, tag) {
61826         return tag === "undefined"
61827             ? ts.createStrictEquality(value, ts.createVoidZero())
61828             : ts.createStrictEquality(ts.createTypeOf(value), ts.createLiteral(tag));
61829     }
61830     ts.createTypeCheck = createTypeCheck;
61831     function createMemberAccessForPropertyName(target, memberName, location) {
61832         if (ts.isComputedPropertyName(memberName)) {
61833             return ts.setTextRange(ts.createElementAccess(target, memberName.expression), location);
61834         }
61835         else {
61836             var expression = ts.setTextRange((ts.isIdentifier(memberName) || ts.isPrivateIdentifier(memberName))
61837                 ? ts.createPropertyAccess(target, memberName)
61838                 : ts.createElementAccess(target, memberName), memberName);
61839             ts.getOrCreateEmitNode(expression).flags |= 64;
61840             return expression;
61841         }
61842     }
61843     ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName;
61844     function createFunctionCall(func, thisArg, argumentsList, location) {
61845         return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), undefined, __spreadArrays([
61846             thisArg
61847         ], argumentsList)), location);
61848     }
61849     ts.createFunctionCall = createFunctionCall;
61850     function createFunctionApply(func, thisArg, argumentsExpression, location) {
61851         return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "apply"), undefined, [
61852             thisArg,
61853             argumentsExpression
61854         ]), location);
61855     }
61856     ts.createFunctionApply = createFunctionApply;
61857     function createArraySlice(array, start) {
61858         var argumentsList = [];
61859         if (start !== undefined) {
61860             argumentsList.push(typeof start === "number" ? ts.createLiteral(start) : start);
61861         }
61862         return ts.createCall(ts.createPropertyAccess(array, "slice"), undefined, argumentsList);
61863     }
61864     ts.createArraySlice = createArraySlice;
61865     function createArrayConcat(array, values) {
61866         return ts.createCall(ts.createPropertyAccess(array, "concat"), undefined, values);
61867     }
61868     ts.createArrayConcat = createArrayConcat;
61869     function createMathPow(left, right, location) {
61870         return ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Math"), "pow"), undefined, [left, right]), location);
61871     }
61872     ts.createMathPow = createMathPow;
61873     function createReactNamespace(reactNamespace, parent) {
61874         var react = ts.createIdentifier(reactNamespace || "React");
61875         react.flags &= ~8;
61876         react.parent = ts.getParseTreeNode(parent);
61877         return react;
61878     }
61879     function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) {
61880         if (ts.isQualifiedName(jsxFactory)) {
61881             var left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent);
61882             var right = ts.createIdentifier(ts.idText(jsxFactory.right));
61883             right.escapedText = jsxFactory.right.escapedText;
61884             return ts.createPropertyAccess(left, right);
61885         }
61886         else {
61887             return createReactNamespace(ts.idText(jsxFactory), parent);
61888         }
61889     }
61890     function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) {
61891         return jsxFactoryEntity ?
61892             createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) :
61893             ts.createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement");
61894     }
61895     function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) {
61896         var argumentsList = [tagName];
61897         if (props) {
61898             argumentsList.push(props);
61899         }
61900         if (children && children.length > 0) {
61901             if (!props) {
61902                 argumentsList.push(ts.createNull());
61903             }
61904             if (children.length > 1) {
61905                 for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
61906                     var child = children_2[_i];
61907                     startOnNewLine(child);
61908                     argumentsList.push(child);
61909                 }
61910             }
61911             else {
61912                 argumentsList.push(children[0]);
61913             }
61914         }
61915         return ts.setTextRange(ts.createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList), location);
61916     }
61917     ts.createExpressionForJsxElement = createExpressionForJsxElement;
61918     function createExpressionForJsxFragment(jsxFactoryEntity, reactNamespace, children, parentElement, location) {
61919         var tagName = ts.createPropertyAccess(createReactNamespace(reactNamespace, parentElement), "Fragment");
61920         var argumentsList = [tagName];
61921         argumentsList.push(ts.createNull());
61922         if (children && children.length > 0) {
61923             if (children.length > 1) {
61924                 for (var _i = 0, children_3 = children; _i < children_3.length; _i++) {
61925                     var child = children_3[_i];
61926                     startOnNewLine(child);
61927                     argumentsList.push(child);
61928                 }
61929             }
61930             else {
61931                 argumentsList.push(children[0]);
61932             }
61933         }
61934         return ts.setTextRange(ts.createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList), location);
61935     }
61936     ts.createExpressionForJsxFragment = createExpressionForJsxFragment;
61937     function getUnscopedHelperName(name) {
61938         return ts.setEmitFlags(ts.createIdentifier(name), 4096 | 2);
61939     }
61940     ts.getUnscopedHelperName = getUnscopedHelperName;
61941     ts.valuesHelper = {
61942         name: "typescript:values",
61943         importName: "__values",
61944         scoped: false,
61945         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            };"
61946     };
61947     function createValuesHelper(context, expression, location) {
61948         context.requestEmitHelper(ts.valuesHelper);
61949         return ts.setTextRange(ts.createCall(getUnscopedHelperName("__values"), undefined, [expression]), location);
61950     }
61951     ts.createValuesHelper = createValuesHelper;
61952     ts.readHelper = {
61953         name: "typescript:read",
61954         importName: "__read",
61955         scoped: false,
61956         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            };"
61957     };
61958     function createReadHelper(context, iteratorRecord, count, location) {
61959         context.requestEmitHelper(ts.readHelper);
61960         return ts.setTextRange(ts.createCall(getUnscopedHelperName("__read"), undefined, count !== undefined
61961             ? [iteratorRecord, ts.createLiteral(count)]
61962             : [iteratorRecord]), location);
61963     }
61964     ts.createReadHelper = createReadHelper;
61965     ts.spreadHelper = {
61966         name: "typescript:spread",
61967         importName: "__spread",
61968         scoped: false,
61969         dependencies: [ts.readHelper],
61970         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            };"
61971     };
61972     function createSpreadHelper(context, argumentList, location) {
61973         context.requestEmitHelper(ts.spreadHelper);
61974         return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spread"), undefined, argumentList), location);
61975     }
61976     ts.createSpreadHelper = createSpreadHelper;
61977     ts.spreadArraysHelper = {
61978         name: "typescript:spreadArrays",
61979         importName: "__spreadArrays",
61980         scoped: false,
61981         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            };"
61982     };
61983     function createSpreadArraysHelper(context, argumentList, location) {
61984         context.requestEmitHelper(ts.spreadArraysHelper);
61985         return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spreadArrays"), undefined, argumentList), location);
61986     }
61987     ts.createSpreadArraysHelper = createSpreadArraysHelper;
61988     function createForOfBindingStatement(node, boundValue) {
61989         if (ts.isVariableDeclarationList(node)) {
61990             var firstDeclaration = ts.first(node.declarations);
61991             var updatedDeclaration = ts.updateVariableDeclaration(firstDeclaration, firstDeclaration.name, undefined, boundValue);
61992             return ts.setTextRange(ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(node, [updatedDeclaration])), node);
61993         }
61994         else {
61995             var updatedExpression = ts.setTextRange(ts.createAssignment(node, boundValue), node);
61996             return ts.setTextRange(ts.createStatement(updatedExpression), node);
61997         }
61998     }
61999     ts.createForOfBindingStatement = createForOfBindingStatement;
62000     function insertLeadingStatement(dest, source) {
62001         if (ts.isBlock(dest)) {
62002             return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray(__spreadArrays([source], dest.statements)), dest.statements));
62003         }
62004         else {
62005             return ts.createBlock(ts.createNodeArray([dest, source]), true);
62006         }
62007     }
62008     ts.insertLeadingStatement = insertLeadingStatement;
62009     function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) {
62010         if (!outermostLabeledStatement) {
62011             return node;
62012         }
62013         var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 238
62014             ? restoreEnclosingLabel(node, outermostLabeledStatement.statement)
62015             : node);
62016         if (afterRestoreLabelCallback) {
62017             afterRestoreLabelCallback(outermostLabeledStatement);
62018         }
62019         return updated;
62020     }
62021     ts.restoreEnclosingLabel = restoreEnclosingLabel;
62022     function shouldBeCapturedInTempVariable(node, cacheIdentifiers) {
62023         var target = ts.skipParentheses(node);
62024         switch (target.kind) {
62025             case 75:
62026                 return cacheIdentifiers;
62027             case 104:
62028             case 8:
62029             case 9:
62030             case 10:
62031                 return false;
62032             case 192:
62033                 var elements = target.elements;
62034                 if (elements.length === 0) {
62035                     return false;
62036                 }
62037                 return true;
62038             case 193:
62039                 return target.properties.length > 0;
62040             default:
62041                 return true;
62042         }
62043     }
62044     function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) {
62045         if (cacheIdentifiers === void 0) { cacheIdentifiers = false; }
62046         var callee = skipOuterExpressions(expression, 15);
62047         var thisArg;
62048         var target;
62049         if (ts.isSuperProperty(callee)) {
62050             thisArg = ts.createThis();
62051             target = callee;
62052         }
62053         else if (callee.kind === 102) {
62054             thisArg = ts.createThis();
62055             target = languageVersion < 2
62056                 ? ts.setTextRange(ts.createIdentifier("_super"), callee)
62057                 : callee;
62058         }
62059         else if (ts.getEmitFlags(callee) & 4096) {
62060             thisArg = ts.createVoidZero();
62061             target = parenthesizeForAccess(callee);
62062         }
62063         else {
62064             switch (callee.kind) {
62065                 case 194: {
62066                     if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
62067                         thisArg = ts.createTempVariable(recordTempVariable);
62068                         target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name);
62069                         ts.setTextRange(target, callee);
62070                     }
62071                     else {
62072                         thisArg = callee.expression;
62073                         target = callee;
62074                     }
62075                     break;
62076                 }
62077                 case 195: {
62078                     if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
62079                         thisArg = ts.createTempVariable(recordTempVariable);
62080                         target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression);
62081                         ts.setTextRange(target, callee);
62082                     }
62083                     else {
62084                         thisArg = callee.expression;
62085                         target = callee;
62086                     }
62087                     break;
62088                 }
62089                 default: {
62090                     thisArg = ts.createVoidZero();
62091                     target = parenthesizeForAccess(expression);
62092                     break;
62093                 }
62094             }
62095         }
62096         return { target: target, thisArg: thisArg };
62097     }
62098     ts.createCallBinding = createCallBinding;
62099     function inlineExpressions(expressions) {
62100         return expressions.length > 10
62101             ? ts.createCommaList(expressions)
62102             : ts.reduceLeft(expressions, ts.createComma);
62103     }
62104     ts.inlineExpressions = inlineExpressions;
62105     function createExpressionFromEntityName(node) {
62106         if (ts.isQualifiedName(node)) {
62107             var left = createExpressionFromEntityName(node.left);
62108             var right = ts.getMutableClone(node.right);
62109             return ts.setTextRange(ts.createPropertyAccess(left, right), node);
62110         }
62111         else {
62112             return ts.getMutableClone(node);
62113         }
62114     }
62115     ts.createExpressionFromEntityName = createExpressionFromEntityName;
62116     function createExpressionForPropertyName(memberName) {
62117         if (ts.isIdentifier(memberName)) {
62118             return ts.createLiteral(memberName);
62119         }
62120         else if (ts.isComputedPropertyName(memberName)) {
62121             return ts.getMutableClone(memberName.expression);
62122         }
62123         else {
62124             return ts.getMutableClone(memberName);
62125         }
62126     }
62127     ts.createExpressionForPropertyName = createExpressionForPropertyName;
62128     function createExpressionForObjectLiteralElementLike(node, property, receiver) {
62129         if (property.name && ts.isPrivateIdentifier(property.name)) {
62130             ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals.");
62131         }
62132         switch (property.kind) {
62133             case 163:
62134             case 164:
62135                 return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine);
62136             case 281:
62137                 return createExpressionForPropertyAssignment(property, receiver);
62138             case 282:
62139                 return createExpressionForShorthandPropertyAssignment(property, receiver);
62140             case 161:
62141                 return createExpressionForMethodDeclaration(property, receiver);
62142         }
62143     }
62144     ts.createExpressionForObjectLiteralElementLike = createExpressionForObjectLiteralElementLike;
62145     function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) {
62146         var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
62147         if (property === firstAccessor) {
62148             var properties_7 = [];
62149             if (getAccessor) {
62150                 var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body);
62151                 ts.setTextRange(getterFunction, getAccessor);
62152                 ts.setOriginalNode(getterFunction, getAccessor);
62153                 var getter = ts.createPropertyAssignment("get", getterFunction);
62154                 properties_7.push(getter);
62155             }
62156             if (setAccessor) {
62157                 var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body);
62158                 ts.setTextRange(setterFunction, setAccessor);
62159                 ts.setOriginalNode(setterFunction, setAccessor);
62160                 var setter = ts.createPropertyAssignment("set", setterFunction);
62161                 properties_7.push(setter);
62162             }
62163             properties_7.push(ts.createPropertyAssignment("enumerable", getAccessor || setAccessor ? ts.createFalse() : ts.createTrue()));
62164             properties_7.push(ts.createPropertyAssignment("configurable", ts.createTrue()));
62165             var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [
62166                 receiver,
62167                 createExpressionForPropertyName(property.name),
62168                 ts.createObjectLiteral(properties_7, multiLine)
62169             ]), firstAccessor);
62170             return ts.aggregateTransformFlags(expression);
62171         }
62172         return undefined;
62173     }
62174     function createExpressionForPropertyAssignment(property, receiver) {
62175         return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), property.initializer), property), property));
62176     }
62177     function createExpressionForShorthandPropertyAssignment(property, receiver) {
62178         return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), ts.getSynthesizedClone(property.name)), property), property));
62179     }
62180     function createExpressionForMethodDeclaration(method, receiver) {
62181         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));
62182     }
62183     function getInternalName(node, allowComments, allowSourceMaps) {
62184         return getName(node, allowComments, allowSourceMaps, 16384 | 32768);
62185     }
62186     ts.getInternalName = getInternalName;
62187     function isInternalName(node) {
62188         return (ts.getEmitFlags(node) & 32768) !== 0;
62189     }
62190     ts.isInternalName = isInternalName;
62191     function getLocalName(node, allowComments, allowSourceMaps) {
62192         return getName(node, allowComments, allowSourceMaps, 16384);
62193     }
62194     ts.getLocalName = getLocalName;
62195     function isLocalName(node) {
62196         return (ts.getEmitFlags(node) & 16384) !== 0;
62197     }
62198     ts.isLocalName = isLocalName;
62199     function getExportName(node, allowComments, allowSourceMaps) {
62200         return getName(node, allowComments, allowSourceMaps, 8192);
62201     }
62202     ts.getExportName = getExportName;
62203     function isExportName(node) {
62204         return (ts.getEmitFlags(node) & 8192) !== 0;
62205     }
62206     ts.isExportName = isExportName;
62207     function getDeclarationName(node, allowComments, allowSourceMaps) {
62208         return getName(node, allowComments, allowSourceMaps);
62209     }
62210     ts.getDeclarationName = getDeclarationName;
62211     function getName(node, allowComments, allowSourceMaps, emitFlags) {
62212         if (emitFlags === void 0) { emitFlags = 0; }
62213         var nodeName = ts.getNameOfDeclaration(node);
62214         if (nodeName && ts.isIdentifier(nodeName) && !ts.isGeneratedIdentifier(nodeName)) {
62215             var name = ts.getMutableClone(nodeName);
62216             emitFlags |= ts.getEmitFlags(nodeName);
62217             if (!allowSourceMaps)
62218                 emitFlags |= 48;
62219             if (!allowComments)
62220                 emitFlags |= 1536;
62221             if (emitFlags)
62222                 ts.setEmitFlags(name, emitFlags);
62223             return name;
62224         }
62225         return ts.getGeneratedNameForNode(node);
62226     }
62227     function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) {
62228         if (ns && ts.hasModifier(node, 1)) {
62229             return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps);
62230         }
62231         return getExportName(node, allowComments, allowSourceMaps);
62232     }
62233     ts.getExternalModuleOrNamespaceExportName = getExternalModuleOrNamespaceExportName;
62234     function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) {
62235         var qualifiedName = ts.createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : ts.getSynthesizedClone(name));
62236         ts.setTextRange(qualifiedName, name);
62237         var emitFlags = 0;
62238         if (!allowSourceMaps)
62239             emitFlags |= 48;
62240         if (!allowComments)
62241             emitFlags |= 1536;
62242         if (emitFlags)
62243             ts.setEmitFlags(qualifiedName, emitFlags);
62244         return qualifiedName;
62245     }
62246     ts.getNamespaceMemberName = getNamespaceMemberName;
62247     function convertToFunctionBody(node, multiLine) {
62248         return ts.isBlock(node) ? node : ts.setTextRange(ts.createBlock([ts.setTextRange(ts.createReturn(node), node)], multiLine), node);
62249     }
62250     ts.convertToFunctionBody = convertToFunctionBody;
62251     function convertFunctionDeclarationToExpression(node) {
62252         if (!node.body)
62253             return ts.Debug.fail();
62254         var updated = ts.createFunctionExpression(node.modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body);
62255         ts.setOriginalNode(updated, node);
62256         ts.setTextRange(updated, node);
62257         if (ts.getStartsOnNewLine(node)) {
62258             ts.setStartsOnNewLine(updated, true);
62259         }
62260         ts.aggregateTransformFlags(updated);
62261         return updated;
62262     }
62263     ts.convertFunctionDeclarationToExpression = convertFunctionDeclarationToExpression;
62264     function isUseStrictPrologue(node) {
62265         return ts.isStringLiteral(node.expression) && node.expression.text === "use strict";
62266     }
62267     function addPrologue(target, source, ensureUseStrict, visitor) {
62268         var offset = addStandardPrologue(target, source, ensureUseStrict);
62269         return addCustomPrologue(target, source, offset, visitor);
62270     }
62271     ts.addPrologue = addPrologue;
62272     function addStandardPrologue(target, source, ensureUseStrict) {
62273         ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array");
62274         var foundUseStrict = false;
62275         var statementOffset = 0;
62276         var numStatements = source.length;
62277         while (statementOffset < numStatements) {
62278             var statement = source[statementOffset];
62279             if (ts.isPrologueDirective(statement)) {
62280                 if (isUseStrictPrologue(statement)) {
62281                     foundUseStrict = true;
62282                 }
62283                 target.push(statement);
62284             }
62285             else {
62286                 break;
62287             }
62288             statementOffset++;
62289         }
62290         if (ensureUseStrict && !foundUseStrict) {
62291             target.push(startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))));
62292         }
62293         return statementOffset;
62294     }
62295     ts.addStandardPrologue = addStandardPrologue;
62296     function addCustomPrologue(target, source, statementOffset, visitor, filter) {
62297         if (filter === void 0) { filter = ts.returnTrue; }
62298         var numStatements = source.length;
62299         while (statementOffset !== undefined && statementOffset < numStatements) {
62300             var statement = source[statementOffset];
62301             if (ts.getEmitFlags(statement) & 1048576 && filter(statement)) {
62302                 ts.append(target, visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement);
62303             }
62304             else {
62305                 break;
62306             }
62307             statementOffset++;
62308         }
62309         return statementOffset;
62310     }
62311     ts.addCustomPrologue = addCustomPrologue;
62312     function findUseStrictPrologue(statements) {
62313         for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) {
62314             var statement = statements_4[_i];
62315             if (ts.isPrologueDirective(statement)) {
62316                 if (isUseStrictPrologue(statement)) {
62317                     return statement;
62318                 }
62319             }
62320             else {
62321                 break;
62322             }
62323         }
62324         return undefined;
62325     }
62326     ts.findUseStrictPrologue = findUseStrictPrologue;
62327     function startsWithUseStrict(statements) {
62328         var firstStatement = ts.firstOrUndefined(statements);
62329         return firstStatement !== undefined
62330             && ts.isPrologueDirective(firstStatement)
62331             && isUseStrictPrologue(firstStatement);
62332     }
62333     ts.startsWithUseStrict = startsWithUseStrict;
62334     function ensureUseStrict(statements) {
62335         var foundUseStrict = findUseStrictPrologue(statements);
62336         if (!foundUseStrict) {
62337             return ts.setTextRange(ts.createNodeArray(__spreadArrays([
62338                 startOnNewLine(ts.createStatement(ts.createLiteral("use strict")))
62339             ], statements)), statements);
62340         }
62341         return statements;
62342     }
62343     ts.ensureUseStrict = ensureUseStrict;
62344     function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) {
62345         var skipped = ts.skipPartiallyEmittedExpressions(operand);
62346         if (skipped.kind === 200) {
62347             return operand;
62348         }
62349         return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand)
62350             ? ts.createParen(operand)
62351             : operand;
62352     }
62353     ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand;
62354     function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) {
62355         var binaryOperatorPrecedence = ts.getOperatorPrecedence(209, binaryOperator);
62356         var binaryOperatorAssociativity = ts.getOperatorAssociativity(209, binaryOperator);
62357         var emittedOperand = ts.skipPartiallyEmittedExpressions(operand);
62358         if (!isLeftSideOfBinary && operand.kind === 202 && binaryOperatorPrecedence > 3) {
62359             return true;
62360         }
62361         var operandPrecedence = ts.getExpressionPrecedence(emittedOperand);
62362         switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) {
62363             case -1:
62364                 if (!isLeftSideOfBinary
62365                     && binaryOperatorAssociativity === 1
62366                     && operand.kind === 212) {
62367                     return false;
62368                 }
62369                 return true;
62370             case 1:
62371                 return false;
62372             case 0:
62373                 if (isLeftSideOfBinary) {
62374                     return binaryOperatorAssociativity === 1;
62375                 }
62376                 else {
62377                     if (ts.isBinaryExpression(emittedOperand)
62378                         && emittedOperand.operatorToken.kind === binaryOperator) {
62379                         if (operatorHasAssociativeProperty(binaryOperator)) {
62380                             return false;
62381                         }
62382                         if (binaryOperator === 39) {
62383                             var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0;
62384                             if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) {
62385                                 return false;
62386                             }
62387                         }
62388                     }
62389                     var operandAssociativity = ts.getExpressionAssociativity(emittedOperand);
62390                     return operandAssociativity === 0;
62391                 }
62392         }
62393     }
62394     function operatorHasAssociativeProperty(binaryOperator) {
62395         return binaryOperator === 41
62396             || binaryOperator === 51
62397             || binaryOperator === 50
62398             || binaryOperator === 52;
62399     }
62400     function getLiteralKindOfBinaryPlusOperand(node) {
62401         node = ts.skipPartiallyEmittedExpressions(node);
62402         if (ts.isLiteralKind(node.kind)) {
62403             return node.kind;
62404         }
62405         if (node.kind === 209 && node.operatorToken.kind === 39) {
62406             if (node.cachedLiteralKind !== undefined) {
62407                 return node.cachedLiteralKind;
62408             }
62409             var leftKind = getLiteralKindOfBinaryPlusOperand(node.left);
62410             var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind :
62411                 0;
62412             node.cachedLiteralKind = literalKind;
62413             return literalKind;
62414         }
62415         return 0;
62416     }
62417     function parenthesizeForConditionalHead(condition) {
62418         var conditionalPrecedence = ts.getOperatorPrecedence(210, 57);
62419         var emittedCondition = ts.skipPartiallyEmittedExpressions(condition);
62420         var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition);
62421         if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1) {
62422             return ts.createParen(condition);
62423         }
62424         return condition;
62425     }
62426     ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead;
62427     function parenthesizeSubexpressionOfConditionalExpression(e) {
62428         var emittedExpression = ts.skipPartiallyEmittedExpressions(e);
62429         return isCommaSequence(emittedExpression)
62430             ? ts.createParen(e)
62431             : e;
62432     }
62433     ts.parenthesizeSubexpressionOfConditionalExpression = parenthesizeSubexpressionOfConditionalExpression;
62434     function parenthesizeDefaultExpression(e) {
62435         var check = ts.skipPartiallyEmittedExpressions(e);
62436         var needsParens = isCommaSequence(check);
62437         if (!needsParens) {
62438             switch (getLeftmostExpression(check, false).kind) {
62439                 case 214:
62440                 case 201:
62441                     needsParens = true;
62442             }
62443         }
62444         return needsParens ? ts.createParen(e) : e;
62445     }
62446     ts.parenthesizeDefaultExpression = parenthesizeDefaultExpression;
62447     function parenthesizeForNew(expression) {
62448         var leftmostExpr = getLeftmostExpression(expression, true);
62449         switch (leftmostExpr.kind) {
62450             case 196:
62451                 return ts.createParen(expression);
62452             case 197:
62453                 return !leftmostExpr.arguments
62454                     ? ts.createParen(expression)
62455                     : expression;
62456         }
62457         return parenthesizeForAccess(expression);
62458     }
62459     ts.parenthesizeForNew = parenthesizeForNew;
62460     function parenthesizeForAccess(expression) {
62461         var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
62462         if (ts.isLeftHandSideExpression(emittedExpression)
62463             && (emittedExpression.kind !== 197 || emittedExpression.arguments)) {
62464             return expression;
62465         }
62466         return ts.setTextRange(ts.createParen(expression), expression);
62467     }
62468     ts.parenthesizeForAccess = parenthesizeForAccess;
62469     function parenthesizePostfixOperand(operand) {
62470         return ts.isLeftHandSideExpression(operand)
62471             ? operand
62472             : ts.setTextRange(ts.createParen(operand), operand);
62473     }
62474     ts.parenthesizePostfixOperand = parenthesizePostfixOperand;
62475     function parenthesizePrefixOperand(operand) {
62476         return ts.isUnaryExpression(operand)
62477             ? operand
62478             : ts.setTextRange(ts.createParen(operand), operand);
62479     }
62480     ts.parenthesizePrefixOperand = parenthesizePrefixOperand;
62481     function parenthesizeListElements(elements) {
62482         var result;
62483         for (var i = 0; i < elements.length; i++) {
62484             var element = parenthesizeExpressionForList(elements[i]);
62485             if (result !== undefined || element !== elements[i]) {
62486                 if (result === undefined) {
62487                     result = elements.slice(0, i);
62488                 }
62489                 result.push(element);
62490             }
62491         }
62492         if (result !== undefined) {
62493             return ts.setTextRange(ts.createNodeArray(result, elements.hasTrailingComma), elements);
62494         }
62495         return elements;
62496     }
62497     ts.parenthesizeListElements = parenthesizeListElements;
62498     function parenthesizeExpressionForList(expression) {
62499         var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
62500         var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression);
62501         var commaPrecedence = ts.getOperatorPrecedence(209, 27);
62502         return expressionPrecedence > commaPrecedence
62503             ? expression
62504             : ts.setTextRange(ts.createParen(expression), expression);
62505     }
62506     ts.parenthesizeExpressionForList = parenthesizeExpressionForList;
62507     function parenthesizeExpressionForExpressionStatement(expression) {
62508         var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
62509         if (ts.isCallExpression(emittedExpression)) {
62510             var callee = emittedExpression.expression;
62511             var kind = ts.skipPartiallyEmittedExpressions(callee).kind;
62512             if (kind === 201 || kind === 202) {
62513                 var mutableCall = ts.getMutableClone(emittedExpression);
62514                 mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee);
62515                 return recreateOuterExpressions(expression, mutableCall, 8);
62516             }
62517         }
62518         var leftmostExpressionKind = getLeftmostExpression(emittedExpression, false).kind;
62519         if (leftmostExpressionKind === 193 || leftmostExpressionKind === 201) {
62520             return ts.setTextRange(ts.createParen(expression), expression);
62521         }
62522         return expression;
62523     }
62524     ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement;
62525     function parenthesizeConditionalTypeMember(member) {
62526         return member.kind === 180 ? ts.createParenthesizedType(member) : member;
62527     }
62528     ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember;
62529     function parenthesizeElementTypeMember(member) {
62530         switch (member.kind) {
62531             case 178:
62532             case 179:
62533             case 170:
62534             case 171:
62535                 return ts.createParenthesizedType(member);
62536         }
62537         return parenthesizeConditionalTypeMember(member);
62538     }
62539     ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember;
62540     function parenthesizeArrayTypeMember(member) {
62541         switch (member.kind) {
62542             case 172:
62543             case 184:
62544             case 181:
62545                 return ts.createParenthesizedType(member);
62546         }
62547         return parenthesizeElementTypeMember(member);
62548     }
62549     ts.parenthesizeArrayTypeMember = parenthesizeArrayTypeMember;
62550     function parenthesizeElementTypeMembers(members) {
62551         return ts.createNodeArray(ts.sameMap(members, parenthesizeElementTypeMember));
62552     }
62553     ts.parenthesizeElementTypeMembers = parenthesizeElementTypeMembers;
62554     function parenthesizeTypeParameters(typeParameters) {
62555         if (ts.some(typeParameters)) {
62556             var params = [];
62557             for (var i = 0; i < typeParameters.length; ++i) {
62558                 var entry = typeParameters[i];
62559                 params.push(i === 0 && ts.isFunctionOrConstructorTypeNode(entry) && entry.typeParameters ?
62560                     ts.createParenthesizedType(entry) :
62561                     entry);
62562             }
62563             return ts.createNodeArray(params);
62564         }
62565     }
62566     ts.parenthesizeTypeParameters = parenthesizeTypeParameters;
62567     function getLeftmostExpression(node, stopAtCallExpressions) {
62568         while (true) {
62569             switch (node.kind) {
62570                 case 208:
62571                     node = node.operand;
62572                     continue;
62573                 case 209:
62574                     node = node.left;
62575                     continue;
62576                 case 210:
62577                     node = node.condition;
62578                     continue;
62579                 case 198:
62580                     node = node.tag;
62581                     continue;
62582                 case 196:
62583                     if (stopAtCallExpressions) {
62584                         return node;
62585                     }
62586                 case 217:
62587                 case 195:
62588                 case 194:
62589                 case 218:
62590                 case 326:
62591                     node = node.expression;
62592                     continue;
62593             }
62594             return node;
62595         }
62596     }
62597     ts.getLeftmostExpression = getLeftmostExpression;
62598     function parenthesizeConciseBody(body) {
62599         if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, false).kind === 193)) {
62600             return ts.setTextRange(ts.createParen(body), body);
62601         }
62602         return body;
62603     }
62604     ts.parenthesizeConciseBody = parenthesizeConciseBody;
62605     function isCommaSequence(node) {
62606         return node.kind === 209 && node.operatorToken.kind === 27 ||
62607             node.kind === 327;
62608     }
62609     ts.isCommaSequence = isCommaSequence;
62610     function isOuterExpression(node, kinds) {
62611         if (kinds === void 0) { kinds = 15; }
62612         switch (node.kind) {
62613             case 200:
62614                 return (kinds & 1) !== 0;
62615             case 199:
62616             case 217:
62617                 return (kinds & 2) !== 0;
62618             case 218:
62619                 return (kinds & 4) !== 0;
62620             case 326:
62621                 return (kinds & 8) !== 0;
62622         }
62623         return false;
62624     }
62625     ts.isOuterExpression = isOuterExpression;
62626     function skipOuterExpressions(node, kinds) {
62627         if (kinds === void 0) { kinds = 15; }
62628         while (isOuterExpression(node, kinds)) {
62629             node = node.expression;
62630         }
62631         return node;
62632     }
62633     ts.skipOuterExpressions = skipOuterExpressions;
62634     function skipAssertions(node) {
62635         return skipOuterExpressions(node, 6);
62636     }
62637     ts.skipAssertions = skipAssertions;
62638     function updateOuterExpression(outerExpression, expression) {
62639         switch (outerExpression.kind) {
62640             case 200: return ts.updateParen(outerExpression, expression);
62641             case 199: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression);
62642             case 217: return ts.updateAsExpression(outerExpression, expression, outerExpression.type);
62643             case 218: return ts.updateNonNullExpression(outerExpression, expression);
62644             case 326: return ts.updatePartiallyEmittedExpression(outerExpression, expression);
62645         }
62646     }
62647     function isIgnorableParen(node) {
62648         return node.kind === 200
62649             && ts.nodeIsSynthesized(node)
62650             && ts.nodeIsSynthesized(ts.getSourceMapRange(node))
62651             && ts.nodeIsSynthesized(ts.getCommentRange(node))
62652             && !ts.some(ts.getSyntheticLeadingComments(node))
62653             && !ts.some(ts.getSyntheticTrailingComments(node));
62654     }
62655     function recreateOuterExpressions(outerExpression, innerExpression, kinds) {
62656         if (kinds === void 0) { kinds = 15; }
62657         if (outerExpression && isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) {
62658             return updateOuterExpression(outerExpression, recreateOuterExpressions(outerExpression.expression, innerExpression));
62659         }
62660         return innerExpression;
62661     }
62662     ts.recreateOuterExpressions = recreateOuterExpressions;
62663     function startOnNewLine(node) {
62664         return ts.setStartsOnNewLine(node, true);
62665     }
62666     ts.startOnNewLine = startOnNewLine;
62667     function getExternalHelpersModuleName(node) {
62668         var parseNode = ts.getOriginalNode(node, ts.isSourceFile);
62669         var emitNode = parseNode && parseNode.emitNode;
62670         return emitNode && emitNode.externalHelpersModuleName;
62671     }
62672     ts.getExternalHelpersModuleName = getExternalHelpersModuleName;
62673     function hasRecordedExternalHelpers(sourceFile) {
62674         var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile);
62675         var emitNode = parseNode && parseNode.emitNode;
62676         return !!emitNode && (!!emitNode.externalHelpersModuleName || !!emitNode.externalHelpers);
62677     }
62678     ts.hasRecordedExternalHelpers = hasRecordedExternalHelpers;
62679     function createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault) {
62680         if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
62681             var namedBindings = void 0;
62682             var moduleKind = ts.getEmitModuleKind(compilerOptions);
62683             if (moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) {
62684                 var helpers = ts.getEmitHelpers(sourceFile);
62685                 if (helpers) {
62686                     var helperNames = [];
62687                     for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) {
62688                         var helper = helpers_2[_i];
62689                         if (!helper.scoped) {
62690                             var importName = helper.importName;
62691                             if (importName) {
62692                                 ts.pushIfUnique(helperNames, importName);
62693                             }
62694                         }
62695                     }
62696                     if (ts.some(helperNames)) {
62697                         helperNames.sort(ts.compareStringsCaseSensitive);
62698                         namedBindings = ts.createNamedImports(ts.map(helperNames, function (name) { return ts.isFileLevelUniqueName(sourceFile, name)
62699                             ? ts.createImportSpecifier(undefined, ts.createIdentifier(name))
62700                             : ts.createImportSpecifier(ts.createIdentifier(name), getUnscopedHelperName(name)); }));
62701                         var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile);
62702                         var emitNode = ts.getOrCreateEmitNode(parseNode);
62703                         emitNode.externalHelpers = true;
62704                     }
62705                 }
62706             }
62707             else {
62708                 var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar || hasImportDefault);
62709                 if (externalHelpersModuleName) {
62710                     namedBindings = ts.createNamespaceImport(externalHelpersModuleName);
62711                 }
62712             }
62713             if (namedBindings) {
62714                 var externalHelpersImportDeclaration = ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, namedBindings), ts.createLiteral(ts.externalHelpersModuleNameText));
62715                 ts.addEmitFlags(externalHelpersImportDeclaration, 67108864);
62716                 return externalHelpersImportDeclaration;
62717             }
62718         }
62719     }
62720     ts.createExternalHelpersImportDeclarationIfNeeded = createExternalHelpersImportDeclarationIfNeeded;
62721     function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault) {
62722         if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(node, compilerOptions)) {
62723             var externalHelpersModuleName = getExternalHelpersModuleName(node);
62724             if (externalHelpersModuleName) {
62725                 return externalHelpersModuleName;
62726             }
62727             var moduleKind = ts.getEmitModuleKind(compilerOptions);
62728             var create = (hasExportStarsToExportValues || (compilerOptions.esModuleInterop && hasImportStarOrImportDefault))
62729                 && moduleKind !== ts.ModuleKind.System
62730                 && moduleKind < ts.ModuleKind.ES2015;
62731             if (!create) {
62732                 var helpers = ts.getEmitHelpers(node);
62733                 if (helpers) {
62734                     for (var _i = 0, helpers_3 = helpers; _i < helpers_3.length; _i++) {
62735                         var helper = helpers_3[_i];
62736                         if (!helper.scoped) {
62737                             create = true;
62738                             break;
62739                         }
62740                     }
62741                 }
62742             }
62743             if (create) {
62744                 var parseNode = ts.getOriginalNode(node, ts.isSourceFile);
62745                 var emitNode = ts.getOrCreateEmitNode(parseNode);
62746                 return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = ts.createUniqueName(ts.externalHelpersModuleNameText));
62747             }
62748         }
62749     }
62750     ts.getOrCreateExternalHelpersModuleNameIfNeeded = getOrCreateExternalHelpersModuleNameIfNeeded;
62751     function getLocalNameForExternalImport(node, sourceFile) {
62752         var namespaceDeclaration = ts.getNamespaceDeclarationNode(node);
62753         if (namespaceDeclaration && !ts.isDefaultImport(node)) {
62754             var name = namespaceDeclaration.name;
62755             return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name));
62756         }
62757         if (node.kind === 254 && node.importClause) {
62758             return ts.getGeneratedNameForNode(node);
62759         }
62760         if (node.kind === 260 && node.moduleSpecifier) {
62761             return ts.getGeneratedNameForNode(node);
62762         }
62763         return undefined;
62764     }
62765     ts.getLocalNameForExternalImport = getLocalNameForExternalImport;
62766     function getExternalModuleNameLiteral(importNode, sourceFile, host, resolver, compilerOptions) {
62767         var moduleName = ts.getExternalModuleName(importNode);
62768         if (moduleName.kind === 10) {
62769             return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions)
62770                 || tryRenameExternalModule(moduleName, sourceFile)
62771                 || ts.getSynthesizedClone(moduleName);
62772         }
62773         return undefined;
62774     }
62775     ts.getExternalModuleNameLiteral = getExternalModuleNameLiteral;
62776     function tryRenameExternalModule(moduleName, sourceFile) {
62777         var rename = sourceFile.renamedDependencies && sourceFile.renamedDependencies.get(moduleName.text);
62778         return rename && ts.createLiteral(rename);
62779     }
62780     function tryGetModuleNameFromFile(file, host, options) {
62781         if (!file) {
62782             return undefined;
62783         }
62784         if (file.moduleName) {
62785             return ts.createLiteral(file.moduleName);
62786         }
62787         if (!file.isDeclarationFile && (options.out || options.outFile)) {
62788             return ts.createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName));
62789         }
62790         return undefined;
62791     }
62792     ts.tryGetModuleNameFromFile = tryGetModuleNameFromFile;
62793     function tryGetModuleNameFromDeclaration(declaration, host, resolver, compilerOptions) {
62794         return tryGetModuleNameFromFile(resolver.getExternalModuleFileFromDeclaration(declaration), host, compilerOptions);
62795     }
62796     function getInitializerOfBindingOrAssignmentElement(bindingElement) {
62797         if (ts.isDeclarationBindingElement(bindingElement)) {
62798             return bindingElement.initializer;
62799         }
62800         if (ts.isPropertyAssignment(bindingElement)) {
62801             var initializer = bindingElement.initializer;
62802             return ts.isAssignmentExpression(initializer, true)
62803                 ? initializer.right
62804                 : undefined;
62805         }
62806         if (ts.isShorthandPropertyAssignment(bindingElement)) {
62807             return bindingElement.objectAssignmentInitializer;
62808         }
62809         if (ts.isAssignmentExpression(bindingElement, true)) {
62810             return bindingElement.right;
62811         }
62812         if (ts.isSpreadElement(bindingElement)) {
62813             return getInitializerOfBindingOrAssignmentElement(bindingElement.expression);
62814         }
62815     }
62816     ts.getInitializerOfBindingOrAssignmentElement = getInitializerOfBindingOrAssignmentElement;
62817     function getTargetOfBindingOrAssignmentElement(bindingElement) {
62818         if (ts.isDeclarationBindingElement(bindingElement)) {
62819             return bindingElement.name;
62820         }
62821         if (ts.isObjectLiteralElementLike(bindingElement)) {
62822             switch (bindingElement.kind) {
62823                 case 281:
62824                     return getTargetOfBindingOrAssignmentElement(bindingElement.initializer);
62825                 case 282:
62826                     return bindingElement.name;
62827                 case 283:
62828                     return getTargetOfBindingOrAssignmentElement(bindingElement.expression);
62829             }
62830             return undefined;
62831         }
62832         if (ts.isAssignmentExpression(bindingElement, true)) {
62833             return getTargetOfBindingOrAssignmentElement(bindingElement.left);
62834         }
62835         if (ts.isSpreadElement(bindingElement)) {
62836             return getTargetOfBindingOrAssignmentElement(bindingElement.expression);
62837         }
62838         return bindingElement;
62839     }
62840     ts.getTargetOfBindingOrAssignmentElement = getTargetOfBindingOrAssignmentElement;
62841     function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) {
62842         switch (bindingElement.kind) {
62843             case 156:
62844             case 191:
62845                 return bindingElement.dotDotDotToken;
62846             case 213:
62847             case 283:
62848                 return bindingElement;
62849         }
62850         return undefined;
62851     }
62852     ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement;
62853     function getPropertyNameOfBindingOrAssignmentElement(bindingElement) {
62854         var propertyName = tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement);
62855         ts.Debug.assert(!!propertyName || ts.isSpreadAssignment(bindingElement), "Invalid property name for binding element.");
62856         return propertyName;
62857     }
62858     ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement;
62859     function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) {
62860         switch (bindingElement.kind) {
62861             case 191:
62862                 if (bindingElement.propertyName) {
62863                     var propertyName = bindingElement.propertyName;
62864                     if (ts.isPrivateIdentifier(propertyName)) {
62865                         return ts.Debug.failBadSyntaxKind(propertyName);
62866                     }
62867                     return ts.isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression)
62868                         ? propertyName.expression
62869                         : propertyName;
62870                 }
62871                 break;
62872             case 281:
62873                 if (bindingElement.name) {
62874                     var propertyName = bindingElement.name;
62875                     if (ts.isPrivateIdentifier(propertyName)) {
62876                         return ts.Debug.failBadSyntaxKind(propertyName);
62877                     }
62878                     return ts.isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression)
62879                         ? propertyName.expression
62880                         : propertyName;
62881                 }
62882                 break;
62883             case 283:
62884                 if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) {
62885                     return ts.Debug.failBadSyntaxKind(bindingElement.name);
62886                 }
62887                 return bindingElement.name;
62888         }
62889         var target = getTargetOfBindingOrAssignmentElement(bindingElement);
62890         if (target && ts.isPropertyName(target)) {
62891             return target;
62892         }
62893     }
62894     ts.tryGetPropertyNameOfBindingOrAssignmentElement = tryGetPropertyNameOfBindingOrAssignmentElement;
62895     function isStringOrNumericLiteral(node) {
62896         var kind = node.kind;
62897         return kind === 10
62898             || kind === 8;
62899     }
62900     function getElementsOfBindingOrAssignmentPattern(name) {
62901         switch (name.kind) {
62902             case 189:
62903             case 190:
62904             case 192:
62905                 return name.elements;
62906             case 193:
62907                 return name.properties;
62908         }
62909     }
62910     ts.getElementsOfBindingOrAssignmentPattern = getElementsOfBindingOrAssignmentPattern;
62911     function convertToArrayAssignmentElement(element) {
62912         if (ts.isBindingElement(element)) {
62913             if (element.dotDotDotToken) {
62914                 ts.Debug.assertNode(element.name, ts.isIdentifier);
62915                 return ts.setOriginalNode(ts.setTextRange(ts.createSpread(element.name), element), element);
62916             }
62917             var expression = convertToAssignmentElementTarget(element.name);
62918             return element.initializer
62919                 ? ts.setOriginalNode(ts.setTextRange(ts.createAssignment(expression, element.initializer), element), element)
62920                 : expression;
62921         }
62922         ts.Debug.assertNode(element, ts.isExpression);
62923         return element;
62924     }
62925     ts.convertToArrayAssignmentElement = convertToArrayAssignmentElement;
62926     function convertToObjectAssignmentElement(element) {
62927         if (ts.isBindingElement(element)) {
62928             if (element.dotDotDotToken) {
62929                 ts.Debug.assertNode(element.name, ts.isIdentifier);
62930                 return ts.setOriginalNode(ts.setTextRange(ts.createSpreadAssignment(element.name), element), element);
62931             }
62932             if (element.propertyName) {
62933                 var expression = convertToAssignmentElementTarget(element.name);
62934                 return ts.setOriginalNode(ts.setTextRange(ts.createPropertyAssignment(element.propertyName, element.initializer ? ts.createAssignment(expression, element.initializer) : expression), element), element);
62935             }
62936             ts.Debug.assertNode(element.name, ts.isIdentifier);
62937             return ts.setOriginalNode(ts.setTextRange(ts.createShorthandPropertyAssignment(element.name, element.initializer), element), element);
62938         }
62939         ts.Debug.assertNode(element, ts.isObjectLiteralElementLike);
62940         return element;
62941     }
62942     ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement;
62943     function convertToAssignmentPattern(node) {
62944         switch (node.kind) {
62945             case 190:
62946             case 192:
62947                 return convertToArrayAssignmentPattern(node);
62948             case 189:
62949             case 193:
62950                 return convertToObjectAssignmentPattern(node);
62951         }
62952     }
62953     ts.convertToAssignmentPattern = convertToAssignmentPattern;
62954     function convertToObjectAssignmentPattern(node) {
62955         if (ts.isObjectBindingPattern(node)) {
62956             return ts.setOriginalNode(ts.setTextRange(ts.createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement)), node), node);
62957         }
62958         ts.Debug.assertNode(node, ts.isObjectLiteralExpression);
62959         return node;
62960     }
62961     ts.convertToObjectAssignmentPattern = convertToObjectAssignmentPattern;
62962     function convertToArrayAssignmentPattern(node) {
62963         if (ts.isArrayBindingPattern(node)) {
62964             return ts.setOriginalNode(ts.setTextRange(ts.createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement)), node), node);
62965         }
62966         ts.Debug.assertNode(node, ts.isArrayLiteralExpression);
62967         return node;
62968     }
62969     ts.convertToArrayAssignmentPattern = convertToArrayAssignmentPattern;
62970     function convertToAssignmentElementTarget(node) {
62971         if (ts.isBindingPattern(node)) {
62972             return convertToAssignmentPattern(node);
62973         }
62974         ts.Debug.assertNode(node, ts.isExpression);
62975         return node;
62976     }
62977     ts.convertToAssignmentElementTarget = convertToAssignmentElementTarget;
62978 })(ts || (ts = {}));
62979 var ts;
62980 (function (ts) {
62981     var isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration);
62982     function visitNode(node, visitor, test, lift) {
62983         if (node === undefined || visitor === undefined) {
62984             return node;
62985         }
62986         ts.aggregateTransformFlags(node);
62987         var visited = visitor(node);
62988         if (visited === node) {
62989             return node;
62990         }
62991         var visitedNode;
62992         if (visited === undefined) {
62993             return undefined;
62994         }
62995         else if (ts.isArray(visited)) {
62996             visitedNode = (lift || extractSingleNode)(visited);
62997         }
62998         else {
62999             visitedNode = visited;
63000         }
63001         ts.Debug.assertNode(visitedNode, test);
63002         ts.aggregateTransformFlags(visitedNode);
63003         return visitedNode;
63004     }
63005     ts.visitNode = visitNode;
63006     function visitNodes(nodes, visitor, test, start, count) {
63007         if (nodes === undefined || visitor === undefined) {
63008             return nodes;
63009         }
63010         var updated;
63011         var length = nodes.length;
63012         if (start === undefined || start < 0) {
63013             start = 0;
63014         }
63015         if (count === undefined || count > length - start) {
63016             count = length - start;
63017         }
63018         if (start > 0 || count < length) {
63019             updated = ts.createNodeArray([], nodes.hasTrailingComma && start + count === length);
63020         }
63021         for (var i = 0; i < count; i++) {
63022             var node = nodes[i + start];
63023             ts.aggregateTransformFlags(node);
63024             var visited = node !== undefined ? visitor(node) : undefined;
63025             if (updated !== undefined || visited === undefined || visited !== node) {
63026                 if (updated === undefined) {
63027                     updated = ts.createNodeArray(nodes.slice(0, i), nodes.hasTrailingComma);
63028                     ts.setTextRange(updated, nodes);
63029                 }
63030                 if (visited) {
63031                     if (ts.isArray(visited)) {
63032                         for (var _i = 0, visited_1 = visited; _i < visited_1.length; _i++) {
63033                             var visitedNode = visited_1[_i];
63034                             ts.Debug.assertNode(visitedNode, test);
63035                             ts.aggregateTransformFlags(visitedNode);
63036                             updated.push(visitedNode);
63037                         }
63038                     }
63039                     else {
63040                         ts.Debug.assertNode(visited, test);
63041                         ts.aggregateTransformFlags(visited);
63042                         updated.push(visited);
63043                     }
63044                 }
63045             }
63046         }
63047         return updated || nodes;
63048     }
63049     ts.visitNodes = visitNodes;
63050     function visitLexicalEnvironment(statements, visitor, context, start, ensureUseStrict) {
63051         context.startLexicalEnvironment();
63052         statements = visitNodes(statements, visitor, ts.isStatement, start);
63053         if (ensureUseStrict)
63054             statements = ts.ensureUseStrict(statements);
63055         return ts.mergeLexicalEnvironment(statements, context.endLexicalEnvironment());
63056     }
63057     ts.visitLexicalEnvironment = visitLexicalEnvironment;
63058     function visitParameterList(nodes, visitor, context, nodesVisitor) {
63059         if (nodesVisitor === void 0) { nodesVisitor = visitNodes; }
63060         var updated;
63061         context.startLexicalEnvironment();
63062         if (nodes) {
63063             context.setLexicalEnvironmentFlags(1, true);
63064             updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration);
63065             if (context.getLexicalEnvironmentFlags() & 2 &&
63066                 ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2) {
63067                 updated = addDefaultValueAssignmentsIfNeeded(updated, context);
63068             }
63069             context.setLexicalEnvironmentFlags(1, false);
63070         }
63071         context.suspendLexicalEnvironment();
63072         return updated;
63073     }
63074     ts.visitParameterList = visitParameterList;
63075     function addDefaultValueAssignmentsIfNeeded(parameters, context) {
63076         var result;
63077         for (var i = 0; i < parameters.length; i++) {
63078             var parameter = parameters[i];
63079             var updated = addDefaultValueAssignmentIfNeeded(parameter, context);
63080             if (result || updated !== parameter) {
63081                 if (!result)
63082                     result = parameters.slice(0, i);
63083                 result[i] = updated;
63084             }
63085         }
63086         if (result) {
63087             return ts.setTextRange(ts.createNodeArray(result, parameters.hasTrailingComma), parameters);
63088         }
63089         return parameters;
63090     }
63091     function addDefaultValueAssignmentIfNeeded(parameter, context) {
63092         return parameter.dotDotDotToken ? parameter :
63093             ts.isBindingPattern(parameter.name) ? addDefaultValueAssignmentForBindingPattern(parameter, context) :
63094                 parameter.initializer ? addDefaultValueAssignmentForInitializer(parameter, parameter.name, parameter.initializer, context) :
63095                     parameter;
63096     }
63097     function addDefaultValueAssignmentForBindingPattern(parameter, context) {
63098         context.addInitializationStatement(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
63099             ts.createVariableDeclaration(parameter.name, parameter.type, parameter.initializer ?
63100                 ts.createConditional(ts.createStrictEquality(ts.getGeneratedNameForNode(parameter), ts.createVoidZero()), parameter.initializer, ts.getGeneratedNameForNode(parameter)) :
63101                 ts.getGeneratedNameForNode(parameter)),
63102         ])));
63103         return ts.updateParameter(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, ts.getGeneratedNameForNode(parameter), parameter.questionToken, parameter.type, undefined);
63104     }
63105     function addDefaultValueAssignmentForInitializer(parameter, name, initializer, context) {
63106         context.addInitializationStatement(ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([
63107             ts.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer) | 1536)), parameter), 1536))
63108         ]), parameter), 1 | 32 | 384 | 1536)));
63109         return ts.updateParameter(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, parameter.name, parameter.questionToken, parameter.type, undefined);
63110     }
63111     function visitFunctionBody(node, visitor, context) {
63112         context.resumeLexicalEnvironment();
63113         var updated = visitNode(node, visitor, ts.isConciseBody);
63114         var declarations = context.endLexicalEnvironment();
63115         if (ts.some(declarations)) {
63116             var block = ts.convertToFunctionBody(updated);
63117             var statements = ts.mergeLexicalEnvironment(block.statements, declarations);
63118             return ts.updateBlock(block, statements);
63119         }
63120         return updated;
63121     }
63122     ts.visitFunctionBody = visitFunctionBody;
63123     function visitEachChild(node, visitor, context, nodesVisitor, tokenVisitor) {
63124         if (nodesVisitor === void 0) { nodesVisitor = visitNodes; }
63125         if (node === undefined) {
63126             return undefined;
63127         }
63128         var kind = node.kind;
63129         if ((kind > 0 && kind <= 152) || kind === 183) {
63130             return node;
63131         }
63132         switch (kind) {
63133             case 75:
63134                 return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration));
63135             case 153:
63136                 return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier));
63137             case 154:
63138                 return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression));
63139             case 155:
63140                 return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode));
63141             case 156:
63142                 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));
63143             case 157:
63144                 return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression));
63145             case 158:
63146                 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));
63147             case 159:
63148                 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));
63149             case 160:
63150                 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));
63151             case 161:
63152                 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));
63153             case 162:
63154                 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));
63155             case 163:
63156                 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));
63157             case 164:
63158                 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));
63159             case 165:
63160                 return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode));
63161             case 166:
63162                 return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode));
63163             case 167:
63164                 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));
63165             case 168:
63166                 return ts.updateTypePredicateNodeWithModifier(node, visitNode(node.assertsModifier, visitor), visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode));
63167             case 169:
63168                 return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode));
63169             case 170:
63170                 return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode));
63171             case 171:
63172                 return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode));
63173             case 172:
63174                 return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName));
63175             case 173:
63176                 return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement));
63177             case 174:
63178                 return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode));
63179             case 175:
63180                 return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode));
63181             case 176:
63182                 return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode));
63183             case 177:
63184                 return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode));
63185             case 178:
63186                 return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode));
63187             case 179:
63188                 return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode));
63189             case 180:
63190                 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));
63191             case 181:
63192                 return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration));
63193             case 188:
63194                 return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf);
63195             case 182:
63196                 return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode));
63197             case 184:
63198                 return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode));
63199             case 185:
63200                 return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode));
63201             case 186:
63202                 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));
63203             case 187:
63204                 return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression));
63205             case 189:
63206                 return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement));
63207             case 190:
63208                 return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement));
63209             case 191:
63210                 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));
63211             case 192:
63212                 return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression));
63213             case 193:
63214                 return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike));
63215             case 194:
63216                 if (node.flags & 32) {
63217                     return ts.updatePropertyAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier));
63218                 }
63219                 return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifierOrPrivateIdentifier));
63220             case 195:
63221                 if (node.flags & 32) {
63222                     return ts.updateElementAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, tokenVisitor, ts.isToken), visitNode(node.argumentExpression, visitor, ts.isExpression));
63223                 }
63224                 return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression));
63225             case 196:
63226                 if (node.flags & 32) {
63227                     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));
63228                 }
63229                 return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
63230             case 197:
63231                 return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
63232             case 198:
63233                 return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral));
63234             case 199:
63235                 return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression));
63236             case 200:
63237                 return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression));
63238             case 201:
63239                 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));
63240             case 202:
63241                 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));
63242             case 203:
63243                 return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression));
63244             case 204:
63245                 return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression));
63246             case 205:
63247                 return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression));
63248             case 206:
63249                 return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression));
63250             case 207:
63251                 return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression));
63252             case 208:
63253                 return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression));
63254             case 209:
63255                 return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, tokenVisitor, ts.isToken));
63256             case 210:
63257                 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));
63258             case 211:
63259                 return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan));
63260             case 212:
63261                 return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression));
63262             case 213:
63263                 return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression));
63264             case 214:
63265                 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));
63266             case 216:
63267                 return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression));
63268             case 217:
63269                 return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode));
63270             case 218:
63271                 return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression));
63272             case 219:
63273                 return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier));
63274             case 221:
63275                 return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail));
63276             case 223:
63277                 return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement));
63278             case 225:
63279                 return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList));
63280             case 226:
63281                 return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression));
63282             case 227:
63283                 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));
63284             case 228:
63285                 return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression));
63286             case 229:
63287                 return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
63288             case 230:
63289                 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));
63290             case 231:
63291                 return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
63292             case 232:
63293                 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));
63294             case 233:
63295                 return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier));
63296             case 234:
63297                 return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier));
63298             case 235:
63299                 return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression));
63300             case 236:
63301                 return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
63302             case 237:
63303                 return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock));
63304             case 238:
63305                 return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
63306             case 239:
63307                 return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression));
63308             case 240:
63309                 return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock));
63310             case 242:
63311                 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));
63312             case 243:
63313                 return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration));
63314             case 244:
63315                 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));
63316             case 245:
63317                 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));
63318             case 246:
63319                 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));
63320             case 247:
63321                 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));
63322             case 248:
63323                 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));
63324             case 249:
63325                 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));
63326             case 250:
63327                 return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement));
63328             case 251:
63329                 return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause));
63330             case 252:
63331                 return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier));
63332             case 253:
63333                 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));
63334             case 254:
63335                 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));
63336             case 255:
63337                 return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings), node.isTypeOnly);
63338             case 256:
63339                 return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier));
63340             case 262:
63341                 return ts.updateNamespaceExport(node, visitNode(node.name, visitor, ts.isIdentifier));
63342             case 257:
63343                 return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier));
63344             case 258:
63345                 return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier));
63346             case 259:
63347                 return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression));
63348             case 260:
63349                 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);
63350             case 261:
63351                 return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier));
63352             case 263:
63353                 return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier));
63354             case 265:
63355                 return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression));
63356             case 266:
63357                 return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement));
63358             case 267:
63359                 return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes));
63360             case 268:
63361                 return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes));
63362             case 269:
63363                 return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression));
63364             case 270:
63365                 return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment));
63366             case 273:
63367                 return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression));
63368             case 274:
63369                 return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike));
63370             case 275:
63371                 return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression));
63372             case 276:
63373                 return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression));
63374             case 277:
63375                 return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement));
63376             case 278:
63377                 return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement));
63378             case 279:
63379                 return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments));
63380             case 280:
63381                 return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock));
63382             case 281:
63383                 return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression));
63384             case 282:
63385                 return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression));
63386             case 283:
63387                 return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression));
63388             case 284:
63389                 return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression));
63390             case 290:
63391                 return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context));
63392             case 326:
63393                 return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression));
63394             case 327:
63395                 return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression));
63396             default:
63397                 return node;
63398         }
63399     }
63400     ts.visitEachChild = visitEachChild;
63401     function extractSingleNode(nodes) {
63402         ts.Debug.assert(nodes.length <= 1, "Too many nodes written to output.");
63403         return ts.singleOrUndefined(nodes);
63404     }
63405 })(ts || (ts = {}));
63406 var ts;
63407 (function (ts) {
63408     function reduceNode(node, f, initial) {
63409         return node ? f(initial, node) : initial;
63410     }
63411     function reduceNodeArray(nodes, f, initial) {
63412         return nodes ? f(initial, nodes) : initial;
63413     }
63414     function reduceEachChild(node, initial, cbNode, cbNodeArray) {
63415         if (node === undefined) {
63416             return initial;
63417         }
63418         var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft;
63419         var cbNodes = cbNodeArray || cbNode;
63420         var kind = node.kind;
63421         if ((kind > 0 && kind <= 152)) {
63422             return initial;
63423         }
63424         if ((kind >= 168 && kind <= 187)) {
63425             return initial;
63426         }
63427         var result = initial;
63428         switch (node.kind) {
63429             case 222:
63430             case 224:
63431             case 215:
63432             case 241:
63433             case 325:
63434                 break;
63435             case 153:
63436                 result = reduceNode(node.left, cbNode, result);
63437                 result = reduceNode(node.right, cbNode, result);
63438                 break;
63439             case 154:
63440                 result = reduceNode(node.expression, cbNode, result);
63441                 break;
63442             case 156:
63443                 result = reduceNodes(node.decorators, cbNodes, result);
63444                 result = reduceNodes(node.modifiers, cbNodes, result);
63445                 result = reduceNode(node.name, cbNode, result);
63446                 result = reduceNode(node.type, cbNode, result);
63447                 result = reduceNode(node.initializer, cbNode, result);
63448                 break;
63449             case 157:
63450                 result = reduceNode(node.expression, cbNode, result);
63451                 break;
63452             case 158:
63453                 result = reduceNodes(node.modifiers, cbNodes, result);
63454                 result = reduceNode(node.name, cbNode, result);
63455                 result = reduceNode(node.questionToken, cbNode, result);
63456                 result = reduceNode(node.type, cbNode, result);
63457                 result = reduceNode(node.initializer, cbNode, result);
63458                 break;
63459             case 159:
63460                 result = reduceNodes(node.decorators, cbNodes, result);
63461                 result = reduceNodes(node.modifiers, cbNodes, result);
63462                 result = reduceNode(node.name, cbNode, result);
63463                 result = reduceNode(node.type, cbNode, result);
63464                 result = reduceNode(node.initializer, cbNode, result);
63465                 break;
63466             case 161:
63467                 result = reduceNodes(node.decorators, cbNodes, result);
63468                 result = reduceNodes(node.modifiers, cbNodes, result);
63469                 result = reduceNode(node.name, cbNode, result);
63470                 result = reduceNodes(node.typeParameters, cbNodes, result);
63471                 result = reduceNodes(node.parameters, cbNodes, result);
63472                 result = reduceNode(node.type, cbNode, result);
63473                 result = reduceNode(node.body, cbNode, result);
63474                 break;
63475             case 162:
63476                 result = reduceNodes(node.modifiers, cbNodes, result);
63477                 result = reduceNodes(node.parameters, cbNodes, result);
63478                 result = reduceNode(node.body, cbNode, result);
63479                 break;
63480             case 163:
63481                 result = reduceNodes(node.decorators, cbNodes, result);
63482                 result = reduceNodes(node.modifiers, cbNodes, result);
63483                 result = reduceNode(node.name, cbNode, result);
63484                 result = reduceNodes(node.parameters, cbNodes, result);
63485                 result = reduceNode(node.type, cbNode, result);
63486                 result = reduceNode(node.body, cbNode, result);
63487                 break;
63488             case 164:
63489                 result = reduceNodes(node.decorators, cbNodes, result);
63490                 result = reduceNodes(node.modifiers, cbNodes, result);
63491                 result = reduceNode(node.name, cbNode, result);
63492                 result = reduceNodes(node.parameters, cbNodes, result);
63493                 result = reduceNode(node.body, cbNode, result);
63494                 break;
63495             case 189:
63496             case 190:
63497                 result = reduceNodes(node.elements, cbNodes, result);
63498                 break;
63499             case 191:
63500                 result = reduceNode(node.propertyName, cbNode, result);
63501                 result = reduceNode(node.name, cbNode, result);
63502                 result = reduceNode(node.initializer, cbNode, result);
63503                 break;
63504             case 192:
63505                 result = reduceNodes(node.elements, cbNodes, result);
63506                 break;
63507             case 193:
63508                 result = reduceNodes(node.properties, cbNodes, result);
63509                 break;
63510             case 194:
63511                 result = reduceNode(node.expression, cbNode, result);
63512                 result = reduceNode(node.name, cbNode, result);
63513                 break;
63514             case 195:
63515                 result = reduceNode(node.expression, cbNode, result);
63516                 result = reduceNode(node.argumentExpression, cbNode, result);
63517                 break;
63518             case 196:
63519                 result = reduceNode(node.expression, cbNode, result);
63520                 result = reduceNodes(node.typeArguments, cbNodes, result);
63521                 result = reduceNodes(node.arguments, cbNodes, result);
63522                 break;
63523             case 197:
63524                 result = reduceNode(node.expression, cbNode, result);
63525                 result = reduceNodes(node.typeArguments, cbNodes, result);
63526                 result = reduceNodes(node.arguments, cbNodes, result);
63527                 break;
63528             case 198:
63529                 result = reduceNode(node.tag, cbNode, result);
63530                 result = reduceNodes(node.typeArguments, cbNodes, result);
63531                 result = reduceNode(node.template, cbNode, result);
63532                 break;
63533             case 199:
63534                 result = reduceNode(node.type, cbNode, result);
63535                 result = reduceNode(node.expression, cbNode, result);
63536                 break;
63537             case 201:
63538                 result = reduceNodes(node.modifiers, cbNodes, result);
63539                 result = reduceNode(node.name, cbNode, result);
63540                 result = reduceNodes(node.typeParameters, cbNodes, result);
63541                 result = reduceNodes(node.parameters, cbNodes, result);
63542                 result = reduceNode(node.type, cbNode, result);
63543                 result = reduceNode(node.body, cbNode, result);
63544                 break;
63545             case 202:
63546                 result = reduceNodes(node.modifiers, cbNodes, result);
63547                 result = reduceNodes(node.typeParameters, cbNodes, result);
63548                 result = reduceNodes(node.parameters, cbNodes, result);
63549                 result = reduceNode(node.type, cbNode, result);
63550                 result = reduceNode(node.body, cbNode, result);
63551                 break;
63552             case 200:
63553             case 203:
63554             case 204:
63555             case 205:
63556             case 206:
63557             case 212:
63558             case 213:
63559             case 218:
63560                 result = reduceNode(node.expression, cbNode, result);
63561                 break;
63562             case 207:
63563             case 208:
63564                 result = reduceNode(node.operand, cbNode, result);
63565                 break;
63566             case 209:
63567                 result = reduceNode(node.left, cbNode, result);
63568                 result = reduceNode(node.right, cbNode, result);
63569                 break;
63570             case 210:
63571                 result = reduceNode(node.condition, cbNode, result);
63572                 result = reduceNode(node.whenTrue, cbNode, result);
63573                 result = reduceNode(node.whenFalse, cbNode, result);
63574                 break;
63575             case 211:
63576                 result = reduceNode(node.head, cbNode, result);
63577                 result = reduceNodes(node.templateSpans, cbNodes, result);
63578                 break;
63579             case 214:
63580                 result = reduceNodes(node.modifiers, cbNodes, result);
63581                 result = reduceNode(node.name, cbNode, result);
63582                 result = reduceNodes(node.typeParameters, cbNodes, result);
63583                 result = reduceNodes(node.heritageClauses, cbNodes, result);
63584                 result = reduceNodes(node.members, cbNodes, result);
63585                 break;
63586             case 216:
63587                 result = reduceNode(node.expression, cbNode, result);
63588                 result = reduceNodes(node.typeArguments, cbNodes, result);
63589                 break;
63590             case 217:
63591                 result = reduceNode(node.expression, cbNode, result);
63592                 result = reduceNode(node.type, cbNode, result);
63593                 break;
63594             case 221:
63595                 result = reduceNode(node.expression, cbNode, result);
63596                 result = reduceNode(node.literal, cbNode, result);
63597                 break;
63598             case 223:
63599                 result = reduceNodes(node.statements, cbNodes, result);
63600                 break;
63601             case 225:
63602                 result = reduceNodes(node.modifiers, cbNodes, result);
63603                 result = reduceNode(node.declarationList, cbNode, result);
63604                 break;
63605             case 226:
63606                 result = reduceNode(node.expression, cbNode, result);
63607                 break;
63608             case 227:
63609                 result = reduceNode(node.expression, cbNode, result);
63610                 result = reduceNode(node.thenStatement, cbNode, result);
63611                 result = reduceNode(node.elseStatement, cbNode, result);
63612                 break;
63613             case 228:
63614                 result = reduceNode(node.statement, cbNode, result);
63615                 result = reduceNode(node.expression, cbNode, result);
63616                 break;
63617             case 229:
63618             case 236:
63619                 result = reduceNode(node.expression, cbNode, result);
63620                 result = reduceNode(node.statement, cbNode, result);
63621                 break;
63622             case 230:
63623                 result = reduceNode(node.initializer, cbNode, result);
63624                 result = reduceNode(node.condition, cbNode, result);
63625                 result = reduceNode(node.incrementor, cbNode, result);
63626                 result = reduceNode(node.statement, cbNode, result);
63627                 break;
63628             case 231:
63629             case 232:
63630                 result = reduceNode(node.initializer, cbNode, result);
63631                 result = reduceNode(node.expression, cbNode, result);
63632                 result = reduceNode(node.statement, cbNode, result);
63633                 break;
63634             case 235:
63635             case 239:
63636                 result = reduceNode(node.expression, cbNode, result);
63637                 break;
63638             case 237:
63639                 result = reduceNode(node.expression, cbNode, result);
63640                 result = reduceNode(node.caseBlock, cbNode, result);
63641                 break;
63642             case 238:
63643                 result = reduceNode(node.label, cbNode, result);
63644                 result = reduceNode(node.statement, cbNode, result);
63645                 break;
63646             case 240:
63647                 result = reduceNode(node.tryBlock, cbNode, result);
63648                 result = reduceNode(node.catchClause, cbNode, result);
63649                 result = reduceNode(node.finallyBlock, cbNode, result);
63650                 break;
63651             case 242:
63652                 result = reduceNode(node.name, cbNode, result);
63653                 result = reduceNode(node.type, cbNode, result);
63654                 result = reduceNode(node.initializer, cbNode, result);
63655                 break;
63656             case 243:
63657                 result = reduceNodes(node.declarations, cbNodes, result);
63658                 break;
63659             case 244:
63660                 result = reduceNodes(node.decorators, cbNodes, result);
63661                 result = reduceNodes(node.modifiers, cbNodes, result);
63662                 result = reduceNode(node.name, cbNode, result);
63663                 result = reduceNodes(node.typeParameters, cbNodes, result);
63664                 result = reduceNodes(node.parameters, cbNodes, result);
63665                 result = reduceNode(node.type, cbNode, result);
63666                 result = reduceNode(node.body, cbNode, result);
63667                 break;
63668             case 245:
63669                 result = reduceNodes(node.decorators, cbNodes, result);
63670                 result = reduceNodes(node.modifiers, cbNodes, result);
63671                 result = reduceNode(node.name, cbNode, result);
63672                 result = reduceNodes(node.typeParameters, cbNodes, result);
63673                 result = reduceNodes(node.heritageClauses, cbNodes, result);
63674                 result = reduceNodes(node.members, cbNodes, result);
63675                 break;
63676             case 248:
63677                 result = reduceNodes(node.decorators, cbNodes, result);
63678                 result = reduceNodes(node.modifiers, cbNodes, result);
63679                 result = reduceNode(node.name, cbNode, result);
63680                 result = reduceNodes(node.members, cbNodes, result);
63681                 break;
63682             case 249:
63683                 result = reduceNodes(node.decorators, cbNodes, result);
63684                 result = reduceNodes(node.modifiers, cbNodes, result);
63685                 result = reduceNode(node.name, cbNode, result);
63686                 result = reduceNode(node.body, cbNode, result);
63687                 break;
63688             case 250:
63689                 result = reduceNodes(node.statements, cbNodes, result);
63690                 break;
63691             case 251:
63692                 result = reduceNodes(node.clauses, cbNodes, result);
63693                 break;
63694             case 253:
63695                 result = reduceNodes(node.decorators, cbNodes, result);
63696                 result = reduceNodes(node.modifiers, cbNodes, result);
63697                 result = reduceNode(node.name, cbNode, result);
63698                 result = reduceNode(node.moduleReference, cbNode, result);
63699                 break;
63700             case 254:
63701                 result = reduceNodes(node.decorators, cbNodes, result);
63702                 result = reduceNodes(node.modifiers, cbNodes, result);
63703                 result = reduceNode(node.importClause, cbNode, result);
63704                 result = reduceNode(node.moduleSpecifier, cbNode, result);
63705                 break;
63706             case 255:
63707                 result = reduceNode(node.name, cbNode, result);
63708                 result = reduceNode(node.namedBindings, cbNode, result);
63709                 break;
63710             case 256:
63711                 result = reduceNode(node.name, cbNode, result);
63712                 break;
63713             case 262:
63714                 result = reduceNode(node.name, cbNode, result);
63715                 break;
63716             case 257:
63717             case 261:
63718                 result = reduceNodes(node.elements, cbNodes, result);
63719                 break;
63720             case 258:
63721             case 263:
63722                 result = reduceNode(node.propertyName, cbNode, result);
63723                 result = reduceNode(node.name, cbNode, result);
63724                 break;
63725             case 259:
63726                 result = ts.reduceLeft(node.decorators, cbNode, result);
63727                 result = ts.reduceLeft(node.modifiers, cbNode, result);
63728                 result = reduceNode(node.expression, cbNode, result);
63729                 break;
63730             case 260:
63731                 result = ts.reduceLeft(node.decorators, cbNode, result);
63732                 result = ts.reduceLeft(node.modifiers, cbNode, result);
63733                 result = reduceNode(node.exportClause, cbNode, result);
63734                 result = reduceNode(node.moduleSpecifier, cbNode, result);
63735                 break;
63736             case 265:
63737                 result = reduceNode(node.expression, cbNode, result);
63738                 break;
63739             case 266:
63740                 result = reduceNode(node.openingElement, cbNode, result);
63741                 result = ts.reduceLeft(node.children, cbNode, result);
63742                 result = reduceNode(node.closingElement, cbNode, result);
63743                 break;
63744             case 270:
63745                 result = reduceNode(node.openingFragment, cbNode, result);
63746                 result = ts.reduceLeft(node.children, cbNode, result);
63747                 result = reduceNode(node.closingFragment, cbNode, result);
63748                 break;
63749             case 267:
63750             case 268:
63751                 result = reduceNode(node.tagName, cbNode, result);
63752                 result = reduceNodes(node.typeArguments, cbNode, result);
63753                 result = reduceNode(node.attributes, cbNode, result);
63754                 break;
63755             case 274:
63756                 result = reduceNodes(node.properties, cbNodes, result);
63757                 break;
63758             case 269:
63759                 result = reduceNode(node.tagName, cbNode, result);
63760                 break;
63761             case 273:
63762                 result = reduceNode(node.name, cbNode, result);
63763                 result = reduceNode(node.initializer, cbNode, result);
63764                 break;
63765             case 275:
63766                 result = reduceNode(node.expression, cbNode, result);
63767                 break;
63768             case 276:
63769                 result = reduceNode(node.expression, cbNode, result);
63770                 break;
63771             case 277:
63772                 result = reduceNode(node.expression, cbNode, result);
63773             case 278:
63774                 result = reduceNodes(node.statements, cbNodes, result);
63775                 break;
63776             case 279:
63777                 result = reduceNodes(node.types, cbNodes, result);
63778                 break;
63779             case 280:
63780                 result = reduceNode(node.variableDeclaration, cbNode, result);
63781                 result = reduceNode(node.block, cbNode, result);
63782                 break;
63783             case 281:
63784                 result = reduceNode(node.name, cbNode, result);
63785                 result = reduceNode(node.initializer, cbNode, result);
63786                 break;
63787             case 282:
63788                 result = reduceNode(node.name, cbNode, result);
63789                 result = reduceNode(node.objectAssignmentInitializer, cbNode, result);
63790                 break;
63791             case 283:
63792                 result = reduceNode(node.expression, cbNode, result);
63793                 break;
63794             case 284:
63795                 result = reduceNode(node.name, cbNode, result);
63796                 result = reduceNode(node.initializer, cbNode, result);
63797                 break;
63798             case 290:
63799                 result = reduceNodes(node.statements, cbNodes, result);
63800                 break;
63801             case 326:
63802                 result = reduceNode(node.expression, cbNode, result);
63803                 break;
63804             case 327:
63805                 result = reduceNodes(node.elements, cbNodes, result);
63806                 break;
63807             default:
63808                 break;
63809         }
63810         return result;
63811     }
63812     ts.reduceEachChild = reduceEachChild;
63813     function findSpanEnd(array, test, start) {
63814         var i = start;
63815         while (i < array.length && test(array[i])) {
63816             i++;
63817         }
63818         return i;
63819     }
63820     function mergeLexicalEnvironment(statements, declarations) {
63821         if (!ts.some(declarations)) {
63822             return statements;
63823         }
63824         var leftStandardPrologueEnd = findSpanEnd(statements, ts.isPrologueDirective, 0);
63825         var leftHoistedFunctionsEnd = findSpanEnd(statements, ts.isHoistedFunction, leftStandardPrologueEnd);
63826         var leftHoistedVariablesEnd = findSpanEnd(statements, ts.isHoistedVariableStatement, leftHoistedFunctionsEnd);
63827         var rightStandardPrologueEnd = findSpanEnd(declarations, ts.isPrologueDirective, 0);
63828         var rightHoistedFunctionsEnd = findSpanEnd(declarations, ts.isHoistedFunction, rightStandardPrologueEnd);
63829         var rightHoistedVariablesEnd = findSpanEnd(declarations, ts.isHoistedVariableStatement, rightHoistedFunctionsEnd);
63830         var rightCustomPrologueEnd = findSpanEnd(declarations, ts.isCustomPrologue, rightHoistedVariablesEnd);
63831         ts.Debug.assert(rightCustomPrologueEnd === declarations.length, "Expected declarations to be valid standard or custom prologues");
63832         var left = ts.isNodeArray(statements) ? statements.slice() : statements;
63833         if (rightCustomPrologueEnd > rightHoistedVariablesEnd) {
63834             left.splice.apply(left, __spreadArrays([leftHoistedVariablesEnd, 0], declarations.slice(rightHoistedVariablesEnd, rightCustomPrologueEnd)));
63835         }
63836         if (rightHoistedVariablesEnd > rightHoistedFunctionsEnd) {
63837             left.splice.apply(left, __spreadArrays([leftHoistedFunctionsEnd, 0], declarations.slice(rightHoistedFunctionsEnd, rightHoistedVariablesEnd)));
63838         }
63839         if (rightHoistedFunctionsEnd > rightStandardPrologueEnd) {
63840             left.splice.apply(left, __spreadArrays([leftStandardPrologueEnd, 0], declarations.slice(rightStandardPrologueEnd, rightHoistedFunctionsEnd)));
63841         }
63842         if (rightStandardPrologueEnd > 0) {
63843             if (leftStandardPrologueEnd === 0) {
63844                 left.splice.apply(left, __spreadArrays([0, 0], declarations.slice(0, rightStandardPrologueEnd)));
63845             }
63846             else {
63847                 var leftPrologues = ts.createMap();
63848                 for (var i = 0; i < leftStandardPrologueEnd; i++) {
63849                     var leftPrologue = statements[i];
63850                     leftPrologues.set(leftPrologue.expression.text, true);
63851                 }
63852                 for (var i = rightStandardPrologueEnd - 1; i >= 0; i--) {
63853                     var rightPrologue = declarations[i];
63854                     if (!leftPrologues.has(rightPrologue.expression.text)) {
63855                         left.unshift(rightPrologue);
63856                     }
63857                 }
63858             }
63859         }
63860         if (ts.isNodeArray(statements)) {
63861             return ts.setTextRange(ts.createNodeArray(left, statements.hasTrailingComma), statements);
63862         }
63863         return statements;
63864     }
63865     ts.mergeLexicalEnvironment = mergeLexicalEnvironment;
63866     function liftToBlock(nodes) {
63867         ts.Debug.assert(ts.every(nodes, ts.isStatement), "Cannot lift nodes to a Block.");
63868         return ts.singleOrUndefined(nodes) || ts.createBlock(nodes);
63869     }
63870     ts.liftToBlock = liftToBlock;
63871     function aggregateTransformFlags(node) {
63872         aggregateTransformFlagsForNode(node);
63873         return node;
63874     }
63875     ts.aggregateTransformFlags = aggregateTransformFlags;
63876     function aggregateTransformFlagsForNode(node) {
63877         if (node === undefined) {
63878             return 0;
63879         }
63880         if (node.transformFlags & 536870912) {
63881             return node.transformFlags & ~ts.getTransformFlagsSubtreeExclusions(node.kind);
63882         }
63883         var subtreeFlags = aggregateTransformFlagsForSubtree(node);
63884         return ts.computeTransformFlagsForNode(node, subtreeFlags);
63885     }
63886     function aggregateTransformFlagsForNodeArray(nodes) {
63887         if (nodes === undefined) {
63888             return 0;
63889         }
63890         var subtreeFlags = 0;
63891         var nodeArrayFlags = 0;
63892         for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) {
63893             var node = nodes_3[_i];
63894             subtreeFlags |= aggregateTransformFlagsForNode(node);
63895             nodeArrayFlags |= node.transformFlags & ~536870912;
63896         }
63897         nodes.transformFlags = nodeArrayFlags | 536870912;
63898         return subtreeFlags;
63899     }
63900     function aggregateTransformFlagsForSubtree(node) {
63901         if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 216)) {
63902             return 0;
63903         }
63904         return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes);
63905     }
63906     function aggregateTransformFlagsForChildNode(transformFlags, node) {
63907         return transformFlags | aggregateTransformFlagsForNode(node);
63908     }
63909     function aggregateTransformFlagsForChildNodes(transformFlags, nodes) {
63910         return transformFlags | aggregateTransformFlagsForNodeArray(nodes);
63911     }
63912 })(ts || (ts = {}));
63913 var ts;
63914 (function (ts) {
63915     function createSourceMapGenerator(host, file, sourceRoot, sourcesDirectoryPath, generatorOptions) {
63916         var _a = generatorOptions.extendedDiagnostics
63917             ? ts.performance.createTimer("Source Map", "beforeSourcemap", "afterSourcemap")
63918             : ts.performance.nullTimer, enter = _a.enter, exit = _a.exit;
63919         var rawSources = [];
63920         var sources = [];
63921         var sourceToSourceIndexMap = ts.createMap();
63922         var sourcesContent;
63923         var names = [];
63924         var nameToNameIndexMap;
63925         var mappings = "";
63926         var lastGeneratedLine = 0;
63927         var lastGeneratedCharacter = 0;
63928         var lastSourceIndex = 0;
63929         var lastSourceLine = 0;
63930         var lastSourceCharacter = 0;
63931         var lastNameIndex = 0;
63932         var hasLast = false;
63933         var pendingGeneratedLine = 0;
63934         var pendingGeneratedCharacter = 0;
63935         var pendingSourceIndex = 0;
63936         var pendingSourceLine = 0;
63937         var pendingSourceCharacter = 0;
63938         var pendingNameIndex = 0;
63939         var hasPending = false;
63940         var hasPendingSource = false;
63941         var hasPendingName = false;
63942         return {
63943             getSources: function () { return rawSources; },
63944             addSource: addSource,
63945             setSourceContent: setSourceContent,
63946             addName: addName,
63947             addMapping: addMapping,
63948             appendSourceMap: appendSourceMap,
63949             toJSON: toJSON,
63950             toString: function () { return JSON.stringify(toJSON()); }
63951         };
63952         function addSource(fileName) {
63953             enter();
63954             var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true);
63955             var sourceIndex = sourceToSourceIndexMap.get(source);
63956             if (sourceIndex === undefined) {
63957                 sourceIndex = sources.length;
63958                 sources.push(source);
63959                 rawSources.push(fileName);
63960                 sourceToSourceIndexMap.set(source, sourceIndex);
63961             }
63962             exit();
63963             return sourceIndex;
63964         }
63965         function setSourceContent(sourceIndex, content) {
63966             enter();
63967             if (content !== null) {
63968                 if (!sourcesContent)
63969                     sourcesContent = [];
63970                 while (sourcesContent.length < sourceIndex) {
63971                     sourcesContent.push(null);
63972                 }
63973                 sourcesContent[sourceIndex] = content;
63974             }
63975             exit();
63976         }
63977         function addName(name) {
63978             enter();
63979             if (!nameToNameIndexMap)
63980                 nameToNameIndexMap = ts.createMap();
63981             var nameIndex = nameToNameIndexMap.get(name);
63982             if (nameIndex === undefined) {
63983                 nameIndex = names.length;
63984                 names.push(name);
63985                 nameToNameIndexMap.set(name, nameIndex);
63986             }
63987             exit();
63988             return nameIndex;
63989         }
63990         function isNewGeneratedPosition(generatedLine, generatedCharacter) {
63991             return !hasPending
63992                 || pendingGeneratedLine !== generatedLine
63993                 || pendingGeneratedCharacter !== generatedCharacter;
63994         }
63995         function isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter) {
63996             return sourceIndex !== undefined
63997                 && sourceLine !== undefined
63998                 && sourceCharacter !== undefined
63999                 && pendingSourceIndex === sourceIndex
64000                 && (pendingSourceLine > sourceLine
64001                     || pendingSourceLine === sourceLine && pendingSourceCharacter > sourceCharacter);
64002         }
64003         function addMapping(generatedLine, generatedCharacter, sourceIndex, sourceLine, sourceCharacter, nameIndex) {
64004             ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack");
64005             ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative");
64006             ts.Debug.assert(sourceIndex === undefined || sourceIndex >= 0, "sourceIndex cannot be negative");
64007             ts.Debug.assert(sourceLine === undefined || sourceLine >= 0, "sourceLine cannot be negative");
64008             ts.Debug.assert(sourceCharacter === undefined || sourceCharacter >= 0, "sourceCharacter cannot be negative");
64009             enter();
64010             if (isNewGeneratedPosition(generatedLine, generatedCharacter) ||
64011                 isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter)) {
64012                 commitPendingMapping();
64013                 pendingGeneratedLine = generatedLine;
64014                 pendingGeneratedCharacter = generatedCharacter;
64015                 hasPendingSource = false;
64016                 hasPendingName = false;
64017                 hasPending = true;
64018             }
64019             if (sourceIndex !== undefined && sourceLine !== undefined && sourceCharacter !== undefined) {
64020                 pendingSourceIndex = sourceIndex;
64021                 pendingSourceLine = sourceLine;
64022                 pendingSourceCharacter = sourceCharacter;
64023                 hasPendingSource = true;
64024                 if (nameIndex !== undefined) {
64025                     pendingNameIndex = nameIndex;
64026                     hasPendingName = true;
64027                 }
64028             }
64029             exit();
64030         }
64031         function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath, start, end) {
64032             ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack");
64033             ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative");
64034             enter();
64035             var sourceIndexToNewSourceIndexMap = [];
64036             var nameIndexToNewNameIndexMap;
64037             var mappingIterator = decodeMappings(map.mappings);
64038             for (var iterResult = mappingIterator.next(); !iterResult.done; iterResult = mappingIterator.next()) {
64039                 var raw = iterResult.value;
64040                 if (end && (raw.generatedLine > end.line ||
64041                     (raw.generatedLine === end.line && raw.generatedCharacter > end.character))) {
64042                     break;
64043                 }
64044                 if (start && (raw.generatedLine < start.line ||
64045                     (start.line === raw.generatedLine && raw.generatedCharacter < start.character))) {
64046                     continue;
64047                 }
64048                 var newSourceIndex = void 0;
64049                 var newSourceLine = void 0;
64050                 var newSourceCharacter = void 0;
64051                 var newNameIndex = void 0;
64052                 if (raw.sourceIndex !== undefined) {
64053                     newSourceIndex = sourceIndexToNewSourceIndexMap[raw.sourceIndex];
64054                     if (newSourceIndex === undefined) {
64055                         var rawPath = map.sources[raw.sourceIndex];
64056                         var relativePath = map.sourceRoot ? ts.combinePaths(map.sourceRoot, rawPath) : rawPath;
64057                         var combinedPath = ts.combinePaths(ts.getDirectoryPath(sourceMapPath), relativePath);
64058                         sourceIndexToNewSourceIndexMap[raw.sourceIndex] = newSourceIndex = addSource(combinedPath);
64059                         if (map.sourcesContent && typeof map.sourcesContent[raw.sourceIndex] === "string") {
64060                             setSourceContent(newSourceIndex, map.sourcesContent[raw.sourceIndex]);
64061                         }
64062                     }
64063                     newSourceLine = raw.sourceLine;
64064                     newSourceCharacter = raw.sourceCharacter;
64065                     if (map.names && raw.nameIndex !== undefined) {
64066                         if (!nameIndexToNewNameIndexMap)
64067                             nameIndexToNewNameIndexMap = [];
64068                         newNameIndex = nameIndexToNewNameIndexMap[raw.nameIndex];
64069                         if (newNameIndex === undefined) {
64070                             nameIndexToNewNameIndexMap[raw.nameIndex] = newNameIndex = addName(map.names[raw.nameIndex]);
64071                         }
64072                     }
64073                 }
64074                 var rawGeneratedLine = raw.generatedLine - (start ? start.line : 0);
64075                 var newGeneratedLine = rawGeneratedLine + generatedLine;
64076                 var rawGeneratedCharacter = start && start.line === raw.generatedLine ? raw.generatedCharacter - start.character : raw.generatedCharacter;
64077                 var newGeneratedCharacter = rawGeneratedLine === 0 ? rawGeneratedCharacter + generatedCharacter : rawGeneratedCharacter;
64078                 addMapping(newGeneratedLine, newGeneratedCharacter, newSourceIndex, newSourceLine, newSourceCharacter, newNameIndex);
64079             }
64080             exit();
64081         }
64082         function shouldCommitMapping() {
64083             return !hasLast
64084                 || lastGeneratedLine !== pendingGeneratedLine
64085                 || lastGeneratedCharacter !== pendingGeneratedCharacter
64086                 || lastSourceIndex !== pendingSourceIndex
64087                 || lastSourceLine !== pendingSourceLine
64088                 || lastSourceCharacter !== pendingSourceCharacter
64089                 || lastNameIndex !== pendingNameIndex;
64090         }
64091         function commitPendingMapping() {
64092             if (!hasPending || !shouldCommitMapping()) {
64093                 return;
64094             }
64095             enter();
64096             if (lastGeneratedLine < pendingGeneratedLine) {
64097                 do {
64098                     mappings += ";";
64099                     lastGeneratedLine++;
64100                     lastGeneratedCharacter = 0;
64101                 } while (lastGeneratedLine < pendingGeneratedLine);
64102             }
64103             else {
64104                 ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack");
64105                 if (hasLast) {
64106                     mappings += ",";
64107                 }
64108             }
64109             mappings += base64VLQFormatEncode(pendingGeneratedCharacter - lastGeneratedCharacter);
64110             lastGeneratedCharacter = pendingGeneratedCharacter;
64111             if (hasPendingSource) {
64112                 mappings += base64VLQFormatEncode(pendingSourceIndex - lastSourceIndex);
64113                 lastSourceIndex = pendingSourceIndex;
64114                 mappings += base64VLQFormatEncode(pendingSourceLine - lastSourceLine);
64115                 lastSourceLine = pendingSourceLine;
64116                 mappings += base64VLQFormatEncode(pendingSourceCharacter - lastSourceCharacter);
64117                 lastSourceCharacter = pendingSourceCharacter;
64118                 if (hasPendingName) {
64119                     mappings += base64VLQFormatEncode(pendingNameIndex - lastNameIndex);
64120                     lastNameIndex = pendingNameIndex;
64121                 }
64122             }
64123             hasLast = true;
64124             exit();
64125         }
64126         function toJSON() {
64127             commitPendingMapping();
64128             return {
64129                 version: 3,
64130                 file: file,
64131                 sourceRoot: sourceRoot,
64132                 sources: sources,
64133                 names: names,
64134                 mappings: mappings,
64135                 sourcesContent: sourcesContent,
64136             };
64137         }
64138     }
64139     ts.createSourceMapGenerator = createSourceMapGenerator;
64140     var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/;
64141     var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/;
64142     function getLineInfo(text, lineStarts) {
64143         return {
64144             getLineCount: function () { return lineStarts.length; },
64145             getLineText: function (line) { return text.substring(lineStarts[line], lineStarts[line + 1]); }
64146         };
64147     }
64148     ts.getLineInfo = getLineInfo;
64149     function tryGetSourceMappingURL(lineInfo) {
64150         for (var index = lineInfo.getLineCount() - 1; index >= 0; index--) {
64151             var line = lineInfo.getLineText(index);
64152             var comment = sourceMapCommentRegExp.exec(line);
64153             if (comment) {
64154                 return comment[1];
64155             }
64156             else if (!line.match(whitespaceOrMapCommentRegExp)) {
64157                 break;
64158             }
64159         }
64160     }
64161     ts.tryGetSourceMappingURL = tryGetSourceMappingURL;
64162     function isStringOrNull(x) {
64163         return typeof x === "string" || x === null;
64164     }
64165     function isRawSourceMap(x) {
64166         return x !== null
64167             && typeof x === "object"
64168             && x.version === 3
64169             && typeof x.file === "string"
64170             && typeof x.mappings === "string"
64171             && ts.isArray(x.sources) && ts.every(x.sources, ts.isString)
64172             && (x.sourceRoot === undefined || x.sourceRoot === null || typeof x.sourceRoot === "string")
64173             && (x.sourcesContent === undefined || x.sourcesContent === null || ts.isArray(x.sourcesContent) && ts.every(x.sourcesContent, isStringOrNull))
64174             && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString));
64175     }
64176     ts.isRawSourceMap = isRawSourceMap;
64177     function tryParseRawSourceMap(text) {
64178         try {
64179             var parsed = JSON.parse(text);
64180             if (isRawSourceMap(parsed)) {
64181                 return parsed;
64182             }
64183         }
64184         catch (_a) {
64185         }
64186         return undefined;
64187     }
64188     ts.tryParseRawSourceMap = tryParseRawSourceMap;
64189     function decodeMappings(mappings) {
64190         var done = false;
64191         var pos = 0;
64192         var generatedLine = 0;
64193         var generatedCharacter = 0;
64194         var sourceIndex = 0;
64195         var sourceLine = 0;
64196         var sourceCharacter = 0;
64197         var nameIndex = 0;
64198         var error;
64199         return {
64200             get pos() { return pos; },
64201             get error() { return error; },
64202             get state() { return captureMapping(true, true); },
64203             next: function () {
64204                 while (!done && pos < mappings.length) {
64205                     var ch = mappings.charCodeAt(pos);
64206                     if (ch === 59) {
64207                         generatedLine++;
64208                         generatedCharacter = 0;
64209                         pos++;
64210                         continue;
64211                     }
64212                     if (ch === 44) {
64213                         pos++;
64214                         continue;
64215                     }
64216                     var hasSource = false;
64217                     var hasName = false;
64218                     generatedCharacter += base64VLQFormatDecode();
64219                     if (hasReportedError())
64220                         return stopIterating();
64221                     if (generatedCharacter < 0)
64222                         return setErrorAndStopIterating("Invalid generatedCharacter found");
64223                     if (!isSourceMappingSegmentEnd()) {
64224                         hasSource = true;
64225                         sourceIndex += base64VLQFormatDecode();
64226                         if (hasReportedError())
64227                             return stopIterating();
64228                         if (sourceIndex < 0)
64229                             return setErrorAndStopIterating("Invalid sourceIndex found");
64230                         if (isSourceMappingSegmentEnd())
64231                             return setErrorAndStopIterating("Unsupported Format: No entries after sourceIndex");
64232                         sourceLine += base64VLQFormatDecode();
64233                         if (hasReportedError())
64234                             return stopIterating();
64235                         if (sourceLine < 0)
64236                             return setErrorAndStopIterating("Invalid sourceLine found");
64237                         if (isSourceMappingSegmentEnd())
64238                             return setErrorAndStopIterating("Unsupported Format: No entries after sourceLine");
64239                         sourceCharacter += base64VLQFormatDecode();
64240                         if (hasReportedError())
64241                             return stopIterating();
64242                         if (sourceCharacter < 0)
64243                             return setErrorAndStopIterating("Invalid sourceCharacter found");
64244                         if (!isSourceMappingSegmentEnd()) {
64245                             hasName = true;
64246                             nameIndex += base64VLQFormatDecode();
64247                             if (hasReportedError())
64248                                 return stopIterating();
64249                             if (nameIndex < 0)
64250                                 return setErrorAndStopIterating("Invalid nameIndex found");
64251                             if (!isSourceMappingSegmentEnd())
64252                                 return setErrorAndStopIterating("Unsupported Error Format: Entries after nameIndex");
64253                         }
64254                     }
64255                     return { value: captureMapping(hasSource, hasName), done: done };
64256                 }
64257                 return stopIterating();
64258             }
64259         };
64260         function captureMapping(hasSource, hasName) {
64261             return {
64262                 generatedLine: generatedLine,
64263                 generatedCharacter: generatedCharacter,
64264                 sourceIndex: hasSource ? sourceIndex : undefined,
64265                 sourceLine: hasSource ? sourceLine : undefined,
64266                 sourceCharacter: hasSource ? sourceCharacter : undefined,
64267                 nameIndex: hasName ? nameIndex : undefined
64268             };
64269         }
64270         function stopIterating() {
64271             done = true;
64272             return { value: undefined, done: true };
64273         }
64274         function setError(message) {
64275             if (error === undefined) {
64276                 error = message;
64277             }
64278         }
64279         function setErrorAndStopIterating(message) {
64280             setError(message);
64281             return stopIterating();
64282         }
64283         function hasReportedError() {
64284             return error !== undefined;
64285         }
64286         function isSourceMappingSegmentEnd() {
64287             return (pos === mappings.length ||
64288                 mappings.charCodeAt(pos) === 44 ||
64289                 mappings.charCodeAt(pos) === 59);
64290         }
64291         function base64VLQFormatDecode() {
64292             var moreDigits = true;
64293             var shiftCount = 0;
64294             var value = 0;
64295             for (; moreDigits; pos++) {
64296                 if (pos >= mappings.length)
64297                     return setError("Error in decoding base64VLQFormatDecode, past the mapping string"), -1;
64298                 var currentByte = base64FormatDecode(mappings.charCodeAt(pos));
64299                 if (currentByte === -1)
64300                     return setError("Invalid character in VLQ"), -1;
64301                 moreDigits = (currentByte & 32) !== 0;
64302                 value = value | ((currentByte & 31) << shiftCount);
64303                 shiftCount += 5;
64304             }
64305             if ((value & 1) === 0) {
64306                 value = value >> 1;
64307             }
64308             else {
64309                 value = value >> 1;
64310                 value = -value;
64311             }
64312             return value;
64313         }
64314     }
64315     ts.decodeMappings = decodeMappings;
64316     function sameMapping(left, right) {
64317         return left === right
64318             || left.generatedLine === right.generatedLine
64319                 && left.generatedCharacter === right.generatedCharacter
64320                 && left.sourceIndex === right.sourceIndex
64321                 && left.sourceLine === right.sourceLine
64322                 && left.sourceCharacter === right.sourceCharacter
64323                 && left.nameIndex === right.nameIndex;
64324     }
64325     ts.sameMapping = sameMapping;
64326     function isSourceMapping(mapping) {
64327         return mapping.sourceIndex !== undefined
64328             && mapping.sourceLine !== undefined
64329             && mapping.sourceCharacter !== undefined;
64330     }
64331     ts.isSourceMapping = isSourceMapping;
64332     function base64FormatEncode(value) {
64333         return value >= 0 && value < 26 ? 65 + value :
64334             value >= 26 && value < 52 ? 97 + value - 26 :
64335                 value >= 52 && value < 62 ? 48 + value - 52 :
64336                     value === 62 ? 43 :
64337                         value === 63 ? 47 :
64338                             ts.Debug.fail(value + ": not a base64 value");
64339     }
64340     function base64FormatDecode(ch) {
64341         return ch >= 65 && ch <= 90 ? ch - 65 :
64342             ch >= 97 && ch <= 122 ? ch - 97 + 26 :
64343                 ch >= 48 && ch <= 57 ? ch - 48 + 52 :
64344                     ch === 43 ? 62 :
64345                         ch === 47 ? 63 :
64346                             -1;
64347     }
64348     function base64VLQFormatEncode(inValue) {
64349         if (inValue < 0) {
64350             inValue = ((-inValue) << 1) + 1;
64351         }
64352         else {
64353             inValue = inValue << 1;
64354         }
64355         var encodedStr = "";
64356         do {
64357             var currentDigit = inValue & 31;
64358             inValue = inValue >> 5;
64359             if (inValue > 0) {
64360                 currentDigit = currentDigit | 32;
64361             }
64362             encodedStr = encodedStr + String.fromCharCode(base64FormatEncode(currentDigit));
64363         } while (inValue > 0);
64364         return encodedStr;
64365     }
64366     function isSourceMappedPosition(value) {
64367         return value.sourceIndex !== undefined
64368             && value.sourcePosition !== undefined;
64369     }
64370     function sameMappedPosition(left, right) {
64371         return left.generatedPosition === right.generatedPosition
64372             && left.sourceIndex === right.sourceIndex
64373             && left.sourcePosition === right.sourcePosition;
64374     }
64375     function compareSourcePositions(left, right) {
64376         ts.Debug.assert(left.sourceIndex === right.sourceIndex);
64377         return ts.compareValues(left.sourcePosition, right.sourcePosition);
64378     }
64379     function compareGeneratedPositions(left, right) {
64380         return ts.compareValues(left.generatedPosition, right.generatedPosition);
64381     }
64382     function getSourcePositionOfMapping(value) {
64383         return value.sourcePosition;
64384     }
64385     function getGeneratedPositionOfMapping(value) {
64386         return value.generatedPosition;
64387     }
64388     function createDocumentPositionMapper(host, map, mapPath) {
64389         var mapDirectory = ts.getDirectoryPath(mapPath);
64390         var sourceRoot = map.sourceRoot ? ts.getNormalizedAbsolutePath(map.sourceRoot, mapDirectory) : mapDirectory;
64391         var generatedAbsoluteFilePath = ts.getNormalizedAbsolutePath(map.file, mapDirectory);
64392         var generatedFile = host.getSourceFileLike(generatedAbsoluteFilePath);
64393         var sourceFileAbsolutePaths = map.sources.map(function (source) { return ts.getNormalizedAbsolutePath(source, sourceRoot); });
64394         var sourceToSourceIndexMap = ts.createMapFromEntries(sourceFileAbsolutePaths.map(function (source, i) { return [host.getCanonicalFileName(source), i]; }));
64395         var decodedMappings;
64396         var generatedMappings;
64397         var sourceMappings;
64398         return {
64399             getSourcePosition: getSourcePosition,
64400             getGeneratedPosition: getGeneratedPosition
64401         };
64402         function processMapping(mapping) {
64403             var generatedPosition = generatedFile !== undefined
64404                 ? ts.getPositionOfLineAndCharacter(generatedFile, mapping.generatedLine, mapping.generatedCharacter, true)
64405                 : -1;
64406             var source;
64407             var sourcePosition;
64408             if (isSourceMapping(mapping)) {
64409                 var sourceFile = host.getSourceFileLike(sourceFileAbsolutePaths[mapping.sourceIndex]);
64410                 source = map.sources[mapping.sourceIndex];
64411                 sourcePosition = sourceFile !== undefined
64412                     ? ts.getPositionOfLineAndCharacter(sourceFile, mapping.sourceLine, mapping.sourceCharacter, true)
64413                     : -1;
64414             }
64415             return {
64416                 generatedPosition: generatedPosition,
64417                 source: source,
64418                 sourceIndex: mapping.sourceIndex,
64419                 sourcePosition: sourcePosition,
64420                 nameIndex: mapping.nameIndex
64421             };
64422         }
64423         function getDecodedMappings() {
64424             if (decodedMappings === undefined) {
64425                 var decoder = decodeMappings(map.mappings);
64426                 var mappings = ts.arrayFrom(decoder, processMapping);
64427                 if (decoder.error !== undefined) {
64428                     if (host.log) {
64429                         host.log("Encountered error while decoding sourcemap: " + decoder.error);
64430                     }
64431                     decodedMappings = ts.emptyArray;
64432                 }
64433                 else {
64434                     decodedMappings = mappings;
64435                 }
64436             }
64437             return decodedMappings;
64438         }
64439         function getSourceMappings(sourceIndex) {
64440             if (sourceMappings === undefined) {
64441                 var lists = [];
64442                 for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) {
64443                     var mapping = _a[_i];
64444                     if (!isSourceMappedPosition(mapping))
64445                         continue;
64446                     var list = lists[mapping.sourceIndex];
64447                     if (!list)
64448                         lists[mapping.sourceIndex] = list = [];
64449                     list.push(mapping);
64450                 }
64451                 sourceMappings = lists.map(function (list) { return ts.sortAndDeduplicate(list, compareSourcePositions, sameMappedPosition); });
64452             }
64453             return sourceMappings[sourceIndex];
64454         }
64455         function getGeneratedMappings() {
64456             if (generatedMappings === undefined) {
64457                 var list = [];
64458                 for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) {
64459                     var mapping = _a[_i];
64460                     list.push(mapping);
64461                 }
64462                 generatedMappings = ts.sortAndDeduplicate(list, compareGeneratedPositions, sameMappedPosition);
64463             }
64464             return generatedMappings;
64465         }
64466         function getGeneratedPosition(loc) {
64467             var sourceIndex = sourceToSourceIndexMap.get(host.getCanonicalFileName(loc.fileName));
64468             if (sourceIndex === undefined)
64469                 return loc;
64470             var sourceMappings = getSourceMappings(sourceIndex);
64471             if (!ts.some(sourceMappings))
64472                 return loc;
64473             var targetIndex = ts.binarySearchKey(sourceMappings, loc.pos, getSourcePositionOfMapping, ts.compareValues);
64474             if (targetIndex < 0) {
64475                 targetIndex = ~targetIndex;
64476             }
64477             var mapping = sourceMappings[targetIndex];
64478             if (mapping === undefined || mapping.sourceIndex !== sourceIndex) {
64479                 return loc;
64480             }
64481             return { fileName: generatedAbsoluteFilePath, pos: mapping.generatedPosition };
64482         }
64483         function getSourcePosition(loc) {
64484             var generatedMappings = getGeneratedMappings();
64485             if (!ts.some(generatedMappings))
64486                 return loc;
64487             var targetIndex = ts.binarySearchKey(generatedMappings, loc.pos, getGeneratedPositionOfMapping, ts.compareValues);
64488             if (targetIndex < 0) {
64489                 targetIndex = ~targetIndex;
64490             }
64491             var mapping = generatedMappings[targetIndex];
64492             if (mapping === undefined || !isSourceMappedPosition(mapping)) {
64493                 return loc;
64494             }
64495             return { fileName: sourceFileAbsolutePaths[mapping.sourceIndex], pos: mapping.sourcePosition };
64496         }
64497     }
64498     ts.createDocumentPositionMapper = createDocumentPositionMapper;
64499     ts.identitySourceMapConsumer = {
64500         getSourcePosition: ts.identity,
64501         getGeneratedPosition: ts.identity
64502     };
64503 })(ts || (ts = {}));
64504 var ts;
64505 (function (ts) {
64506     function getOriginalNodeId(node) {
64507         node = ts.getOriginalNode(node);
64508         return node ? ts.getNodeId(node) : 0;
64509     }
64510     ts.getOriginalNodeId = getOriginalNodeId;
64511     function containsDefaultReference(node) {
64512         if (!node)
64513             return false;
64514         if (!ts.isNamedImports(node))
64515             return false;
64516         return ts.some(node.elements, isNamedDefaultReference);
64517     }
64518     function isNamedDefaultReference(e) {
64519         return e.propertyName !== undefined && e.propertyName.escapedText === "default";
64520     }
64521     function chainBundle(transformSourceFile) {
64522         return transformSourceFileOrBundle;
64523         function transformSourceFileOrBundle(node) {
64524             return node.kind === 290 ? transformSourceFile(node) : transformBundle(node);
64525         }
64526         function transformBundle(node) {
64527             return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends);
64528         }
64529     }
64530     ts.chainBundle = chainBundle;
64531     function getExportNeedsImportStarHelper(node) {
64532         return !!ts.getNamespaceDeclarationNode(node);
64533     }
64534     ts.getExportNeedsImportStarHelper = getExportNeedsImportStarHelper;
64535     function getImportNeedsImportStarHelper(node) {
64536         if (!!ts.getNamespaceDeclarationNode(node)) {
64537             return true;
64538         }
64539         var bindings = node.importClause && node.importClause.namedBindings;
64540         if (!bindings) {
64541             return false;
64542         }
64543         if (!ts.isNamedImports(bindings))
64544             return false;
64545         var defaultRefCount = 0;
64546         for (var _i = 0, _a = bindings.elements; _i < _a.length; _i++) {
64547             var binding = _a[_i];
64548             if (isNamedDefaultReference(binding)) {
64549                 defaultRefCount++;
64550             }
64551         }
64552         return (defaultRefCount > 0 && defaultRefCount !== bindings.elements.length) || (!!(bindings.elements.length - defaultRefCount) && ts.isDefaultImport(node));
64553     }
64554     ts.getImportNeedsImportStarHelper = getImportNeedsImportStarHelper;
64555     function getImportNeedsImportDefaultHelper(node) {
64556         return !getImportNeedsImportStarHelper(node) && (ts.isDefaultImport(node) || (!!node.importClause && ts.isNamedImports(node.importClause.namedBindings) && containsDefaultReference(node.importClause.namedBindings)));
64557     }
64558     ts.getImportNeedsImportDefaultHelper = getImportNeedsImportDefaultHelper;
64559     function collectExternalModuleInfo(sourceFile, resolver, compilerOptions) {
64560         var externalImports = [];
64561         var exportSpecifiers = ts.createMultiMap();
64562         var exportedBindings = [];
64563         var uniqueExports = ts.createMap();
64564         var exportedNames;
64565         var hasExportDefault = false;
64566         var exportEquals;
64567         var hasExportStarsToExportValues = false;
64568         var hasImportStar = false;
64569         var hasImportDefault = false;
64570         for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
64571             var node = _a[_i];
64572             switch (node.kind) {
64573                 case 254:
64574                     externalImports.push(node);
64575                     if (!hasImportStar && getImportNeedsImportStarHelper(node)) {
64576                         hasImportStar = true;
64577                     }
64578                     if (!hasImportDefault && getImportNeedsImportDefaultHelper(node)) {
64579                         hasImportDefault = true;
64580                     }
64581                     break;
64582                 case 253:
64583                     if (node.moduleReference.kind === 265) {
64584                         externalImports.push(node);
64585                     }
64586                     break;
64587                 case 260:
64588                     if (node.moduleSpecifier) {
64589                         if (!node.exportClause) {
64590                             externalImports.push(node);
64591                             hasExportStarsToExportValues = true;
64592                         }
64593                         else {
64594                             externalImports.push(node);
64595                         }
64596                     }
64597                     else {
64598                         for (var _b = 0, _c = ts.cast(node.exportClause, ts.isNamedExports).elements; _b < _c.length; _b++) {
64599                             var specifier = _c[_b];
64600                             if (!uniqueExports.get(ts.idText(specifier.name))) {
64601                                 var name = specifier.propertyName || specifier.name;
64602                                 exportSpecifiers.add(ts.idText(name), specifier);
64603                                 var decl = resolver.getReferencedImportDeclaration(name)
64604                                     || resolver.getReferencedValueDeclaration(name);
64605                                 if (decl) {
64606                                     multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name);
64607                                 }
64608                                 uniqueExports.set(ts.idText(specifier.name), true);
64609                                 exportedNames = ts.append(exportedNames, specifier.name);
64610                             }
64611                         }
64612                     }
64613                     break;
64614                 case 259:
64615                     if (node.isExportEquals && !exportEquals) {
64616                         exportEquals = node;
64617                     }
64618                     break;
64619                 case 225:
64620                     if (ts.hasModifier(node, 1)) {
64621                         for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) {
64622                             var decl = _e[_d];
64623                             exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames);
64624                         }
64625                     }
64626                     break;
64627                 case 244:
64628                     if (ts.hasModifier(node, 1)) {
64629                         if (ts.hasModifier(node, 512)) {
64630                             if (!hasExportDefault) {
64631                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), ts.getDeclarationName(node));
64632                                 hasExportDefault = true;
64633                             }
64634                         }
64635                         else {
64636                             var name = node.name;
64637                             if (!uniqueExports.get(ts.idText(name))) {
64638                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
64639                                 uniqueExports.set(ts.idText(name), true);
64640                                 exportedNames = ts.append(exportedNames, name);
64641                             }
64642                         }
64643                     }
64644                     break;
64645                 case 245:
64646                     if (ts.hasModifier(node, 1)) {
64647                         if (ts.hasModifier(node, 512)) {
64648                             if (!hasExportDefault) {
64649                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), ts.getDeclarationName(node));
64650                                 hasExportDefault = true;
64651                             }
64652                         }
64653                         else {
64654                             var name = node.name;
64655                             if (name && !uniqueExports.get(ts.idText(name))) {
64656                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
64657                                 uniqueExports.set(ts.idText(name), true);
64658                                 exportedNames = ts.append(exportedNames, name);
64659                             }
64660                         }
64661                     }
64662                     break;
64663             }
64664         }
64665         var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault);
64666         if (externalHelpersImportDeclaration) {
64667             externalImports.unshift(externalHelpersImportDeclaration);
64668         }
64669         return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames, externalHelpersImportDeclaration: externalHelpersImportDeclaration };
64670     }
64671     ts.collectExternalModuleInfo = collectExternalModuleInfo;
64672     function collectExportedVariableInfo(decl, uniqueExports, exportedNames) {
64673         if (ts.isBindingPattern(decl.name)) {
64674             for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) {
64675                 var element = _a[_i];
64676                 if (!ts.isOmittedExpression(element)) {
64677                     exportedNames = collectExportedVariableInfo(element, uniqueExports, exportedNames);
64678                 }
64679             }
64680         }
64681         else if (!ts.isGeneratedIdentifier(decl.name)) {
64682             var text = ts.idText(decl.name);
64683             if (!uniqueExports.get(text)) {
64684                 uniqueExports.set(text, true);
64685                 exportedNames = ts.append(exportedNames, decl.name);
64686             }
64687         }
64688         return exportedNames;
64689     }
64690     function multiMapSparseArrayAdd(map, key, value) {
64691         var values = map[key];
64692         if (values) {
64693             values.push(value);
64694         }
64695         else {
64696             map[key] = values = [value];
64697         }
64698         return values;
64699     }
64700     function isSimpleCopiableExpression(expression) {
64701         return ts.isStringLiteralLike(expression) ||
64702             expression.kind === 8 ||
64703             ts.isKeyword(expression.kind) ||
64704             ts.isIdentifier(expression);
64705     }
64706     ts.isSimpleCopiableExpression = isSimpleCopiableExpression;
64707     function isSimpleInlineableExpression(expression) {
64708         return !ts.isIdentifier(expression) && isSimpleCopiableExpression(expression) ||
64709             ts.isWellKnownSymbolSyntactically(expression);
64710     }
64711     ts.isSimpleInlineableExpression = isSimpleInlineableExpression;
64712     function isCompoundAssignment(kind) {
64713         return kind >= 63
64714             && kind <= 74;
64715     }
64716     ts.isCompoundAssignment = isCompoundAssignment;
64717     function getNonAssignmentOperatorForCompoundAssignment(kind) {
64718         switch (kind) {
64719             case 63: return 39;
64720             case 64: return 40;
64721             case 65: return 41;
64722             case 66: return 42;
64723             case 67: return 43;
64724             case 68: return 44;
64725             case 69: return 47;
64726             case 70: return 48;
64727             case 71: return 49;
64728             case 72: return 50;
64729             case 73: return 51;
64730             case 74: return 52;
64731         }
64732     }
64733     ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment;
64734     function addPrologueDirectivesAndInitialSuperCall(ctor, result, visitor) {
64735         if (ctor.body) {
64736             var statements = ctor.body.statements;
64737             var index = ts.addPrologue(result, statements, false, visitor);
64738             if (index === statements.length) {
64739                 return index;
64740             }
64741             var superIndex = ts.findIndex(statements, function (s) { return ts.isExpressionStatement(s) && ts.isSuperCall(s.expression); }, index);
64742             if (superIndex > -1) {
64743                 for (var i = index; i <= superIndex; i++) {
64744                     result.push(ts.visitNode(statements[i], visitor, ts.isStatement));
64745                 }
64746                 return superIndex + 1;
64747             }
64748             return index;
64749         }
64750         return 0;
64751     }
64752     ts.addPrologueDirectivesAndInitialSuperCall = addPrologueDirectivesAndInitialSuperCall;
64753     function helperString(input) {
64754         var args = [];
64755         for (var _i = 1; _i < arguments.length; _i++) {
64756             args[_i - 1] = arguments[_i];
64757         }
64758         return function (uniqueName) {
64759             var result = "";
64760             for (var i = 0; i < args.length; i++) {
64761                 result += input[i];
64762                 result += uniqueName(args[i]);
64763             }
64764             result += input[input.length - 1];
64765             return result;
64766         };
64767     }
64768     ts.helperString = helperString;
64769     function getProperties(node, requireInitializer, isStatic) {
64770         return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); });
64771     }
64772     ts.getProperties = getProperties;
64773     function isInitializedOrStaticProperty(member, requireInitializer, isStatic) {
64774         return ts.isPropertyDeclaration(member)
64775             && (!!member.initializer || !requireInitializer)
64776             && ts.hasStaticModifier(member) === isStatic;
64777     }
64778     function isInitializedProperty(member) {
64779         return member.kind === 159
64780             && member.initializer !== undefined;
64781     }
64782     ts.isInitializedProperty = isInitializedProperty;
64783 })(ts || (ts = {}));
64784 var ts;
64785 (function (ts) {
64786     function flattenDestructuringAssignment(node, visitor, context, level, needsValue, createAssignmentCallback) {
64787         var location = node;
64788         var value;
64789         if (ts.isDestructuringAssignment(node)) {
64790             value = node.right;
64791             while (ts.isEmptyArrayLiteral(node.left) || ts.isEmptyObjectLiteral(node.left)) {
64792                 if (ts.isDestructuringAssignment(value)) {
64793                     location = node = value;
64794                     value = node.right;
64795                 }
64796                 else {
64797                     return ts.visitNode(value, visitor, ts.isExpression);
64798                 }
64799             }
64800         }
64801         var expressions;
64802         var flattenContext = {
64803             context: context,
64804             level: level,
64805             downlevelIteration: !!context.getCompilerOptions().downlevelIteration,
64806             hoistTempVariables: true,
64807             emitExpression: emitExpression,
64808             emitBindingOrAssignment: emitBindingOrAssignment,
64809             createArrayBindingOrAssignmentPattern: makeArrayAssignmentPattern,
64810             createObjectBindingOrAssignmentPattern: makeObjectAssignmentPattern,
64811             createArrayBindingOrAssignmentElement: makeAssignmentElement,
64812             visitor: visitor
64813         };
64814         if (value) {
64815             value = ts.visitNode(value, visitor, ts.isExpression);
64816             if (ts.isIdentifier(value) && bindingOrAssignmentElementAssignsToName(node, value.escapedText) ||
64817                 bindingOrAssignmentElementContainsNonLiteralComputedName(node)) {
64818                 value = ensureIdentifier(flattenContext, value, false, location);
64819             }
64820             else if (needsValue) {
64821                 value = ensureIdentifier(flattenContext, value, true, location);
64822             }
64823             else if (ts.nodeIsSynthesized(node)) {
64824                 location = value;
64825             }
64826         }
64827         flattenBindingOrAssignmentElement(flattenContext, node, value, location, ts.isDestructuringAssignment(node));
64828         if (value && needsValue) {
64829             if (!ts.some(expressions)) {
64830                 return value;
64831             }
64832             expressions.push(value);
64833         }
64834         return ts.aggregateTransformFlags(ts.inlineExpressions(expressions)) || ts.createOmittedExpression();
64835         function emitExpression(expression) {
64836             ts.aggregateTransformFlags(expression);
64837             expressions = ts.append(expressions, expression);
64838         }
64839         function emitBindingOrAssignment(target, value, location, original) {
64840             ts.Debug.assertNode(target, createAssignmentCallback ? ts.isIdentifier : ts.isExpression);
64841             var expression = createAssignmentCallback
64842                 ? createAssignmentCallback(target, value, location)
64843                 : ts.setTextRange(ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value), location);
64844             expression.original = original;
64845             emitExpression(expression);
64846         }
64847     }
64848     ts.flattenDestructuringAssignment = flattenDestructuringAssignment;
64849     function bindingOrAssignmentElementAssignsToName(element, escapedName) {
64850         var target = ts.getTargetOfBindingOrAssignmentElement(element);
64851         if (ts.isBindingOrAssignmentPattern(target)) {
64852             return bindingOrAssignmentPatternAssignsToName(target, escapedName);
64853         }
64854         else if (ts.isIdentifier(target)) {
64855             return target.escapedText === escapedName;
64856         }
64857         return false;
64858     }
64859     function bindingOrAssignmentPatternAssignsToName(pattern, escapedName) {
64860         var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
64861         for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) {
64862             var element = elements_3[_i];
64863             if (bindingOrAssignmentElementAssignsToName(element, escapedName)) {
64864                 return true;
64865             }
64866         }
64867         return false;
64868     }
64869     function bindingOrAssignmentElementContainsNonLiteralComputedName(element) {
64870         var propertyName = ts.tryGetPropertyNameOfBindingOrAssignmentElement(element);
64871         if (propertyName && ts.isComputedPropertyName(propertyName) && !ts.isLiteralExpression(propertyName.expression)) {
64872             return true;
64873         }
64874         var target = ts.getTargetOfBindingOrAssignmentElement(element);
64875         return !!target && ts.isBindingOrAssignmentPattern(target) && bindingOrAssignmentPatternContainsNonLiteralComputedName(target);
64876     }
64877     function bindingOrAssignmentPatternContainsNonLiteralComputedName(pattern) {
64878         return !!ts.forEach(ts.getElementsOfBindingOrAssignmentPattern(pattern), bindingOrAssignmentElementContainsNonLiteralComputedName);
64879     }
64880     function flattenDestructuringBinding(node, visitor, context, level, rval, hoistTempVariables, skipInitializer) {
64881         if (hoistTempVariables === void 0) { hoistTempVariables = false; }
64882         var pendingExpressions;
64883         var pendingDeclarations = [];
64884         var declarations = [];
64885         var flattenContext = {
64886             context: context,
64887             level: level,
64888             downlevelIteration: !!context.getCompilerOptions().downlevelIteration,
64889             hoistTempVariables: hoistTempVariables,
64890             emitExpression: emitExpression,
64891             emitBindingOrAssignment: emitBindingOrAssignment,
64892             createArrayBindingOrAssignmentPattern: makeArrayBindingPattern,
64893             createObjectBindingOrAssignmentPattern: makeObjectBindingPattern,
64894             createArrayBindingOrAssignmentElement: makeBindingElement,
64895             visitor: visitor
64896         };
64897         if (ts.isVariableDeclaration(node)) {
64898             var initializer = ts.getInitializerOfBindingOrAssignmentElement(node);
64899             if (initializer && (ts.isIdentifier(initializer) && bindingOrAssignmentElementAssignsToName(node, initializer.escapedText) ||
64900                 bindingOrAssignmentElementContainsNonLiteralComputedName(node))) {
64901                 initializer = ensureIdentifier(flattenContext, initializer, false, initializer);
64902                 node = ts.updateVariableDeclaration(node, node.name, node.type, initializer);
64903             }
64904         }
64905         flattenBindingOrAssignmentElement(flattenContext, node, rval, node, skipInitializer);
64906         if (pendingExpressions) {
64907             var temp = ts.createTempVariable(undefined);
64908             if (hoistTempVariables) {
64909                 var value = ts.inlineExpressions(pendingExpressions);
64910                 pendingExpressions = undefined;
64911                 emitBindingOrAssignment(temp, value, undefined, undefined);
64912             }
64913             else {
64914                 context.hoistVariableDeclaration(temp);
64915                 var pendingDeclaration = ts.last(pendingDeclarations);
64916                 pendingDeclaration.pendingExpressions = ts.append(pendingDeclaration.pendingExpressions, ts.createAssignment(temp, pendingDeclaration.value));
64917                 ts.addRange(pendingDeclaration.pendingExpressions, pendingExpressions);
64918                 pendingDeclaration.value = temp;
64919             }
64920         }
64921         for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) {
64922             var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name = _a.name, value = _a.value, location = _a.location, original = _a.original;
64923             var variable = ts.createVariableDeclaration(name, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value);
64924             variable.original = original;
64925             ts.setTextRange(variable, location);
64926             ts.aggregateTransformFlags(variable);
64927             declarations.push(variable);
64928         }
64929         return declarations;
64930         function emitExpression(value) {
64931             pendingExpressions = ts.append(pendingExpressions, value);
64932         }
64933         function emitBindingOrAssignment(target, value, location, original) {
64934             ts.Debug.assertNode(target, ts.isBindingName);
64935             if (pendingExpressions) {
64936                 value = ts.inlineExpressions(ts.append(pendingExpressions, value));
64937                 pendingExpressions = undefined;
64938             }
64939             pendingDeclarations.push({ pendingExpressions: pendingExpressions, name: target, value: value, location: location, original: original });
64940         }
64941     }
64942     ts.flattenDestructuringBinding = flattenDestructuringBinding;
64943     function flattenBindingOrAssignmentElement(flattenContext, element, value, location, skipInitializer) {
64944         if (!skipInitializer) {
64945             var initializer = ts.visitNode(ts.getInitializerOfBindingOrAssignmentElement(element), flattenContext.visitor, ts.isExpression);
64946             if (initializer) {
64947                 value = value ? createDefaultValueCheck(flattenContext, value, initializer, location) : initializer;
64948             }
64949             else if (!value) {
64950                 value = ts.createVoidZero();
64951             }
64952         }
64953         var bindingTarget = ts.getTargetOfBindingOrAssignmentElement(element);
64954         if (ts.isObjectBindingOrAssignmentPattern(bindingTarget)) {
64955             flattenObjectBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location);
64956         }
64957         else if (ts.isArrayBindingOrAssignmentPattern(bindingTarget)) {
64958             flattenArrayBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location);
64959         }
64960         else {
64961             flattenContext.emitBindingOrAssignment(bindingTarget, value, location, element);
64962         }
64963     }
64964     function flattenObjectBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) {
64965         var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
64966         var numElements = elements.length;
64967         if (numElements !== 1) {
64968             var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0;
64969             value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location);
64970         }
64971         var bindingElements;
64972         var computedTempVariables;
64973         for (var i = 0; i < numElements; i++) {
64974             var element = elements[i];
64975             if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) {
64976                 var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element);
64977                 if (flattenContext.level >= 1
64978                     && !(element.transformFlags & (8192 | 16384))
64979                     && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (8192 | 16384))
64980                     && !ts.isComputedPropertyName(propertyName)) {
64981                     bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor));
64982                 }
64983                 else {
64984                     if (bindingElements) {
64985                         flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
64986                         bindingElements = undefined;
64987                     }
64988                     var rhsValue = createDestructuringPropertyAccess(flattenContext, value, propertyName);
64989                     if (ts.isComputedPropertyName(propertyName)) {
64990                         computedTempVariables = ts.append(computedTempVariables, rhsValue.argumentExpression);
64991                     }
64992                     flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
64993                 }
64994             }
64995             else if (i === numElements - 1) {
64996                 if (bindingElements) {
64997                     flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
64998                     bindingElements = undefined;
64999                 }
65000                 var rhsValue = createRestCall(flattenContext.context, value, elements, computedTempVariables, pattern);
65001                 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
65002             }
65003         }
65004         if (bindingElements) {
65005             flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
65006         }
65007     }
65008     function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) {
65009         var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
65010         var numElements = elements.length;
65011         if (flattenContext.level < 1 && flattenContext.downlevelIteration) {
65012             value = ensureIdentifier(flattenContext, ts.createReadHelper(flattenContext.context, value, numElements > 0 && ts.getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1])
65013                 ? undefined
65014                 : numElements, location), false, location);
65015         }
65016         else if (numElements !== 1 && (flattenContext.level < 1 || numElements === 0)
65017             || ts.every(elements, ts.isOmittedExpression)) {
65018             var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0;
65019             value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location);
65020         }
65021         var bindingElements;
65022         var restContainingElements;
65023         for (var i = 0; i < numElements; i++) {
65024             var element = elements[i];
65025             if (flattenContext.level >= 1) {
65026                 if (element.transformFlags & 16384) {
65027                     var temp = ts.createTempVariable(undefined);
65028                     if (flattenContext.hoistTempVariables) {
65029                         flattenContext.context.hoistVariableDeclaration(temp);
65030                     }
65031                     restContainingElements = ts.append(restContainingElements, [temp, element]);
65032                     bindingElements = ts.append(bindingElements, flattenContext.createArrayBindingOrAssignmentElement(temp));
65033                 }
65034                 else {
65035                     bindingElements = ts.append(bindingElements, element);
65036                 }
65037             }
65038             else if (ts.isOmittedExpression(element)) {
65039                 continue;
65040             }
65041             else if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) {
65042                 var rhsValue = ts.createElementAccess(value, i);
65043                 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
65044             }
65045             else if (i === numElements - 1) {
65046                 var rhsValue = ts.createArraySlice(value, i);
65047                 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
65048             }
65049         }
65050         if (bindingElements) {
65051             flattenContext.emitBindingOrAssignment(flattenContext.createArrayBindingOrAssignmentPattern(bindingElements), value, location, pattern);
65052         }
65053         if (restContainingElements) {
65054             for (var _i = 0, restContainingElements_1 = restContainingElements; _i < restContainingElements_1.length; _i++) {
65055                 var _a = restContainingElements_1[_i], id = _a[0], element = _a[1];
65056                 flattenBindingOrAssignmentElement(flattenContext, element, id, element);
65057             }
65058         }
65059     }
65060     function createDefaultValueCheck(flattenContext, value, defaultValue, location) {
65061         value = ensureIdentifier(flattenContext, value, true, location);
65062         return ts.createConditional(ts.createTypeCheck(value, "undefined"), defaultValue, value);
65063     }
65064     function createDestructuringPropertyAccess(flattenContext, value, propertyName) {
65065         if (ts.isComputedPropertyName(propertyName)) {
65066             var argumentExpression = ensureIdentifier(flattenContext, ts.visitNode(propertyName.expression, flattenContext.visitor), false, propertyName);
65067             return ts.createElementAccess(value, argumentExpression);
65068         }
65069         else if (ts.isStringOrNumericLiteralLike(propertyName)) {
65070             var argumentExpression = ts.getSynthesizedClone(propertyName);
65071             argumentExpression.text = argumentExpression.text;
65072             return ts.createElementAccess(value, argumentExpression);
65073         }
65074         else {
65075             var name = ts.createIdentifier(ts.idText(propertyName));
65076             return ts.createPropertyAccess(value, name);
65077         }
65078     }
65079     function ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location) {
65080         if (ts.isIdentifier(value) && reuseIdentifierExpressions) {
65081             return value;
65082         }
65083         else {
65084             var temp = ts.createTempVariable(undefined);
65085             if (flattenContext.hoistTempVariables) {
65086                 flattenContext.context.hoistVariableDeclaration(temp);
65087                 flattenContext.emitExpression(ts.setTextRange(ts.createAssignment(temp, value), location));
65088             }
65089             else {
65090                 flattenContext.emitBindingOrAssignment(temp, value, location, undefined);
65091             }
65092             return temp;
65093         }
65094     }
65095     function makeArrayBindingPattern(elements) {
65096         ts.Debug.assertEachNode(elements, ts.isArrayBindingElement);
65097         return ts.createArrayBindingPattern(elements);
65098     }
65099     function makeArrayAssignmentPattern(elements) {
65100         return ts.createArrayLiteral(ts.map(elements, ts.convertToArrayAssignmentElement));
65101     }
65102     function makeObjectBindingPattern(elements) {
65103         ts.Debug.assertEachNode(elements, ts.isBindingElement);
65104         return ts.createObjectBindingPattern(elements);
65105     }
65106     function makeObjectAssignmentPattern(elements) {
65107         return ts.createObjectLiteral(ts.map(elements, ts.convertToObjectAssignmentElement));
65108     }
65109     function makeBindingElement(name) {
65110         return ts.createBindingElement(undefined, undefined, name);
65111     }
65112     function makeAssignmentElement(name) {
65113         return name;
65114     }
65115     ts.restHelper = {
65116         name: "typescript:rest",
65117         importName: "__rest",
65118         scoped: false,
65119         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            };"
65120     };
65121     function createRestCall(context, value, elements, computedTempVariables, location) {
65122         context.requestEmitHelper(ts.restHelper);
65123         var propertyNames = [];
65124         var computedTempVariableOffset = 0;
65125         for (var i = 0; i < elements.length - 1; i++) {
65126             var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(elements[i]);
65127             if (propertyName) {
65128                 if (ts.isComputedPropertyName(propertyName)) {
65129                     var temp = computedTempVariables[computedTempVariableOffset];
65130                     computedTempVariableOffset++;
65131                     propertyNames.push(ts.createConditional(ts.createTypeCheck(temp, "symbol"), temp, ts.createAdd(temp, ts.createLiteral(""))));
65132                 }
65133                 else {
65134                     propertyNames.push(ts.createLiteral(propertyName));
65135                 }
65136             }
65137         }
65138         return ts.createCall(ts.getUnscopedHelperName("__rest"), undefined, [
65139             value,
65140             ts.setTextRange(ts.createArrayLiteral(propertyNames), location)
65141         ]);
65142     }
65143 })(ts || (ts = {}));
65144 var ts;
65145 (function (ts) {
65146     var ProcessLevel;
65147     (function (ProcessLevel) {
65148         ProcessLevel[ProcessLevel["LiftRestriction"] = 0] = "LiftRestriction";
65149         ProcessLevel[ProcessLevel["All"] = 1] = "All";
65150     })(ProcessLevel = ts.ProcessLevel || (ts.ProcessLevel = {}));
65151     function processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, level) {
65152         var tag = ts.visitNode(node.tag, visitor, ts.isExpression);
65153         var templateArguments = [undefined];
65154         var cookedStrings = [];
65155         var rawStrings = [];
65156         var template = node.template;
65157         if (level === ProcessLevel.LiftRestriction && !ts.hasInvalidEscape(template))
65158             return node;
65159         if (ts.isNoSubstitutionTemplateLiteral(template)) {
65160             cookedStrings.push(createTemplateCooked(template));
65161             rawStrings.push(getRawLiteral(template, currentSourceFile));
65162         }
65163         else {
65164             cookedStrings.push(createTemplateCooked(template.head));
65165             rawStrings.push(getRawLiteral(template.head, currentSourceFile));
65166             for (var _i = 0, _a = template.templateSpans; _i < _a.length; _i++) {
65167                 var templateSpan = _a[_i];
65168                 cookedStrings.push(createTemplateCooked(templateSpan.literal));
65169                 rawStrings.push(getRawLiteral(templateSpan.literal, currentSourceFile));
65170                 templateArguments.push(ts.visitNode(templateSpan.expression, visitor, ts.isExpression));
65171             }
65172         }
65173         var helperCall = createTemplateObjectHelper(context, ts.createArrayLiteral(cookedStrings), ts.createArrayLiteral(rawStrings));
65174         if (ts.isExternalModule(currentSourceFile)) {
65175             var tempVar = ts.createUniqueName("templateObject");
65176             recordTaggedTemplateString(tempVar);
65177             templateArguments[0] = ts.createLogicalOr(tempVar, ts.createAssignment(tempVar, helperCall));
65178         }
65179         else {
65180             templateArguments[0] = helperCall;
65181         }
65182         return ts.createCall(tag, undefined, templateArguments);
65183     }
65184     ts.processTaggedTemplateExpression = processTaggedTemplateExpression;
65185     function createTemplateCooked(template) {
65186         return template.templateFlags ? ts.createIdentifier("undefined") : ts.createLiteral(template.text);
65187     }
65188     function getRawLiteral(node, currentSourceFile) {
65189         var text = node.rawText;
65190         if (text === undefined) {
65191             text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node);
65192             var isLast = node.kind === 14 || node.kind === 17;
65193             text = text.substring(1, text.length - (isLast ? 1 : 2));
65194         }
65195         text = text.replace(/\r\n?/g, "\n");
65196         return ts.setTextRange(ts.createLiteral(text), node);
65197     }
65198     function createTemplateObjectHelper(context, cooked, raw) {
65199         context.requestEmitHelper(ts.templateObjectHelper);
65200         return ts.createCall(ts.getUnscopedHelperName("__makeTemplateObject"), undefined, [
65201             cooked,
65202             raw
65203         ]);
65204     }
65205     ts.templateObjectHelper = {
65206         name: "typescript:makeTemplateObject",
65207         importName: "__makeTemplateObject",
65208         scoped: false,
65209         priority: 0,
65210         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            };"
65211     };
65212 })(ts || (ts = {}));
65213 var ts;
65214 (function (ts) {
65215     var USE_NEW_TYPE_METADATA_FORMAT = false;
65216     function transformTypeScript(context) {
65217         var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
65218         var resolver = context.getEmitResolver();
65219         var compilerOptions = context.getCompilerOptions();
65220         var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
65221         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
65222         var moduleKind = ts.getEmitModuleKind(compilerOptions);
65223         var previousOnEmitNode = context.onEmitNode;
65224         var previousOnSubstituteNode = context.onSubstituteNode;
65225         context.onEmitNode = onEmitNode;
65226         context.onSubstituteNode = onSubstituteNode;
65227         context.enableSubstitution(194);
65228         context.enableSubstitution(195);
65229         var currentSourceFile;
65230         var currentNamespace;
65231         var currentNamespaceContainerName;
65232         var currentLexicalScope;
65233         var currentNameScope;
65234         var currentScopeFirstDeclarationsOfName;
65235         var currentClassHasParameterProperties;
65236         var enabledSubstitutions;
65237         var classAliases;
65238         var applicableSubstitutions;
65239         return transformSourceFileOrBundle;
65240         function transformSourceFileOrBundle(node) {
65241             if (node.kind === 291) {
65242                 return transformBundle(node);
65243             }
65244             return transformSourceFile(node);
65245         }
65246         function transformBundle(node) {
65247             return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) {
65248                 if (prepend.kind === 293) {
65249                     return ts.createUnparsedSourceFile(prepend, "js");
65250                 }
65251                 return prepend;
65252             }));
65253         }
65254         function transformSourceFile(node) {
65255             if (node.isDeclarationFile) {
65256                 return node;
65257             }
65258             currentSourceFile = node;
65259             var visited = saveStateAndInvoke(node, visitSourceFile);
65260             ts.addEmitHelpers(visited, context.readEmitHelpers());
65261             currentSourceFile = undefined;
65262             return visited;
65263         }
65264         function saveStateAndInvoke(node, f) {
65265             var savedCurrentScope = currentLexicalScope;
65266             var savedCurrentNameScope = currentNameScope;
65267             var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName;
65268             var savedCurrentClassHasParameterProperties = currentClassHasParameterProperties;
65269             onBeforeVisitNode(node);
65270             var visited = f(node);
65271             if (currentLexicalScope !== savedCurrentScope) {
65272                 currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName;
65273             }
65274             currentLexicalScope = savedCurrentScope;
65275             currentNameScope = savedCurrentNameScope;
65276             currentClassHasParameterProperties = savedCurrentClassHasParameterProperties;
65277             return visited;
65278         }
65279         function onBeforeVisitNode(node) {
65280             switch (node.kind) {
65281                 case 290:
65282                 case 251:
65283                 case 250:
65284                 case 223:
65285                     currentLexicalScope = node;
65286                     currentNameScope = undefined;
65287                     currentScopeFirstDeclarationsOfName = undefined;
65288                     break;
65289                 case 245:
65290                 case 244:
65291                     if (ts.hasModifier(node, 2)) {
65292                         break;
65293                     }
65294                     if (node.name) {
65295                         recordEmittedDeclarationInScope(node);
65296                     }
65297                     else {
65298                         ts.Debug.assert(node.kind === 245 || ts.hasModifier(node, 512));
65299                     }
65300                     if (ts.isClassDeclaration(node)) {
65301                         currentNameScope = node;
65302                     }
65303                     break;
65304             }
65305         }
65306         function visitor(node) {
65307             return saveStateAndInvoke(node, visitorWorker);
65308         }
65309         function visitorWorker(node) {
65310             if (node.transformFlags & 1) {
65311                 return visitTypeScript(node);
65312             }
65313             return node;
65314         }
65315         function sourceElementVisitor(node) {
65316             return saveStateAndInvoke(node, sourceElementVisitorWorker);
65317         }
65318         function sourceElementVisitorWorker(node) {
65319             switch (node.kind) {
65320                 case 254:
65321                 case 253:
65322                 case 259:
65323                 case 260:
65324                     return visitEllidableStatement(node);
65325                 default:
65326                     return visitorWorker(node);
65327             }
65328         }
65329         function visitEllidableStatement(node) {
65330             var parsed = ts.getParseTreeNode(node);
65331             if (parsed !== node) {
65332                 if (node.transformFlags & 1) {
65333                     return ts.visitEachChild(node, visitor, context);
65334                 }
65335                 return node;
65336             }
65337             switch (node.kind) {
65338                 case 254:
65339                     return visitImportDeclaration(node);
65340                 case 253:
65341                     return visitImportEqualsDeclaration(node);
65342                 case 259:
65343                     return visitExportAssignment(node);
65344                 case 260:
65345                     return visitExportDeclaration(node);
65346                 default:
65347                     ts.Debug.fail("Unhandled ellided statement");
65348             }
65349         }
65350         function namespaceElementVisitor(node) {
65351             return saveStateAndInvoke(node, namespaceElementVisitorWorker);
65352         }
65353         function namespaceElementVisitorWorker(node) {
65354             if (node.kind === 260 ||
65355                 node.kind === 254 ||
65356                 node.kind === 255 ||
65357                 (node.kind === 253 &&
65358                     node.moduleReference.kind === 265)) {
65359                 return undefined;
65360             }
65361             else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) {
65362                 return visitTypeScript(node);
65363             }
65364             return node;
65365         }
65366         function classElementVisitor(node) {
65367             return saveStateAndInvoke(node, classElementVisitorWorker);
65368         }
65369         function classElementVisitorWorker(node) {
65370             switch (node.kind) {
65371                 case 162:
65372                     return visitConstructor(node);
65373                 case 159:
65374                     return visitPropertyDeclaration(node);
65375                 case 167:
65376                 case 163:
65377                 case 164:
65378                 case 161:
65379                     return visitorWorker(node);
65380                 case 222:
65381                     return node;
65382                 default:
65383                     return ts.Debug.failBadSyntaxKind(node);
65384             }
65385         }
65386         function modifierVisitor(node) {
65387             if (ts.modifierToFlag(node.kind) & 2270) {
65388                 return undefined;
65389             }
65390             else if (currentNamespace && node.kind === 89) {
65391                 return undefined;
65392             }
65393             return node;
65394         }
65395         function visitTypeScript(node) {
65396             if (ts.isStatement(node) && ts.hasModifier(node, 2)) {
65397                 return ts.createNotEmittedStatement(node);
65398             }
65399             switch (node.kind) {
65400                 case 89:
65401                 case 84:
65402                     return currentNamespace ? undefined : node;
65403                 case 119:
65404                 case 117:
65405                 case 118:
65406                 case 122:
65407                 case 81:
65408                 case 130:
65409                 case 138:
65410                 case 174:
65411                 case 175:
65412                 case 176:
65413                 case 177:
65414                 case 173:
65415                 case 168:
65416                 case 155:
65417                 case 125:
65418                 case 148:
65419                 case 128:
65420                 case 143:
65421                 case 140:
65422                 case 137:
65423                 case 110:
65424                 case 144:
65425                 case 171:
65426                 case 170:
65427                 case 172:
65428                 case 169:
65429                 case 178:
65430                 case 179:
65431                 case 180:
65432                 case 182:
65433                 case 183:
65434                 case 184:
65435                 case 185:
65436                 case 186:
65437                 case 187:
65438                 case 167:
65439                 case 157:
65440                 case 247:
65441                     return undefined;
65442                 case 159:
65443                     return visitPropertyDeclaration(node);
65444                 case 252:
65445                     return undefined;
65446                 case 162:
65447                     return visitConstructor(node);
65448                 case 246:
65449                     return ts.createNotEmittedStatement(node);
65450                 case 245:
65451                     return visitClassDeclaration(node);
65452                 case 214:
65453                     return visitClassExpression(node);
65454                 case 279:
65455                     return visitHeritageClause(node);
65456                 case 216:
65457                     return visitExpressionWithTypeArguments(node);
65458                 case 161:
65459                     return visitMethodDeclaration(node);
65460                 case 163:
65461                     return visitGetAccessor(node);
65462                 case 164:
65463                     return visitSetAccessor(node);
65464                 case 244:
65465                     return visitFunctionDeclaration(node);
65466                 case 201:
65467                     return visitFunctionExpression(node);
65468                 case 202:
65469                     return visitArrowFunction(node);
65470                 case 156:
65471                     return visitParameter(node);
65472                 case 200:
65473                     return visitParenthesizedExpression(node);
65474                 case 199:
65475                 case 217:
65476                     return visitAssertionExpression(node);
65477                 case 196:
65478                     return visitCallExpression(node);
65479                 case 197:
65480                     return visitNewExpression(node);
65481                 case 198:
65482                     return visitTaggedTemplateExpression(node);
65483                 case 218:
65484                     return visitNonNullExpression(node);
65485                 case 248:
65486                     return visitEnumDeclaration(node);
65487                 case 225:
65488                     return visitVariableStatement(node);
65489                 case 242:
65490                     return visitVariableDeclaration(node);
65491                 case 249:
65492                     return visitModuleDeclaration(node);
65493                 case 253:
65494                     return visitImportEqualsDeclaration(node);
65495                 case 267:
65496                     return visitJsxSelfClosingElement(node);
65497                 case 268:
65498                     return visitJsxJsxOpeningElement(node);
65499                 default:
65500                     return ts.visitEachChild(node, visitor, context);
65501             }
65502         }
65503         function visitSourceFile(node) {
65504             var alwaysStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") &&
65505                 !(ts.isExternalModule(node) && moduleKind >= ts.ModuleKind.ES2015) &&
65506                 !ts.isJsonSourceFile(node);
65507             return ts.updateSourceFileNode(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, 0, alwaysStrict));
65508         }
65509         function shouldEmitDecorateCallForClass(node) {
65510             if (node.decorators && node.decorators.length > 0) {
65511                 return true;
65512             }
65513             var constructor = ts.getFirstConstructorWithBody(node);
65514             if (constructor) {
65515                 return ts.forEach(constructor.parameters, shouldEmitDecorateCallForParameter);
65516             }
65517             return false;
65518         }
65519         function shouldEmitDecorateCallForParameter(parameter) {
65520             return parameter.decorators !== undefined && parameter.decorators.length > 0;
65521         }
65522         function getClassFacts(node, staticProperties) {
65523             var facts = 0;
65524             if (ts.some(staticProperties))
65525                 facts |= 1;
65526             var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
65527             if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 100)
65528                 facts |= 64;
65529             if (shouldEmitDecorateCallForClass(node))
65530                 facts |= 2;
65531             if (ts.childIsDecorated(node))
65532                 facts |= 4;
65533             if (isExportOfNamespace(node))
65534                 facts |= 8;
65535             else if (isDefaultExternalModuleExport(node))
65536                 facts |= 32;
65537             else if (isNamedExternalModuleExport(node))
65538                 facts |= 16;
65539             if (languageVersion <= 1 && (facts & 7))
65540                 facts |= 128;
65541             return facts;
65542         }
65543         function hasTypeScriptClassSyntax(node) {
65544             return !!(node.transformFlags & 2048);
65545         }
65546         function isClassLikeDeclarationWithTypeScriptSyntax(node) {
65547             return ts.some(node.decorators)
65548                 || ts.some(node.typeParameters)
65549                 || ts.some(node.heritageClauses, hasTypeScriptClassSyntax)
65550                 || ts.some(node.members, hasTypeScriptClassSyntax);
65551         }
65552         function visitClassDeclaration(node) {
65553             if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasModifier(node, 1))) {
65554                 return ts.visitEachChild(node, visitor, context);
65555             }
65556             var staticProperties = ts.getProperties(node, true, true);
65557             var facts = getClassFacts(node, staticProperties);
65558             if (facts & 128) {
65559                 context.startLexicalEnvironment();
65560             }
65561             var name = node.name || (facts & 5 ? ts.getGeneratedNameForNode(node) : undefined);
65562             var classStatement = facts & 2
65563                 ? createClassDeclarationHeadWithDecorators(node, name)
65564                 : createClassDeclarationHeadWithoutDecorators(node, name, facts);
65565             var statements = [classStatement];
65566             addClassElementDecorationStatements(statements, node, false);
65567             addClassElementDecorationStatements(statements, node, true);
65568             addConstructorDecorationStatement(statements, node);
65569             if (facts & 128) {
65570                 var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19);
65571                 var localName = ts.getInternalName(node);
65572                 var outer = ts.createPartiallyEmittedExpression(localName);
65573                 outer.end = closingBraceLocation.end;
65574                 ts.setEmitFlags(outer, 1536);
65575                 var statement = ts.createReturn(outer);
65576                 statement.pos = closingBraceLocation.pos;
65577                 ts.setEmitFlags(statement, 1536 | 384);
65578                 statements.push(statement);
65579                 ts.insertStatementsAfterStandardPrologue(statements, context.endLexicalEnvironment());
65580                 var iife = ts.createImmediatelyInvokedArrowFunction(statements);
65581                 ts.setEmitFlags(iife, 33554432);
65582                 var varStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
65583                     ts.createVariableDeclaration(ts.getLocalName(node, false, false), undefined, iife)
65584                 ]));
65585                 ts.setOriginalNode(varStatement, node);
65586                 ts.setCommentRange(varStatement, node);
65587                 ts.setSourceMapRange(varStatement, ts.moveRangePastDecorators(node));
65588                 ts.startOnNewLine(varStatement);
65589                 statements = [varStatement];
65590             }
65591             if (facts & 8) {
65592                 addExportMemberAssignment(statements, node);
65593             }
65594             else if (facts & 128 || facts & 2) {
65595                 if (facts & 32) {
65596                     statements.push(ts.createExportDefault(ts.getLocalName(node, false, true)));
65597                 }
65598                 else if (facts & 16) {
65599                     statements.push(ts.createExternalModuleExport(ts.getLocalName(node, false, true)));
65600                 }
65601             }
65602             if (statements.length > 1) {
65603                 statements.push(ts.createEndOfDeclarationMarker(node));
65604                 ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304);
65605             }
65606             return ts.singleOrMany(statements);
65607         }
65608         function createClassDeclarationHeadWithoutDecorators(node, name, facts) {
65609             var modifiers = !(facts & 128)
65610                 ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier)
65611                 : undefined;
65612             var classDeclaration = ts.createClassDeclaration(undefined, modifiers, name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
65613             var emitFlags = ts.getEmitFlags(node);
65614             if (facts & 1) {
65615                 emitFlags |= 32;
65616             }
65617             ts.aggregateTransformFlags(classDeclaration);
65618             ts.setTextRange(classDeclaration, node);
65619             ts.setOriginalNode(classDeclaration, node);
65620             ts.setEmitFlags(classDeclaration, emitFlags);
65621             return classDeclaration;
65622         }
65623         function createClassDeclarationHeadWithDecorators(node, name) {
65624             var location = ts.moveRangePastDecorators(node);
65625             var classAlias = getClassAliasIfNeeded(node);
65626             var declName = ts.getLocalName(node, false, true);
65627             var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
65628             var members = transformClassMembers(node);
65629             var classExpression = ts.createClassExpression(undefined, name, undefined, heritageClauses, members);
65630             ts.aggregateTransformFlags(classExpression);
65631             ts.setOriginalNode(classExpression, node);
65632             ts.setTextRange(classExpression, location);
65633             var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
65634                 ts.createVariableDeclaration(declName, undefined, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression)
65635             ], 1));
65636             ts.setOriginalNode(statement, node);
65637             ts.setTextRange(statement, location);
65638             ts.setCommentRange(statement, node);
65639             return statement;
65640         }
65641         function visitClassExpression(node) {
65642             if (!isClassLikeDeclarationWithTypeScriptSyntax(node)) {
65643                 return ts.visitEachChild(node, visitor, context);
65644             }
65645             var classExpression = ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
65646             ts.aggregateTransformFlags(classExpression);
65647             ts.setOriginalNode(classExpression, node);
65648             ts.setTextRange(classExpression, node);
65649             return classExpression;
65650         }
65651         function transformClassMembers(node) {
65652             var members = [];
65653             var constructor = ts.getFirstConstructorWithBody(node);
65654             var parametersWithPropertyAssignments = constructor &&
65655                 ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); });
65656             if (parametersWithPropertyAssignments) {
65657                 for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) {
65658                     var parameter = parametersWithPropertyAssignments_1[_i];
65659                     if (ts.isIdentifier(parameter.name)) {
65660                         members.push(ts.setOriginalNode(ts.aggregateTransformFlags(ts.createProperty(undefined, undefined, parameter.name, undefined, undefined, undefined)), parameter));
65661                     }
65662                 }
65663             }
65664             ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
65665             return ts.setTextRange(ts.createNodeArray(members), node.members);
65666         }
65667         function getDecoratedClassElements(node, isStatic) {
65668             return ts.filter(node.members, isStatic ? function (m) { return isStaticDecoratedClassElement(m, node); } : function (m) { return isInstanceDecoratedClassElement(m, node); });
65669         }
65670         function isStaticDecoratedClassElement(member, parent) {
65671             return isDecoratedClassElement(member, true, parent);
65672         }
65673         function isInstanceDecoratedClassElement(member, parent) {
65674             return isDecoratedClassElement(member, false, parent);
65675         }
65676         function isDecoratedClassElement(member, isStatic, parent) {
65677             return ts.nodeOrChildIsDecorated(member, parent)
65678                 && isStatic === ts.hasModifier(member, 32);
65679         }
65680         function getDecoratorsOfParameters(node) {
65681             var decorators;
65682             if (node) {
65683                 var parameters = node.parameters;
65684                 var firstParameterIsThis = parameters.length > 0 && ts.parameterIsThisKeyword(parameters[0]);
65685                 var firstParameterOffset = firstParameterIsThis ? 1 : 0;
65686                 var numParameters = firstParameterIsThis ? parameters.length - 1 : parameters.length;
65687                 for (var i = 0; i < numParameters; i++) {
65688                     var parameter = parameters[i + firstParameterOffset];
65689                     if (decorators || parameter.decorators) {
65690                         if (!decorators) {
65691                             decorators = new Array(numParameters);
65692                         }
65693                         decorators[i] = parameter.decorators;
65694                     }
65695                 }
65696             }
65697             return decorators;
65698         }
65699         function getAllDecoratorsOfConstructor(node) {
65700             var decorators = node.decorators;
65701             var parameters = getDecoratorsOfParameters(ts.getFirstConstructorWithBody(node));
65702             if (!decorators && !parameters) {
65703                 return undefined;
65704             }
65705             return {
65706                 decorators: decorators,
65707                 parameters: parameters
65708             };
65709         }
65710         function getAllDecoratorsOfClassElement(node, member) {
65711             switch (member.kind) {
65712                 case 163:
65713                 case 164:
65714                     return getAllDecoratorsOfAccessors(node, member);
65715                 case 161:
65716                     return getAllDecoratorsOfMethod(member);
65717                 case 159:
65718                     return getAllDecoratorsOfProperty(member);
65719                 default:
65720                     return undefined;
65721             }
65722         }
65723         function getAllDecoratorsOfAccessors(node, accessor) {
65724             if (!accessor.body) {
65725                 return undefined;
65726             }
65727             var _a = ts.getAllAccessorDeclarations(node.members, accessor), firstAccessor = _a.firstAccessor, secondAccessor = _a.secondAccessor, setAccessor = _a.setAccessor;
65728             var firstAccessorWithDecorators = firstAccessor.decorators ? firstAccessor : secondAccessor && secondAccessor.decorators ? secondAccessor : undefined;
65729             if (!firstAccessorWithDecorators || accessor !== firstAccessorWithDecorators) {
65730                 return undefined;
65731             }
65732             var decorators = firstAccessorWithDecorators.decorators;
65733             var parameters = getDecoratorsOfParameters(setAccessor);
65734             if (!decorators && !parameters) {
65735                 return undefined;
65736             }
65737             return { decorators: decorators, parameters: parameters };
65738         }
65739         function getAllDecoratorsOfMethod(method) {
65740             if (!method.body) {
65741                 return undefined;
65742             }
65743             var decorators = method.decorators;
65744             var parameters = getDecoratorsOfParameters(method);
65745             if (!decorators && !parameters) {
65746                 return undefined;
65747             }
65748             return { decorators: decorators, parameters: parameters };
65749         }
65750         function getAllDecoratorsOfProperty(property) {
65751             var decorators = property.decorators;
65752             if (!decorators) {
65753                 return undefined;
65754             }
65755             return { decorators: decorators };
65756         }
65757         function transformAllDecoratorsOfDeclaration(node, container, allDecorators) {
65758             if (!allDecorators) {
65759                 return undefined;
65760             }
65761             var decoratorExpressions = [];
65762             ts.addRange(decoratorExpressions, ts.map(allDecorators.decorators, transformDecorator));
65763             ts.addRange(decoratorExpressions, ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter));
65764             addTypeMetadata(node, container, decoratorExpressions);
65765             return decoratorExpressions;
65766         }
65767         function addClassElementDecorationStatements(statements, node, isStatic) {
65768             ts.addRange(statements, ts.map(generateClassElementDecorationExpressions(node, isStatic), expressionToStatement));
65769         }
65770         function generateClassElementDecorationExpressions(node, isStatic) {
65771             var members = getDecoratedClassElements(node, isStatic);
65772             var expressions;
65773             for (var _i = 0, members_6 = members; _i < members_6.length; _i++) {
65774                 var member = members_6[_i];
65775                 var expression = generateClassElementDecorationExpression(node, member);
65776                 if (expression) {
65777                     if (!expressions) {
65778                         expressions = [expression];
65779                     }
65780                     else {
65781                         expressions.push(expression);
65782                     }
65783                 }
65784             }
65785             return expressions;
65786         }
65787         function generateClassElementDecorationExpression(node, member) {
65788             var allDecorators = getAllDecoratorsOfClassElement(node, member);
65789             var decoratorExpressions = transformAllDecoratorsOfDeclaration(member, node, allDecorators);
65790             if (!decoratorExpressions) {
65791                 return undefined;
65792             }
65793             var prefix = getClassMemberPrefix(node, member);
65794             var memberName = getExpressionForPropertyName(member, true);
65795             var descriptor = languageVersion > 0
65796                 ? member.kind === 159
65797                     ? ts.createVoidZero()
65798                     : ts.createNull()
65799                 : undefined;
65800             var helper = createDecorateHelper(context, decoratorExpressions, prefix, memberName, descriptor, ts.moveRangePastDecorators(member));
65801             ts.setEmitFlags(helper, 1536);
65802             return helper;
65803         }
65804         function addConstructorDecorationStatement(statements, node) {
65805             var expression = generateConstructorDecorationExpression(node);
65806             if (expression) {
65807                 statements.push(ts.setOriginalNode(ts.createExpressionStatement(expression), node));
65808             }
65809         }
65810         function generateConstructorDecorationExpression(node) {
65811             var allDecorators = getAllDecoratorsOfConstructor(node);
65812             var decoratorExpressions = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
65813             if (!decoratorExpressions) {
65814                 return undefined;
65815             }
65816             var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)];
65817             var localName = ts.getLocalName(node, false, true);
65818             var decorate = createDecorateHelper(context, decoratorExpressions, localName);
65819             var expression = ts.createAssignment(localName, classAlias ? ts.createAssignment(classAlias, decorate) : decorate);
65820             ts.setEmitFlags(expression, 1536);
65821             ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node));
65822             return expression;
65823         }
65824         function transformDecorator(decorator) {
65825             return ts.visitNode(decorator.expression, visitor, ts.isExpression);
65826         }
65827         function transformDecoratorsOfParameter(decorators, parameterOffset) {
65828             var expressions;
65829             if (decorators) {
65830                 expressions = [];
65831                 for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) {
65832                     var decorator = decorators_1[_i];
65833                     var helper = createParamHelper(context, transformDecorator(decorator), parameterOffset, decorator.expression);
65834                     ts.setEmitFlags(helper, 1536);
65835                     expressions.push(helper);
65836                 }
65837             }
65838             return expressions;
65839         }
65840         function addTypeMetadata(node, container, decoratorExpressions) {
65841             if (USE_NEW_TYPE_METADATA_FORMAT) {
65842                 addNewTypeMetadata(node, container, decoratorExpressions);
65843             }
65844             else {
65845                 addOldTypeMetadata(node, container, decoratorExpressions);
65846             }
65847         }
65848         function addOldTypeMetadata(node, container, decoratorExpressions) {
65849             if (compilerOptions.emitDecoratorMetadata) {
65850                 if (shouldAddTypeMetadata(node)) {
65851                     decoratorExpressions.push(createMetadataHelper(context, "design:type", serializeTypeOfNode(node)));
65852                 }
65853                 if (shouldAddParamTypesMetadata(node)) {
65854                     decoratorExpressions.push(createMetadataHelper(context, "design:paramtypes", serializeParameterTypesOfNode(node, container)));
65855                 }
65856                 if (shouldAddReturnTypeMetadata(node)) {
65857                     decoratorExpressions.push(createMetadataHelper(context, "design:returntype", serializeReturnTypeOfNode(node)));
65858                 }
65859             }
65860         }
65861         function addNewTypeMetadata(node, container, decoratorExpressions) {
65862             if (compilerOptions.emitDecoratorMetadata) {
65863                 var properties = void 0;
65864                 if (shouldAddTypeMetadata(node)) {
65865                     (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(38), serializeTypeOfNode(node))));
65866                 }
65867                 if (shouldAddParamTypesMetadata(node)) {
65868                     (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(38), serializeParameterTypesOfNode(node, container))));
65869                 }
65870                 if (shouldAddReturnTypeMetadata(node)) {
65871                     (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(38), serializeReturnTypeOfNode(node))));
65872                 }
65873                 if (properties) {
65874                     decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, true)));
65875                 }
65876             }
65877         }
65878         function shouldAddTypeMetadata(node) {
65879             var kind = node.kind;
65880             return kind === 161
65881                 || kind === 163
65882                 || kind === 164
65883                 || kind === 159;
65884         }
65885         function shouldAddReturnTypeMetadata(node) {
65886             return node.kind === 161;
65887         }
65888         function shouldAddParamTypesMetadata(node) {
65889             switch (node.kind) {
65890                 case 245:
65891                 case 214:
65892                     return ts.getFirstConstructorWithBody(node) !== undefined;
65893                 case 161:
65894                 case 163:
65895                 case 164:
65896                     return true;
65897             }
65898             return false;
65899         }
65900         function getAccessorTypeNode(node) {
65901             var accessors = resolver.getAllAccessorDeclarations(node);
65902             return accessors.setAccessor && ts.getSetAccessorTypeAnnotationNode(accessors.setAccessor)
65903                 || accessors.getAccessor && ts.getEffectiveReturnTypeNode(accessors.getAccessor);
65904         }
65905         function serializeTypeOfNode(node) {
65906             switch (node.kind) {
65907                 case 159:
65908                 case 156:
65909                     return serializeTypeNode(node.type);
65910                 case 164:
65911                 case 163:
65912                     return serializeTypeNode(getAccessorTypeNode(node));
65913                 case 245:
65914                 case 214:
65915                 case 161:
65916                     return ts.createIdentifier("Function");
65917                 default:
65918                     return ts.createVoidZero();
65919             }
65920         }
65921         function serializeParameterTypesOfNode(node, container) {
65922             var valueDeclaration = ts.isClassLike(node)
65923                 ? ts.getFirstConstructorWithBody(node)
65924                 : ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)
65925                     ? node
65926                     : undefined;
65927             var expressions = [];
65928             if (valueDeclaration) {
65929                 var parameters = getParametersOfDecoratedDeclaration(valueDeclaration, container);
65930                 var numParameters = parameters.length;
65931                 for (var i = 0; i < numParameters; i++) {
65932                     var parameter = parameters[i];
65933                     if (i === 0 && ts.isIdentifier(parameter.name) && parameter.name.escapedText === "this") {
65934                         continue;
65935                     }
65936                     if (parameter.dotDotDotToken) {
65937                         expressions.push(serializeTypeNode(ts.getRestParameterElementType(parameter.type)));
65938                     }
65939                     else {
65940                         expressions.push(serializeTypeOfNode(parameter));
65941                     }
65942                 }
65943             }
65944             return ts.createArrayLiteral(expressions);
65945         }
65946         function getParametersOfDecoratedDeclaration(node, container) {
65947             if (container && node.kind === 163) {
65948                 var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor;
65949                 if (setAccessor) {
65950                     return setAccessor.parameters;
65951                 }
65952             }
65953             return node.parameters;
65954         }
65955         function serializeReturnTypeOfNode(node) {
65956             if (ts.isFunctionLike(node) && node.type) {
65957                 return serializeTypeNode(node.type);
65958             }
65959             else if (ts.isAsyncFunction(node)) {
65960                 return ts.createIdentifier("Promise");
65961             }
65962             return ts.createVoidZero();
65963         }
65964         function serializeTypeNode(node) {
65965             if (node === undefined) {
65966                 return ts.createIdentifier("Object");
65967             }
65968             switch (node.kind) {
65969                 case 110:
65970                 case 146:
65971                 case 100:
65972                 case 137:
65973                     return ts.createVoidZero();
65974                 case 182:
65975                     return serializeTypeNode(node.type);
65976                 case 170:
65977                 case 171:
65978                     return ts.createIdentifier("Function");
65979                 case 174:
65980                 case 175:
65981                     return ts.createIdentifier("Array");
65982                 case 168:
65983                 case 128:
65984                     return ts.createIdentifier("Boolean");
65985                 case 143:
65986                     return ts.createIdentifier("String");
65987                 case 141:
65988                     return ts.createIdentifier("Object");
65989                 case 187:
65990                     switch (node.literal.kind) {
65991                         case 10:
65992                             return ts.createIdentifier("String");
65993                         case 207:
65994                         case 8:
65995                             return ts.createIdentifier("Number");
65996                         case 9:
65997                             return getGlobalBigIntNameWithFallback();
65998                         case 106:
65999                         case 91:
66000                             return ts.createIdentifier("Boolean");
66001                         default:
66002                             return ts.Debug.failBadSyntaxKind(node.literal);
66003                     }
66004                 case 140:
66005                     return ts.createIdentifier("Number");
66006                 case 151:
66007                     return getGlobalBigIntNameWithFallback();
66008                 case 144:
66009                     return languageVersion < 2
66010                         ? getGlobalSymbolNameWithFallback()
66011                         : ts.createIdentifier("Symbol");
66012                 case 169:
66013                     return serializeTypeReferenceNode(node);
66014                 case 179:
66015                 case 178:
66016                     return serializeTypeList(node.types);
66017                 case 180:
66018                     return serializeTypeList([node.trueType, node.falseType]);
66019                 case 184:
66020                     if (node.operator === 138) {
66021                         return serializeTypeNode(node.type);
66022                     }
66023                     break;
66024                 case 172:
66025                 case 185:
66026                 case 186:
66027                 case 173:
66028                 case 125:
66029                 case 148:
66030                 case 183:
66031                 case 188:
66032                     break;
66033                 case 295:
66034                 case 296:
66035                 case 300:
66036                 case 301:
66037                 case 302:
66038                     break;
66039                 case 297:
66040                 case 298:
66041                 case 299:
66042                     return serializeTypeNode(node.type);
66043                 default:
66044                     return ts.Debug.failBadSyntaxKind(node);
66045             }
66046             return ts.createIdentifier("Object");
66047         }
66048         function serializeTypeList(types) {
66049             var serializedUnion;
66050             for (var _i = 0, types_21 = types; _i < types_21.length; _i++) {
66051                 var typeNode = types_21[_i];
66052                 while (typeNode.kind === 182) {
66053                     typeNode = typeNode.type;
66054                 }
66055                 if (typeNode.kind === 137) {
66056                     continue;
66057                 }
66058                 if (!strictNullChecks && (typeNode.kind === 100 || typeNode.kind === 146)) {
66059                     continue;
66060                 }
66061                 var serializedIndividual = serializeTypeNode(typeNode);
66062                 if (ts.isIdentifier(serializedIndividual) && serializedIndividual.escapedText === "Object") {
66063                     return serializedIndividual;
66064                 }
66065                 else if (serializedUnion) {
66066                     if (!ts.isIdentifier(serializedUnion) ||
66067                         !ts.isIdentifier(serializedIndividual) ||
66068                         serializedUnion.escapedText !== serializedIndividual.escapedText) {
66069                         return ts.createIdentifier("Object");
66070                     }
66071                 }
66072                 else {
66073                     serializedUnion = serializedIndividual;
66074                 }
66075             }
66076             return serializedUnion || ts.createVoidZero();
66077         }
66078         function serializeTypeReferenceNode(node) {
66079             var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope);
66080             switch (kind) {
66081                 case ts.TypeReferenceSerializationKind.Unknown:
66082                     if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) {
66083                         return ts.createIdentifier("Object");
66084                     }
66085                     var serialized = serializeEntityNameAsExpressionFallback(node.typeName);
66086                     var temp = ts.createTempVariable(hoistVariableDeclaration);
66087                     return ts.createConditional(ts.createTypeCheck(ts.createAssignment(temp, serialized), "function"), temp, ts.createIdentifier("Object"));
66088                 case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
66089                     return serializeEntityNameAsExpression(node.typeName);
66090                 case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType:
66091                     return ts.createVoidZero();
66092                 case ts.TypeReferenceSerializationKind.BigIntLikeType:
66093                     return getGlobalBigIntNameWithFallback();
66094                 case ts.TypeReferenceSerializationKind.BooleanType:
66095                     return ts.createIdentifier("Boolean");
66096                 case ts.TypeReferenceSerializationKind.NumberLikeType:
66097                     return ts.createIdentifier("Number");
66098                 case ts.TypeReferenceSerializationKind.StringLikeType:
66099                     return ts.createIdentifier("String");
66100                 case ts.TypeReferenceSerializationKind.ArrayLikeType:
66101                     return ts.createIdentifier("Array");
66102                 case ts.TypeReferenceSerializationKind.ESSymbolType:
66103                     return languageVersion < 2
66104                         ? getGlobalSymbolNameWithFallback()
66105                         : ts.createIdentifier("Symbol");
66106                 case ts.TypeReferenceSerializationKind.TypeWithCallSignature:
66107                     return ts.createIdentifier("Function");
66108                 case ts.TypeReferenceSerializationKind.Promise:
66109                     return ts.createIdentifier("Promise");
66110                 case ts.TypeReferenceSerializationKind.ObjectType:
66111                     return ts.createIdentifier("Object");
66112                 default:
66113                     return ts.Debug.assertNever(kind);
66114             }
66115         }
66116         function createCheckedValue(left, right) {
66117             return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(left), ts.createLiteral("undefined")), right);
66118         }
66119         function serializeEntityNameAsExpressionFallback(node) {
66120             if (node.kind === 75) {
66121                 var copied = serializeEntityNameAsExpression(node);
66122                 return createCheckedValue(copied, copied);
66123             }
66124             if (node.left.kind === 75) {
66125                 return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node));
66126             }
66127             var left = serializeEntityNameAsExpressionFallback(node.left);
66128             var temp = ts.createTempVariable(hoistVariableDeclaration);
66129             return ts.createLogicalAnd(ts.createLogicalAnd(left.left, ts.createStrictInequality(ts.createAssignment(temp, left.right), ts.createVoidZero())), ts.createPropertyAccess(temp, node.right));
66130         }
66131         function serializeEntityNameAsExpression(node) {
66132             switch (node.kind) {
66133                 case 75:
66134                     var name = ts.getMutableClone(node);
66135                     name.flags &= ~8;
66136                     name.original = undefined;
66137                     name.parent = ts.getParseTreeNode(currentLexicalScope);
66138                     return name;
66139                 case 153:
66140                     return serializeQualifiedNameAsExpression(node);
66141             }
66142         }
66143         function serializeQualifiedNameAsExpression(node) {
66144             return ts.createPropertyAccess(serializeEntityNameAsExpression(node.left), node.right);
66145         }
66146         function getGlobalSymbolNameWithFallback() {
66147             return ts.createConditional(ts.createTypeCheck(ts.createIdentifier("Symbol"), "function"), ts.createIdentifier("Symbol"), ts.createIdentifier("Object"));
66148         }
66149         function getGlobalBigIntNameWithFallback() {
66150             return languageVersion < 99
66151                 ? ts.createConditional(ts.createTypeCheck(ts.createIdentifier("BigInt"), "function"), ts.createIdentifier("BigInt"), ts.createIdentifier("Object"))
66152                 : ts.createIdentifier("BigInt");
66153         }
66154         function getExpressionForPropertyName(member, generateNameForComputedPropertyName) {
66155             var name = member.name;
66156             if (ts.isPrivateIdentifier(name)) {
66157                 return ts.createIdentifier("");
66158             }
66159             else if (ts.isComputedPropertyName(name)) {
66160                 return generateNameForComputedPropertyName && !ts.isSimpleInlineableExpression(name.expression)
66161                     ? ts.getGeneratedNameForNode(name)
66162                     : name.expression;
66163             }
66164             else if (ts.isIdentifier(name)) {
66165                 return ts.createLiteral(ts.idText(name));
66166             }
66167             else {
66168                 return ts.getSynthesizedClone(name);
66169             }
66170         }
66171         function visitPropertyNameOfClassElement(member) {
66172             var name = member.name;
66173             if (ts.isComputedPropertyName(name) && ((!ts.hasStaticModifier(member) && currentClassHasParameterProperties) || ts.some(member.decorators))) {
66174                 var expression = ts.visitNode(name.expression, visitor, ts.isExpression);
66175                 var innerExpression = ts.skipPartiallyEmittedExpressions(expression);
66176                 if (!ts.isSimpleInlineableExpression(innerExpression)) {
66177                     var generatedName = ts.getGeneratedNameForNode(name);
66178                     hoistVariableDeclaration(generatedName);
66179                     return ts.updateComputedPropertyName(name, ts.createAssignment(generatedName, expression));
66180                 }
66181             }
66182             return ts.visitNode(name, visitor, ts.isPropertyName);
66183         }
66184         function visitHeritageClause(node) {
66185             if (node.token === 113) {
66186                 return undefined;
66187             }
66188             return ts.visitEachChild(node, visitor, context);
66189         }
66190         function visitExpressionWithTypeArguments(node) {
66191             return ts.updateExpressionWithTypeArguments(node, undefined, ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression));
66192         }
66193         function shouldEmitFunctionLikeDeclaration(node) {
66194             return !ts.nodeIsMissing(node.body);
66195         }
66196         function visitPropertyDeclaration(node) {
66197             if (node.flags & 8388608) {
66198                 return undefined;
66199             }
66200             var updated = ts.updateProperty(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), undefined, undefined, ts.visitNode(node.initializer, visitor));
66201             if (updated !== node) {
66202                 ts.setCommentRange(updated, node);
66203                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
66204             }
66205             return updated;
66206         }
66207         function visitConstructor(node) {
66208             if (!shouldEmitFunctionLikeDeclaration(node)) {
66209                 return undefined;
66210             }
66211             return ts.updateConstructor(node, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), transformConstructorBody(node.body, node));
66212         }
66213         function transformConstructorBody(body, constructor) {
66214             var parametersWithPropertyAssignments = constructor &&
66215                 ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); });
66216             if (!ts.some(parametersWithPropertyAssignments)) {
66217                 return ts.visitFunctionBody(body, visitor, context);
66218             }
66219             var statements = [];
66220             var indexOfFirstStatement = 0;
66221             resumeLexicalEnvironment();
66222             indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(constructor, statements, visitor);
66223             ts.addRange(statements, ts.map(parametersWithPropertyAssignments, transformParameterWithPropertyAssignment));
66224             ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexOfFirstStatement));
66225             statements = ts.mergeLexicalEnvironment(statements, endLexicalEnvironment());
66226             var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), body.statements), true);
66227             ts.setTextRange(block, body);
66228             ts.setOriginalNode(block, body);
66229             return block;
66230         }
66231         function transformParameterWithPropertyAssignment(node) {
66232             var name = node.name;
66233             if (!ts.isIdentifier(name)) {
66234                 return undefined;
66235             }
66236             var propertyName = ts.getMutableClone(name);
66237             ts.setEmitFlags(propertyName, 1536 | 48);
66238             var localName = ts.getMutableClone(name);
66239             ts.setEmitFlags(localName, 1536);
66240             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))));
66241         }
66242         function visitMethodDeclaration(node) {
66243             if (!shouldEmitFunctionLikeDeclaration(node)) {
66244                 return undefined;
66245             }
66246             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));
66247             if (updated !== node) {
66248                 ts.setCommentRange(updated, node);
66249                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
66250             }
66251             return updated;
66252         }
66253         function shouldEmitAccessorDeclaration(node) {
66254             return !(ts.nodeIsMissing(node.body) && ts.hasModifier(node, 128));
66255         }
66256         function visitGetAccessor(node) {
66257             if (!shouldEmitAccessorDeclaration(node)) {
66258                 return undefined;
66259             }
66260             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([]));
66261             if (updated !== node) {
66262                 ts.setCommentRange(updated, node);
66263                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
66264             }
66265             return updated;
66266         }
66267         function visitSetAccessor(node) {
66268             if (!shouldEmitAccessorDeclaration(node)) {
66269                 return undefined;
66270             }
66271             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([]));
66272             if (updated !== node) {
66273                 ts.setCommentRange(updated, node);
66274                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
66275             }
66276             return updated;
66277         }
66278         function visitFunctionDeclaration(node) {
66279             if (!shouldEmitFunctionLikeDeclaration(node)) {
66280                 return ts.createNotEmittedStatement(node);
66281             }
66282             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([]));
66283             if (isExportOfNamespace(node)) {
66284                 var statements = [updated];
66285                 addExportMemberAssignment(statements, node);
66286                 return statements;
66287             }
66288             return updated;
66289         }
66290         function visitFunctionExpression(node) {
66291             if (!shouldEmitFunctionLikeDeclaration(node)) {
66292                 return ts.createOmittedExpression();
66293             }
66294             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([]));
66295             return updated;
66296         }
66297         function visitArrowFunction(node) {
66298             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));
66299             return updated;
66300         }
66301         function visitParameter(node) {
66302             if (ts.parameterIsThisKeyword(node)) {
66303                 return undefined;
66304             }
66305             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));
66306             if (updated !== node) {
66307                 ts.setCommentRange(updated, node);
66308                 ts.setTextRange(updated, ts.moveRangePastModifiers(node));
66309                 ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node));
66310                 ts.setEmitFlags(updated.name, 32);
66311             }
66312             return updated;
66313         }
66314         function visitVariableStatement(node) {
66315             if (isExportOfNamespace(node)) {
66316                 var variables = ts.getInitializedVariables(node.declarationList);
66317                 if (variables.length === 0) {
66318                     return undefined;
66319                 }
66320                 return ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node);
66321             }
66322             else {
66323                 return ts.visitEachChild(node, visitor, context);
66324             }
66325         }
66326         function transformInitializedVariable(node) {
66327             var name = node.name;
66328             if (ts.isBindingPattern(name)) {
66329                 return ts.flattenDestructuringAssignment(node, visitor, context, 0, false, createNamespaceExportExpression);
66330             }
66331             else {
66332                 return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression)), node);
66333             }
66334         }
66335         function visitVariableDeclaration(node) {
66336             return ts.updateTypeScriptVariableDeclaration(node, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
66337         }
66338         function visitParenthesizedExpression(node) {
66339             var innerExpression = ts.skipOuterExpressions(node.expression, ~6);
66340             if (ts.isAssertionExpression(innerExpression)) {
66341                 var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
66342                 if (ts.length(ts.getLeadingCommentRangesOfNode(expression, currentSourceFile))) {
66343                     return ts.updateParen(node, expression);
66344                 }
66345                 return ts.createPartiallyEmittedExpression(expression, node);
66346             }
66347             return ts.visitEachChild(node, visitor, context);
66348         }
66349         function visitAssertionExpression(node) {
66350             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
66351             return ts.createPartiallyEmittedExpression(expression, node);
66352         }
66353         function visitNonNullExpression(node) {
66354             var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression);
66355             return ts.createPartiallyEmittedExpression(expression, node);
66356         }
66357         function visitCallExpression(node) {
66358             return ts.updateCall(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression));
66359         }
66360         function visitNewExpression(node) {
66361             return ts.updateNew(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression));
66362         }
66363         function visitTaggedTemplateExpression(node) {
66364             return ts.updateTaggedTemplate(node, ts.visitNode(node.tag, visitor, ts.isExpression), undefined, ts.visitNode(node.template, visitor, ts.isExpression));
66365         }
66366         function visitJsxSelfClosingElement(node) {
66367             return ts.updateJsxSelfClosingElement(node, ts.visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), undefined, ts.visitNode(node.attributes, visitor, ts.isJsxAttributes));
66368         }
66369         function visitJsxJsxOpeningElement(node) {
66370             return ts.updateJsxOpeningElement(node, ts.visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), undefined, ts.visitNode(node.attributes, visitor, ts.isJsxAttributes));
66371         }
66372         function shouldEmitEnumDeclaration(node) {
66373             return !ts.isEnumConst(node)
66374                 || compilerOptions.preserveConstEnums
66375                 || compilerOptions.isolatedModules;
66376         }
66377         function visitEnumDeclaration(node) {
66378             if (!shouldEmitEnumDeclaration(node)) {
66379                 return ts.createNotEmittedStatement(node);
66380             }
66381             var statements = [];
66382             var emitFlags = 2;
66383             var varAdded = addVarForEnumOrModuleDeclaration(statements, node);
66384             if (varAdded) {
66385                 if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) {
66386                     emitFlags |= 512;
66387                 }
66388             }
66389             var parameterName = getNamespaceParameterName(node);
66390             var containerName = getNamespaceContainerName(node);
66391             var exportName = ts.hasModifier(node, 1)
66392                 ? ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true)
66393                 : ts.getLocalName(node, false, true);
66394             var moduleArg = ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()));
66395             if (hasNamespaceQualifiedExportName(node)) {
66396                 var localName = ts.getLocalName(node, false, true);
66397                 moduleArg = ts.createAssignment(localName, moduleArg);
66398             }
66399             var enumStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg]));
66400             ts.setOriginalNode(enumStatement, node);
66401             if (varAdded) {
66402                 ts.setSyntheticLeadingComments(enumStatement, undefined);
66403                 ts.setSyntheticTrailingComments(enumStatement, undefined);
66404             }
66405             ts.setTextRange(enumStatement, node);
66406             ts.addEmitFlags(enumStatement, emitFlags);
66407             statements.push(enumStatement);
66408             statements.push(ts.createEndOfDeclarationMarker(node));
66409             return statements;
66410         }
66411         function transformEnumBody(node, localName) {
66412             var savedCurrentNamespaceLocalName = currentNamespaceContainerName;
66413             currentNamespaceContainerName = localName;
66414             var statements = [];
66415             startLexicalEnvironment();
66416             var members = ts.map(node.members, transformEnumMember);
66417             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
66418             ts.addRange(statements, members);
66419             currentNamespaceContainerName = savedCurrentNamespaceLocalName;
66420             return ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true);
66421         }
66422         function transformEnumMember(member) {
66423             var name = getExpressionForPropertyName(member, false);
66424             var valueExpression = transformEnumMemberDeclarationValue(member);
66425             var innerAssignment = ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), valueExpression);
66426             var outerAssignment = valueExpression.kind === 10 ?
66427                 innerAssignment :
66428                 ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, innerAssignment), name);
66429             return ts.setTextRange(ts.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member);
66430         }
66431         function transformEnumMemberDeclarationValue(member) {
66432             var value = resolver.getConstantValue(member);
66433             if (value !== undefined) {
66434                 return ts.createLiteral(value);
66435             }
66436             else {
66437                 enableSubstitutionForNonQualifiedEnumMembers();
66438                 if (member.initializer) {
66439                     return ts.visitNode(member.initializer, visitor, ts.isExpression);
66440                 }
66441                 else {
66442                     return ts.createVoidZero();
66443                 }
66444             }
66445         }
66446         function shouldEmitModuleDeclaration(nodeIn) {
66447             var node = ts.getParseTreeNode(nodeIn, ts.isModuleDeclaration);
66448             if (!node) {
66449                 return true;
66450             }
66451             return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules);
66452         }
66453         function hasNamespaceQualifiedExportName(node) {
66454             return isExportOfNamespace(node)
66455                 || (isExternalModuleExport(node)
66456                     && moduleKind !== ts.ModuleKind.ES2015
66457                     && moduleKind !== ts.ModuleKind.ES2020
66458                     && moduleKind !== ts.ModuleKind.ESNext
66459                     && moduleKind !== ts.ModuleKind.System);
66460         }
66461         function recordEmittedDeclarationInScope(node) {
66462             if (!currentScopeFirstDeclarationsOfName) {
66463                 currentScopeFirstDeclarationsOfName = ts.createUnderscoreEscapedMap();
66464             }
66465             var name = declaredNameInScope(node);
66466             if (!currentScopeFirstDeclarationsOfName.has(name)) {
66467                 currentScopeFirstDeclarationsOfName.set(name, node);
66468             }
66469         }
66470         function isFirstEmittedDeclarationInScope(node) {
66471             if (currentScopeFirstDeclarationsOfName) {
66472                 var name = declaredNameInScope(node);
66473                 return currentScopeFirstDeclarationsOfName.get(name) === node;
66474             }
66475             return true;
66476         }
66477         function declaredNameInScope(node) {
66478             ts.Debug.assertNode(node.name, ts.isIdentifier);
66479             return node.name.escapedText;
66480         }
66481         function addVarForEnumOrModuleDeclaration(statements, node) {
66482             var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([
66483                 ts.createVariableDeclaration(ts.getLocalName(node, false, true))
66484             ], currentLexicalScope.kind === 290 ? 0 : 1));
66485             ts.setOriginalNode(statement, node);
66486             recordEmittedDeclarationInScope(node);
66487             if (isFirstEmittedDeclarationInScope(node)) {
66488                 if (node.kind === 248) {
66489                     ts.setSourceMapRange(statement.declarationList, node);
66490                 }
66491                 else {
66492                     ts.setSourceMapRange(statement, node);
66493                 }
66494                 ts.setCommentRange(statement, node);
66495                 ts.addEmitFlags(statement, 1024 | 4194304);
66496                 statements.push(statement);
66497                 return true;
66498             }
66499             else {
66500                 var mergeMarker = ts.createMergeDeclarationMarker(statement);
66501                 ts.setEmitFlags(mergeMarker, 1536 | 4194304);
66502                 statements.push(mergeMarker);
66503                 return false;
66504             }
66505         }
66506         function visitModuleDeclaration(node) {
66507             if (!shouldEmitModuleDeclaration(node)) {
66508                 return ts.createNotEmittedStatement(node);
66509             }
66510             ts.Debug.assertNode(node.name, ts.isIdentifier, "A TypeScript namespace should have an Identifier name.");
66511             enableSubstitutionForNamespaceExports();
66512             var statements = [];
66513             var emitFlags = 2;
66514             var varAdded = addVarForEnumOrModuleDeclaration(statements, node);
66515             if (varAdded) {
66516                 if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) {
66517                     emitFlags |= 512;
66518                 }
66519             }
66520             var parameterName = getNamespaceParameterName(node);
66521             var containerName = getNamespaceContainerName(node);
66522             var exportName = ts.hasModifier(node, 1)
66523                 ? ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true)
66524                 : ts.getLocalName(node, false, true);
66525             var moduleArg = ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()));
66526             if (hasNamespaceQualifiedExportName(node)) {
66527                 var localName = ts.getLocalName(node, false, true);
66528                 moduleArg = ts.createAssignment(localName, moduleArg);
66529             }
66530             var moduleStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]));
66531             ts.setOriginalNode(moduleStatement, node);
66532             if (varAdded) {
66533                 ts.setSyntheticLeadingComments(moduleStatement, undefined);
66534                 ts.setSyntheticTrailingComments(moduleStatement, undefined);
66535             }
66536             ts.setTextRange(moduleStatement, node);
66537             ts.addEmitFlags(moduleStatement, emitFlags);
66538             statements.push(moduleStatement);
66539             statements.push(ts.createEndOfDeclarationMarker(node));
66540             return statements;
66541         }
66542         function transformModuleBody(node, namespaceLocalName) {
66543             var savedCurrentNamespaceContainerName = currentNamespaceContainerName;
66544             var savedCurrentNamespace = currentNamespace;
66545             var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName;
66546             currentNamespaceContainerName = namespaceLocalName;
66547             currentNamespace = node;
66548             currentScopeFirstDeclarationsOfName = undefined;
66549             var statements = [];
66550             startLexicalEnvironment();
66551             var statementsLocation;
66552             var blockLocation;
66553             if (node.body) {
66554                 if (node.body.kind === 250) {
66555                     saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); });
66556                     statementsLocation = node.body.statements;
66557                     blockLocation = node.body;
66558                 }
66559                 else {
66560                     var result = visitModuleDeclaration(node.body);
66561                     if (result) {
66562                         if (ts.isArray(result)) {
66563                             ts.addRange(statements, result);
66564                         }
66565                         else {
66566                             statements.push(result);
66567                         }
66568                     }
66569                     var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body;
66570                     statementsLocation = ts.moveRangePos(moduleBlock.statements, -1);
66571                 }
66572             }
66573             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
66574             currentNamespaceContainerName = savedCurrentNamespaceContainerName;
66575             currentNamespace = savedCurrentNamespace;
66576             currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName;
66577             var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true);
66578             ts.setTextRange(block, blockLocation);
66579             if (!node.body || node.body.kind !== 250) {
66580                 ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536);
66581             }
66582             return block;
66583         }
66584         function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) {
66585             if (moduleDeclaration.body.kind === 249) {
66586                 var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body);
66587                 return recursiveInnerModule || moduleDeclaration.body;
66588             }
66589         }
66590         function visitImportDeclaration(node) {
66591             if (!node.importClause) {
66592                 return node;
66593             }
66594             if (node.importClause.isTypeOnly) {
66595                 return undefined;
66596             }
66597             var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause);
66598             return importClause ||
66599                 compilerOptions.importsNotUsedAsValues === 1 ||
66600                 compilerOptions.importsNotUsedAsValues === 2
66601                 ? ts.updateImportDeclaration(node, undefined, undefined, importClause, node.moduleSpecifier)
66602                 : undefined;
66603         }
66604         function visitImportClause(node) {
66605             if (node.isTypeOnly) {
66606                 return undefined;
66607             }
66608             var name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined;
66609             var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings);
66610             return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings, false) : undefined;
66611         }
66612         function visitNamedImportBindings(node) {
66613             if (node.kind === 256) {
66614                 return resolver.isReferencedAliasDeclaration(node) ? node : undefined;
66615             }
66616             else {
66617                 var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier);
66618                 return ts.some(elements) ? ts.updateNamedImports(node, elements) : undefined;
66619             }
66620         }
66621         function visitImportSpecifier(node) {
66622             return resolver.isReferencedAliasDeclaration(node) ? node : undefined;
66623         }
66624         function visitExportAssignment(node) {
66625             return resolver.isValueAliasDeclaration(node)
66626                 ? ts.visitEachChild(node, visitor, context)
66627                 : undefined;
66628         }
66629         function visitExportDeclaration(node) {
66630             if (node.isTypeOnly) {
66631                 return undefined;
66632             }
66633             if (!node.exportClause || ts.isNamespaceExport(node.exportClause)) {
66634                 return node;
66635             }
66636             if (!resolver.isValueAliasDeclaration(node)) {
66637                 return undefined;
66638             }
66639             var exportClause = ts.visitNode(node.exportClause, visitNamedExportBindings, ts.isNamedExportBindings);
66640             return exportClause
66641                 ? ts.updateExportDeclaration(node, undefined, undefined, exportClause, node.moduleSpecifier, node.isTypeOnly)
66642                 : undefined;
66643         }
66644         function visitNamedExports(node) {
66645             var elements = ts.visitNodes(node.elements, visitExportSpecifier, ts.isExportSpecifier);
66646             return ts.some(elements) ? ts.updateNamedExports(node, elements) : undefined;
66647         }
66648         function visitNamespaceExports(node) {
66649             return ts.updateNamespaceExport(node, ts.visitNode(node.name, visitor, ts.isIdentifier));
66650         }
66651         function visitNamedExportBindings(node) {
66652             return ts.isNamespaceExport(node) ? visitNamespaceExports(node) : visitNamedExports(node);
66653         }
66654         function visitExportSpecifier(node) {
66655             return resolver.isValueAliasDeclaration(node) ? node : undefined;
66656         }
66657         function shouldEmitImportEqualsDeclaration(node) {
66658             return resolver.isReferencedAliasDeclaration(node)
66659                 || (!ts.isExternalModule(currentSourceFile)
66660                     && resolver.isTopLevelValueImportEqualsWithEntityName(node));
66661         }
66662         function visitImportEqualsDeclaration(node) {
66663             if (ts.isExternalModuleImportEqualsDeclaration(node)) {
66664                 var isReferenced = resolver.isReferencedAliasDeclaration(node);
66665                 if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1) {
66666                     return ts.setOriginalNode(ts.setTextRange(ts.createImportDeclaration(undefined, undefined, undefined, node.moduleReference.expression), node), node);
66667                 }
66668                 return isReferenced ? ts.visitEachChild(node, visitor, context) : undefined;
66669             }
66670             if (!shouldEmitImportEqualsDeclaration(node)) {
66671                 return undefined;
66672             }
66673             var moduleReference = ts.createExpressionFromEntityName(node.moduleReference);
66674             ts.setEmitFlags(moduleReference, 1536 | 2048);
66675             if (isNamedExternalModuleExport(node) || !isExportOfNamespace(node)) {
66676                 return ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([
66677                     ts.setOriginalNode(ts.createVariableDeclaration(node.name, undefined, moduleReference), node)
66678                 ])), node), node);
66679             }
66680             else {
66681                 return ts.setOriginalNode(createNamespaceExport(node.name, moduleReference, node), node);
66682             }
66683         }
66684         function isExportOfNamespace(node) {
66685             return currentNamespace !== undefined && ts.hasModifier(node, 1);
66686         }
66687         function isExternalModuleExport(node) {
66688             return currentNamespace === undefined && ts.hasModifier(node, 1);
66689         }
66690         function isNamedExternalModuleExport(node) {
66691             return isExternalModuleExport(node)
66692                 && !ts.hasModifier(node, 512);
66693         }
66694         function isDefaultExternalModuleExport(node) {
66695             return isExternalModuleExport(node)
66696                 && ts.hasModifier(node, 512);
66697         }
66698         function expressionToStatement(expression) {
66699             return ts.createExpressionStatement(expression);
66700         }
66701         function addExportMemberAssignment(statements, node) {
66702             var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true), ts.getLocalName(node));
66703             ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end));
66704             var statement = ts.createExpressionStatement(expression);
66705             ts.setSourceMapRange(statement, ts.createRange(-1, node.end));
66706             statements.push(statement);
66707         }
66708         function createNamespaceExport(exportName, exportValue, location) {
66709             return ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue)), location);
66710         }
66711         function createNamespaceExportExpression(exportName, exportValue, location) {
66712             return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location);
66713         }
66714         function getNamespaceMemberNameWithSourceMapsAndWithoutComments(name) {
66715             return ts.getNamespaceMemberName(currentNamespaceContainerName, name, false, true);
66716         }
66717         function getNamespaceParameterName(node) {
66718             var name = ts.getGeneratedNameForNode(node);
66719             ts.setSourceMapRange(name, node.name);
66720             return name;
66721         }
66722         function getNamespaceContainerName(node) {
66723             return ts.getGeneratedNameForNode(node);
66724         }
66725         function getClassAliasIfNeeded(node) {
66726             if (resolver.getNodeCheckFlags(node) & 16777216) {
66727                 enableSubstitutionForClassAliases();
66728                 var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default");
66729                 classAliases[ts.getOriginalNodeId(node)] = classAlias;
66730                 hoistVariableDeclaration(classAlias);
66731                 return classAlias;
66732             }
66733         }
66734         function getClassPrototype(node) {
66735             return ts.createPropertyAccess(ts.getDeclarationName(node), "prototype");
66736         }
66737         function getClassMemberPrefix(node, member) {
66738             return ts.hasModifier(member, 32)
66739                 ? ts.getDeclarationName(node)
66740                 : getClassPrototype(node);
66741         }
66742         function enableSubstitutionForNonQualifiedEnumMembers() {
66743             if ((enabledSubstitutions & 8) === 0) {
66744                 enabledSubstitutions |= 8;
66745                 context.enableSubstitution(75);
66746             }
66747         }
66748         function enableSubstitutionForClassAliases() {
66749             if ((enabledSubstitutions & 1) === 0) {
66750                 enabledSubstitutions |= 1;
66751                 context.enableSubstitution(75);
66752                 classAliases = [];
66753             }
66754         }
66755         function enableSubstitutionForNamespaceExports() {
66756             if ((enabledSubstitutions & 2) === 0) {
66757                 enabledSubstitutions |= 2;
66758                 context.enableSubstitution(75);
66759                 context.enableSubstitution(282);
66760                 context.enableEmitNotification(249);
66761             }
66762         }
66763         function isTransformedModuleDeclaration(node) {
66764             return ts.getOriginalNode(node).kind === 249;
66765         }
66766         function isTransformedEnumDeclaration(node) {
66767             return ts.getOriginalNode(node).kind === 248;
66768         }
66769         function onEmitNode(hint, node, emitCallback) {
66770             var savedApplicableSubstitutions = applicableSubstitutions;
66771             var savedCurrentSourceFile = currentSourceFile;
66772             if (ts.isSourceFile(node)) {
66773                 currentSourceFile = node;
66774             }
66775             if (enabledSubstitutions & 2 && isTransformedModuleDeclaration(node)) {
66776                 applicableSubstitutions |= 2;
66777             }
66778             if (enabledSubstitutions & 8 && isTransformedEnumDeclaration(node)) {
66779                 applicableSubstitutions |= 8;
66780             }
66781             previousOnEmitNode(hint, node, emitCallback);
66782             applicableSubstitutions = savedApplicableSubstitutions;
66783             currentSourceFile = savedCurrentSourceFile;
66784         }
66785         function onSubstituteNode(hint, node) {
66786             node = previousOnSubstituteNode(hint, node);
66787             if (hint === 1) {
66788                 return substituteExpression(node);
66789             }
66790             else if (ts.isShorthandPropertyAssignment(node)) {
66791                 return substituteShorthandPropertyAssignment(node);
66792             }
66793             return node;
66794         }
66795         function substituteShorthandPropertyAssignment(node) {
66796             if (enabledSubstitutions & 2) {
66797                 var name = node.name;
66798                 var exportedName = trySubstituteNamespaceExportedName(name);
66799                 if (exportedName) {
66800                     if (node.objectAssignmentInitializer) {
66801                         var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer);
66802                         return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node);
66803                     }
66804                     return ts.setTextRange(ts.createPropertyAssignment(name, exportedName), node);
66805                 }
66806             }
66807             return node;
66808         }
66809         function substituteExpression(node) {
66810             switch (node.kind) {
66811                 case 75:
66812                     return substituteExpressionIdentifier(node);
66813                 case 194:
66814                     return substitutePropertyAccessExpression(node);
66815                 case 195:
66816                     return substituteElementAccessExpression(node);
66817             }
66818             return node;
66819         }
66820         function substituteExpressionIdentifier(node) {
66821             return trySubstituteClassAlias(node)
66822                 || trySubstituteNamespaceExportedName(node)
66823                 || node;
66824         }
66825         function trySubstituteClassAlias(node) {
66826             if (enabledSubstitutions & 1) {
66827                 if (resolver.getNodeCheckFlags(node) & 33554432) {
66828                     var declaration = resolver.getReferencedValueDeclaration(node);
66829                     if (declaration) {
66830                         var classAlias = classAliases[declaration.id];
66831                         if (classAlias) {
66832                             var clone_1 = ts.getSynthesizedClone(classAlias);
66833                             ts.setSourceMapRange(clone_1, node);
66834                             ts.setCommentRange(clone_1, node);
66835                             return clone_1;
66836                         }
66837                     }
66838                 }
66839             }
66840             return undefined;
66841         }
66842         function trySubstituteNamespaceExportedName(node) {
66843             if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
66844                 var container = resolver.getReferencedExportContainer(node, false);
66845                 if (container && container.kind !== 290) {
66846                     var substitute = (applicableSubstitutions & 2 && container.kind === 249) ||
66847                         (applicableSubstitutions & 8 && container.kind === 248);
66848                     if (substitute) {
66849                         return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), node);
66850                     }
66851                 }
66852             }
66853             return undefined;
66854         }
66855         function substitutePropertyAccessExpression(node) {
66856             return substituteConstantValue(node);
66857         }
66858         function substituteElementAccessExpression(node) {
66859             return substituteConstantValue(node);
66860         }
66861         function substituteConstantValue(node) {
66862             var constantValue = tryGetConstEnumValue(node);
66863             if (constantValue !== undefined) {
66864                 ts.setConstantValue(node, constantValue);
66865                 var substitute = ts.createLiteral(constantValue);
66866                 if (!compilerOptions.removeComments) {
66867                     var originalNode = ts.getOriginalNode(node, ts.isAccessExpression);
66868                     var propertyName = ts.isPropertyAccessExpression(originalNode)
66869                         ? ts.declarationNameToString(originalNode.name)
66870                         : ts.getTextOfNode(originalNode.argumentExpression);
66871                     ts.addSyntheticTrailingComment(substitute, 3, " " + propertyName + " ");
66872                 }
66873                 return substitute;
66874             }
66875             return node;
66876         }
66877         function tryGetConstEnumValue(node) {
66878             if (compilerOptions.isolatedModules) {
66879                 return undefined;
66880             }
66881             return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) ? resolver.getConstantValue(node) : undefined;
66882         }
66883     }
66884     ts.transformTypeScript = transformTypeScript;
66885     function createDecorateHelper(context, decoratorExpressions, target, memberName, descriptor, location) {
66886         var argumentsArray = [];
66887         argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, true));
66888         argumentsArray.push(target);
66889         if (memberName) {
66890             argumentsArray.push(memberName);
66891             if (descriptor) {
66892                 argumentsArray.push(descriptor);
66893             }
66894         }
66895         context.requestEmitHelper(ts.decorateHelper);
66896         return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__decorate"), undefined, argumentsArray), location);
66897     }
66898     ts.decorateHelper = {
66899         name: "typescript:decorate",
66900         importName: "__decorate",
66901         scoped: false,
66902         priority: 2,
66903         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            };"
66904     };
66905     function createMetadataHelper(context, metadataKey, metadataValue) {
66906         context.requestEmitHelper(ts.metadataHelper);
66907         return ts.createCall(ts.getUnscopedHelperName("__metadata"), undefined, [
66908             ts.createLiteral(metadataKey),
66909             metadataValue
66910         ]);
66911     }
66912     ts.metadataHelper = {
66913         name: "typescript:metadata",
66914         importName: "__metadata",
66915         scoped: false,
66916         priority: 3,
66917         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            };"
66918     };
66919     function createParamHelper(context, expression, parameterOffset, location) {
66920         context.requestEmitHelper(ts.paramHelper);
66921         return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__param"), undefined, [
66922             ts.createLiteral(parameterOffset),
66923             expression
66924         ]), location);
66925     }
66926     ts.paramHelper = {
66927         name: "typescript:param",
66928         importName: "__param",
66929         scoped: false,
66930         priority: 4,
66931         text: "\n            var __param = (this && this.__param) || function (paramIndex, decorator) {\n                return function (target, key) { decorator(target, key, paramIndex); }\n            };"
66932     };
66933 })(ts || (ts = {}));
66934 var ts;
66935 (function (ts) {
66936     function transformClassFields(context) {
66937         var hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment;
66938         var resolver = context.getEmitResolver();
66939         var compilerOptions = context.getCompilerOptions();
66940         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
66941         var shouldTransformPrivateFields = languageVersion < 99;
66942         var previousOnSubstituteNode = context.onSubstituteNode;
66943         context.onSubstituteNode = onSubstituteNode;
66944         var enabledSubstitutions;
66945         var classAliases;
66946         var pendingExpressions;
66947         var pendingStatements;
66948         var privateIdentifierEnvironmentStack = [];
66949         var currentPrivateIdentifierEnvironment;
66950         return ts.chainBundle(transformSourceFile);
66951         function transformSourceFile(node) {
66952             var options = context.getCompilerOptions();
66953             if (node.isDeclarationFile
66954                 || options.useDefineForClassFields && options.target === 99) {
66955                 return node;
66956             }
66957             var visited = ts.visitEachChild(node, visitor, context);
66958             ts.addEmitHelpers(visited, context.readEmitHelpers());
66959             return visited;
66960         }
66961         function visitor(node) {
66962             if (!(node.transformFlags & 4194304))
66963                 return node;
66964             switch (node.kind) {
66965                 case 214:
66966                 case 245:
66967                     return visitClassLike(node);
66968                 case 159:
66969                     return visitPropertyDeclaration(node);
66970                 case 225:
66971                     return visitVariableStatement(node);
66972                 case 154:
66973                     return visitComputedPropertyName(node);
66974                 case 194:
66975                     return visitPropertyAccessExpression(node);
66976                 case 207:
66977                     return visitPrefixUnaryExpression(node);
66978                 case 208:
66979                     return visitPostfixUnaryExpression(node, false);
66980                 case 196:
66981                     return visitCallExpression(node);
66982                 case 209:
66983                     return visitBinaryExpression(node);
66984                 case 76:
66985                     return visitPrivateIdentifier(node);
66986                 case 226:
66987                     return visitExpressionStatement(node);
66988                 case 230:
66989                     return visitForStatement(node);
66990                 case 198:
66991                     return visitTaggedTemplateExpression(node);
66992             }
66993             return ts.visitEachChild(node, visitor, context);
66994         }
66995         function visitorDestructuringTarget(node) {
66996             switch (node.kind) {
66997                 case 193:
66998                 case 192:
66999                     return visitAssignmentPattern(node);
67000                 default:
67001                     return visitor(node);
67002             }
67003         }
67004         function visitPrivateIdentifier(node) {
67005             if (!shouldTransformPrivateFields) {
67006                 return node;
67007             }
67008             return ts.setOriginalNode(ts.createIdentifier(""), node);
67009         }
67010         function classElementVisitor(node) {
67011             switch (node.kind) {
67012                 case 162:
67013                     return undefined;
67014                 case 163:
67015                 case 164:
67016                 case 161:
67017                     return ts.visitEachChild(node, classElementVisitor, context);
67018                 case 159:
67019                     return visitPropertyDeclaration(node);
67020                 case 154:
67021                     return visitComputedPropertyName(node);
67022                 case 222:
67023                     return node;
67024                 default:
67025                     return visitor(node);
67026             }
67027         }
67028         function visitVariableStatement(node) {
67029             var savedPendingStatements = pendingStatements;
67030             pendingStatements = [];
67031             var visitedNode = ts.visitEachChild(node, visitor, context);
67032             var statement = ts.some(pendingStatements) ? __spreadArrays([visitedNode], pendingStatements) :
67033                 visitedNode;
67034             pendingStatements = savedPendingStatements;
67035             return statement;
67036         }
67037         function visitComputedPropertyName(name) {
67038             var node = ts.visitEachChild(name, visitor, context);
67039             if (ts.some(pendingExpressions)) {
67040                 var expressions = pendingExpressions;
67041                 expressions.push(name.expression);
67042                 pendingExpressions = [];
67043                 node = ts.updateComputedPropertyName(node, ts.inlineExpressions(expressions));
67044             }
67045             return node;
67046         }
67047         function visitPropertyDeclaration(node) {
67048             ts.Debug.assert(!ts.some(node.decorators));
67049             if (!shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) {
67050                 return ts.updateProperty(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, undefined, undefined);
67051             }
67052             var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || !!context.getCompilerOptions().useDefineForClassFields);
67053             if (expr && !ts.isSimpleInlineableExpression(expr)) {
67054                 (pendingExpressions || (pendingExpressions = [])).push(expr);
67055             }
67056             return undefined;
67057         }
67058         function createPrivateIdentifierAccess(info, receiver) {
67059             receiver = ts.visitNode(receiver, visitor, ts.isExpression);
67060             switch (info.placement) {
67061                 case 0:
67062                     return createClassPrivateFieldGetHelper(context, ts.nodeIsSynthesized(receiver) ? receiver : ts.getSynthesizedClone(receiver), info.weakMapName);
67063                 default: return ts.Debug.fail("Unexpected private identifier placement");
67064             }
67065         }
67066         function visitPropertyAccessExpression(node) {
67067             if (shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) {
67068                 var privateIdentifierInfo = accessPrivateIdentifier(node.name);
67069                 if (privateIdentifierInfo) {
67070                     return ts.setOriginalNode(createPrivateIdentifierAccess(privateIdentifierInfo, node.expression), node);
67071                 }
67072             }
67073             return ts.visitEachChild(node, visitor, context);
67074         }
67075         function visitPrefixUnaryExpression(node) {
67076             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) {
67077                 var operator = node.operator === 45 ?
67078                     39 : node.operator === 46 ?
67079                     40 : undefined;
67080                 var info = void 0;
67081                 if (operator && (info = accessPrivateIdentifier(node.operand.name))) {
67082                     var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression);
67083                     var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
67084                     var existingValue = ts.createPrefix(39, createPrivateIdentifierAccess(info, readExpression));
67085                     return ts.setOriginalNode(createPrivateIdentifierAssignment(info, initializeExpression || readExpression, ts.createBinary(existingValue, operator, ts.createLiteral(1)), 62), node);
67086                 }
67087             }
67088             return ts.visitEachChild(node, visitor, context);
67089         }
67090         function visitPostfixUnaryExpression(node, valueIsDiscarded) {
67091             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) {
67092                 var operator = node.operator === 45 ?
67093                     39 : node.operator === 46 ?
67094                     40 : undefined;
67095                 var info = void 0;
67096                 if (operator && (info = accessPrivateIdentifier(node.operand.name))) {
67097                     var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression);
67098                     var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
67099                     var existingValue = ts.createPrefix(39, createPrivateIdentifierAccess(info, readExpression));
67100                     var returnValue = valueIsDiscarded ? undefined : ts.createTempVariable(hoistVariableDeclaration);
67101                     return ts.setOriginalNode(ts.inlineExpressions(ts.compact([
67102                         createPrivateIdentifierAssignment(info, initializeExpression || readExpression, ts.createBinary(returnValue ? ts.createAssignment(returnValue, existingValue) : existingValue, operator, ts.createLiteral(1)), 62),
67103                         returnValue
67104                     ])), node);
67105                 }
67106             }
67107             return ts.visitEachChild(node, visitor, context);
67108         }
67109         function visitForStatement(node) {
67110             if (node.incrementor && ts.isPostfixUnaryExpression(node.incrementor)) {
67111                 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));
67112             }
67113             return ts.visitEachChild(node, visitor, context);
67114         }
67115         function visitExpressionStatement(node) {
67116             if (ts.isPostfixUnaryExpression(node.expression)) {
67117                 return ts.updateExpressionStatement(node, visitPostfixUnaryExpression(node.expression, true));
67118             }
67119             return ts.visitEachChild(node, visitor, context);
67120         }
67121         function createCopiableReceiverExpr(receiver) {
67122             var clone = ts.nodeIsSynthesized(receiver) ? receiver : ts.getSynthesizedClone(receiver);
67123             if (ts.isSimpleInlineableExpression(receiver)) {
67124                 return { readExpression: clone, initializeExpression: undefined };
67125             }
67126             var readExpression = ts.createTempVariable(hoistVariableDeclaration);
67127             var initializeExpression = ts.createAssignment(readExpression, clone);
67128             return { readExpression: readExpression, initializeExpression: initializeExpression };
67129         }
67130         function visitCallExpression(node) {
67131             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.expression)) {
67132                 var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target;
67133                 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)));
67134             }
67135             return ts.visitEachChild(node, visitor, context);
67136         }
67137         function visitTaggedTemplateExpression(node) {
67138             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.tag)) {
67139                 var _a = ts.createCallBinding(node.tag, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target;
67140                 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));
67141             }
67142             return ts.visitEachChild(node, visitor, context);
67143         }
67144         function visitBinaryExpression(node) {
67145             if (shouldTransformPrivateFields) {
67146                 if (ts.isDestructuringAssignment(node)) {
67147                     var savedPendingExpressions = pendingExpressions;
67148                     pendingExpressions = undefined;
67149                     node = ts.updateBinary(node, ts.visitNode(node.left, visitorDestructuringTarget), ts.visitNode(node.right, visitor), node.operatorToken);
67150                     var expr = ts.some(pendingExpressions) ?
67151                         ts.inlineExpressions(ts.compact(__spreadArrays(pendingExpressions, [node]))) :
67152                         node;
67153                     pendingExpressions = savedPendingExpressions;
67154                     return expr;
67155                 }
67156                 if (ts.isAssignmentExpression(node) && ts.isPrivateIdentifierPropertyAccessExpression(node.left)) {
67157                     var info = accessPrivateIdentifier(node.left.name);
67158                     if (info) {
67159                         return ts.setOriginalNode(createPrivateIdentifierAssignment(info, node.left.expression, node.right, node.operatorToken.kind), node);
67160                     }
67161                 }
67162             }
67163             return ts.visitEachChild(node, visitor, context);
67164         }
67165         function createPrivateIdentifierAssignment(info, receiver, right, operator) {
67166             switch (info.placement) {
67167                 case 0: {
67168                     return createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator);
67169                 }
67170                 default: return ts.Debug.fail("Unexpected private identifier placement");
67171             }
67172         }
67173         function createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator) {
67174             receiver = ts.visitNode(receiver, visitor, ts.isExpression);
67175             right = ts.visitNode(right, visitor, ts.isExpression);
67176             if (ts.isCompoundAssignment(operator)) {
67177                 var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
67178                 return createClassPrivateFieldSetHelper(context, initializeExpression || readExpression, info.weakMapName, ts.createBinary(createClassPrivateFieldGetHelper(context, readExpression, info.weakMapName), ts.getNonAssignmentOperatorForCompoundAssignment(operator), right));
67179             }
67180             else {
67181                 return createClassPrivateFieldSetHelper(context, receiver, info.weakMapName, right);
67182             }
67183         }
67184         function visitClassLike(node) {
67185             var savedPendingExpressions = pendingExpressions;
67186             pendingExpressions = undefined;
67187             if (shouldTransformPrivateFields) {
67188                 startPrivateIdentifierEnvironment();
67189             }
67190             var result = ts.isClassDeclaration(node) ?
67191                 visitClassDeclaration(node) :
67192                 visitClassExpression(node);
67193             if (shouldTransformPrivateFields) {
67194                 endPrivateIdentifierEnvironment();
67195             }
67196             pendingExpressions = savedPendingExpressions;
67197             return result;
67198         }
67199         function doesClassElementNeedTransform(node) {
67200             return ts.isPropertyDeclaration(node) || (shouldTransformPrivateFields && node.name && ts.isPrivateIdentifier(node.name));
67201         }
67202         function visitClassDeclaration(node) {
67203             if (!ts.forEach(node.members, doesClassElementNeedTransform)) {
67204                 return ts.visitEachChild(node, visitor, context);
67205             }
67206             var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
67207             var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 100);
67208             var statements = [
67209                 ts.updateClassDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass))
67210             ];
67211             if (ts.some(pendingExpressions)) {
67212                 statements.push(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions)));
67213             }
67214             var staticProperties = ts.getProperties(node, true, true);
67215             if (ts.some(staticProperties)) {
67216                 addPropertyStatements(statements, staticProperties, ts.getInternalName(node));
67217             }
67218             return statements;
67219         }
67220         function visitClassExpression(node) {
67221             if (!ts.forEach(node.members, doesClassElementNeedTransform)) {
67222                 return ts.visitEachChild(node, visitor, context);
67223             }
67224             var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node));
67225             var staticProperties = ts.getProperties(node, true, true);
67226             var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
67227             var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 100);
67228             var classExpression = ts.updateClassExpression(node, node.modifiers, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass));
67229             if (ts.some(staticProperties) || ts.some(pendingExpressions)) {
67230                 if (isDecoratedClassDeclaration) {
67231                     ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration.");
67232                     if (pendingStatements && pendingExpressions && ts.some(pendingExpressions)) {
67233                         pendingStatements.push(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions)));
67234                     }
67235                     if (pendingStatements && ts.some(staticProperties)) {
67236                         addPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node));
67237                     }
67238                     return classExpression;
67239                 }
67240                 else {
67241                     var expressions = [];
67242                     var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216;
67243                     var temp = ts.createTempVariable(hoistVariableDeclaration, !!isClassWithConstructorReference);
67244                     if (isClassWithConstructorReference) {
67245                         enableSubstitutionForClassAliases();
67246                         var alias = ts.getSynthesizedClone(temp);
67247                         alias.autoGenerateFlags &= ~8;
67248                         classAliases[ts.getOriginalNodeId(node)] = alias;
67249                     }
67250                     ts.setEmitFlags(classExpression, 65536 | ts.getEmitFlags(classExpression));
67251                     expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression)));
67252                     ts.addRange(expressions, ts.map(pendingExpressions, ts.startOnNewLine));
67253                     ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp));
67254                     expressions.push(ts.startOnNewLine(temp));
67255                     return ts.inlineExpressions(expressions);
67256                 }
67257             }
67258             return classExpression;
67259         }
67260         function transformClassMembers(node, isDerivedClass) {
67261             if (shouldTransformPrivateFields) {
67262                 for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
67263                     var member = _a[_i];
67264                     if (ts.isPrivateIdentifierPropertyDeclaration(member)) {
67265                         addPrivateIdentifierToEnvironment(member.name);
67266                     }
67267                 }
67268             }
67269             var members = [];
67270             var constructor = transformConstructor(node, isDerivedClass);
67271             if (constructor) {
67272                 members.push(constructor);
67273             }
67274             ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
67275             return ts.setTextRange(ts.createNodeArray(members), node.members);
67276         }
67277         function isPropertyDeclarationThatRequiresConstructorStatement(member) {
67278             if (!ts.isPropertyDeclaration(member) || ts.hasStaticModifier(member)) {
67279                 return false;
67280             }
67281             if (context.getCompilerOptions().useDefineForClassFields) {
67282                 return languageVersion < 99;
67283             }
67284             return ts.isInitializedProperty(member) || shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyDeclaration(member);
67285         }
67286         function transformConstructor(node, isDerivedClass) {
67287             var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration);
67288             var properties = node.members.filter(isPropertyDeclarationThatRequiresConstructorStatement);
67289             if (!ts.some(properties)) {
67290                 return constructor;
67291             }
67292             var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context);
67293             var body = transformConstructorBody(node, constructor, isDerivedClass);
67294             if (!body) {
67295                 return undefined;
67296             }
67297             return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(ts.createConstructor(undefined, undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor));
67298         }
67299         function transformConstructorBody(node, constructor, isDerivedClass) {
67300             var useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields;
67301             var properties = ts.getProperties(node, false, false);
67302             if (!useDefineForClassFields) {
67303                 properties = ts.filter(properties, function (property) { return !!property.initializer || ts.isPrivateIdentifier(property.name); });
67304             }
67305             if (!constructor && !ts.some(properties)) {
67306                 return ts.visitFunctionBody(undefined, visitor, context);
67307             }
67308             resumeLexicalEnvironment();
67309             var indexOfFirstStatement = 0;
67310             var statements = [];
67311             if (!constructor && isDerivedClass) {
67312                 statements.push(ts.createExpressionStatement(ts.createCall(ts.createSuper(), undefined, [ts.createSpread(ts.createIdentifier("arguments"))])));
67313             }
67314             if (constructor) {
67315                 indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(constructor, statements, visitor);
67316             }
67317             if (constructor === null || constructor === void 0 ? void 0 : constructor.body) {
67318                 var afterParameterProperties = ts.findIndex(constructor.body.statements, function (s) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(s), constructor); }, indexOfFirstStatement);
67319                 if (afterParameterProperties === -1) {
67320                     afterParameterProperties = constructor.body.statements.length;
67321                 }
67322                 if (afterParameterProperties > indexOfFirstStatement) {
67323                     if (!useDefineForClassFields) {
67324                         ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, afterParameterProperties - indexOfFirstStatement));
67325                     }
67326                     indexOfFirstStatement = afterParameterProperties;
67327                 }
67328             }
67329             addPropertyStatements(statements, properties, ts.createThis());
67330             if (constructor) {
67331                 ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement));
67332             }
67333             statements = ts.mergeLexicalEnvironment(statements, endLexicalEnvironment());
67334             return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true), constructor ? constructor.body : undefined);
67335         }
67336         function addPropertyStatements(statements, properties, receiver) {
67337             for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) {
67338                 var property = properties_8[_i];
67339                 var expression = transformProperty(property, receiver);
67340                 if (!expression) {
67341                     continue;
67342                 }
67343                 var statement = ts.createExpressionStatement(expression);
67344                 ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
67345                 ts.setCommentRange(statement, property);
67346                 ts.setOriginalNode(statement, property);
67347                 statements.push(statement);
67348             }
67349         }
67350         function generateInitializedPropertyExpressions(properties, receiver) {
67351             var expressions = [];
67352             for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) {
67353                 var property = properties_9[_i];
67354                 var expression = transformProperty(property, receiver);
67355                 if (!expression) {
67356                     continue;
67357                 }
67358                 ts.startOnNewLine(expression);
67359                 ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property));
67360                 ts.setCommentRange(expression, property);
67361                 ts.setOriginalNode(expression, property);
67362                 expressions.push(expression);
67363             }
67364             return expressions;
67365         }
67366         function transformProperty(property, receiver) {
67367             var emitAssignment = !context.getCompilerOptions().useDefineForClassFields;
67368             var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression)
67369                 ? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name))
67370                 : property.name;
67371             if (shouldTransformPrivateFields && ts.isPrivateIdentifier(propertyName)) {
67372                 var privateIdentifierInfo = accessPrivateIdentifier(propertyName);
67373                 if (privateIdentifierInfo) {
67374                     switch (privateIdentifierInfo.placement) {
67375                         case 0: {
67376                             return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.weakMapName);
67377                         }
67378                     }
67379                 }
67380                 else {
67381                     ts.Debug.fail("Undeclared private name for property declaration.");
67382                 }
67383             }
67384             if (ts.isPrivateIdentifier(propertyName) && !property.initializer) {
67385                 return undefined;
67386             }
67387             if (ts.isPrivateIdentifier(propertyName) && !property.initializer) {
67388                 return undefined;
67389             }
67390             var propertyOriginalNode = ts.getOriginalNode(property);
67391             var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression)
67392                 : ts.isParameterPropertyDeclaration(propertyOriginalNode, propertyOriginalNode.parent) && ts.isIdentifier(propertyName) ? propertyName
67393                     : ts.createVoidZero();
67394             if (emitAssignment || ts.isPrivateIdentifier(propertyName)) {
67395                 var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, propertyName);
67396                 return ts.createAssignment(memberAccess, initializer);
67397             }
67398             else {
67399                 var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression
67400                     : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText))
67401                         : propertyName;
67402                 var descriptor = ts.createPropertyDescriptor({ value: initializer, configurable: true, writable: true, enumerable: true });
67403                 return ts.createObjectDefinePropertyCall(receiver, name, descriptor);
67404             }
67405         }
67406         function enableSubstitutionForClassAliases() {
67407             if ((enabledSubstitutions & 1) === 0) {
67408                 enabledSubstitutions |= 1;
67409                 context.enableSubstitution(75);
67410                 classAliases = [];
67411             }
67412         }
67413         function onSubstituteNode(hint, node) {
67414             node = previousOnSubstituteNode(hint, node);
67415             if (hint === 1) {
67416                 return substituteExpression(node);
67417             }
67418             return node;
67419         }
67420         function substituteExpression(node) {
67421             switch (node.kind) {
67422                 case 75:
67423                     return substituteExpressionIdentifier(node);
67424             }
67425             return node;
67426         }
67427         function substituteExpressionIdentifier(node) {
67428             return trySubstituteClassAlias(node) || node;
67429         }
67430         function trySubstituteClassAlias(node) {
67431             if (enabledSubstitutions & 1) {
67432                 if (resolver.getNodeCheckFlags(node) & 33554432) {
67433                     var declaration = resolver.getReferencedValueDeclaration(node);
67434                     if (declaration) {
67435                         var classAlias = classAliases[declaration.id];
67436                         if (classAlias) {
67437                             var clone_2 = ts.getSynthesizedClone(classAlias);
67438                             ts.setSourceMapRange(clone_2, node);
67439                             ts.setCommentRange(clone_2, node);
67440                             return clone_2;
67441                         }
67442                     }
67443                 }
67444             }
67445             return undefined;
67446         }
67447         function getPropertyNameExpressionIfNeeded(name, shouldHoist) {
67448             if (ts.isComputedPropertyName(name)) {
67449                 var expression = ts.visitNode(name.expression, visitor, ts.isExpression);
67450                 var innerExpression = ts.skipPartiallyEmittedExpressions(expression);
67451                 var inlinable = ts.isSimpleInlineableExpression(innerExpression);
67452                 var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left);
67453                 if (!alreadyTransformed && !inlinable && shouldHoist) {
67454                     var generatedName = ts.getGeneratedNameForNode(name);
67455                     hoistVariableDeclaration(generatedName);
67456                     return ts.createAssignment(generatedName, expression);
67457                 }
67458                 return (inlinable || ts.isIdentifier(innerExpression)) ? undefined : expression;
67459             }
67460         }
67461         function startPrivateIdentifierEnvironment() {
67462             privateIdentifierEnvironmentStack.push(currentPrivateIdentifierEnvironment);
67463             currentPrivateIdentifierEnvironment = undefined;
67464         }
67465         function endPrivateIdentifierEnvironment() {
67466             currentPrivateIdentifierEnvironment = privateIdentifierEnvironmentStack.pop();
67467         }
67468         function addPrivateIdentifierToEnvironment(name) {
67469             var text = ts.getTextOfPropertyName(name);
67470             var weakMapName = ts.createOptimisticUniqueName("_" + text.substring(1));
67471             weakMapName.autoGenerateFlags |= 8;
67472             hoistVariableDeclaration(weakMapName);
67473             (currentPrivateIdentifierEnvironment || (currentPrivateIdentifierEnvironment = ts.createUnderscoreEscapedMap()))
67474                 .set(name.escapedText, { placement: 0, weakMapName: weakMapName });
67475             (pendingExpressions || (pendingExpressions = [])).push(ts.createAssignment(weakMapName, ts.createNew(ts.createIdentifier("WeakMap"), undefined, [])));
67476         }
67477         function accessPrivateIdentifier(name) {
67478             if (currentPrivateIdentifierEnvironment) {
67479                 var info = currentPrivateIdentifierEnvironment.get(name.escapedText);
67480                 if (info) {
67481                     return info;
67482                 }
67483             }
67484             for (var i = privateIdentifierEnvironmentStack.length - 1; i >= 0; --i) {
67485                 var env = privateIdentifierEnvironmentStack[i];
67486                 if (!env) {
67487                     continue;
67488                 }
67489                 var info = env.get(name.escapedText);
67490                 if (info) {
67491                     return info;
67492                 }
67493             }
67494             return undefined;
67495         }
67496         function wrapPrivateIdentifierForDestructuringTarget(node) {
67497             var parameter = ts.getGeneratedNameForNode(node);
67498             var info = accessPrivateIdentifier(node.name);
67499             if (!info) {
67500                 return ts.visitEachChild(node, visitor, context);
67501             }
67502             var receiver = node.expression;
67503             if (ts.isThisProperty(node) || ts.isSuperProperty(node) || !ts.isSimpleCopiableExpression(node.expression)) {
67504                 receiver = ts.createTempVariable(hoistVariableDeclaration);
67505                 receiver.autoGenerateFlags |= 8;
67506                 (pendingExpressions || (pendingExpressions = [])).push(ts.createBinary(receiver, 62, node.expression));
67507             }
67508             return ts.createPropertyAccess(ts.createParen(ts.createObjectLiteral([
67509                 ts.createSetAccessor(undefined, undefined, "value", [ts.createParameter(undefined, undefined, undefined, parameter, undefined, undefined, undefined)], ts.createBlock([ts.createExpressionStatement(createPrivateIdentifierAssignment(info, receiver, parameter, 62))]))
67510             ])), "value");
67511         }
67512         function visitArrayAssignmentTarget(node) {
67513             var target = ts.getTargetOfBindingOrAssignmentElement(node);
67514             if (target && ts.isPrivateIdentifierPropertyAccessExpression(target)) {
67515                 var wrapped = wrapPrivateIdentifierForDestructuringTarget(target);
67516                 if (ts.isAssignmentExpression(node)) {
67517                     return ts.updateBinary(node, wrapped, ts.visitNode(node.right, visitor, ts.isExpression), node.operatorToken);
67518                 }
67519                 else if (ts.isSpreadElement(node)) {
67520                     return ts.updateSpread(node, wrapped);
67521                 }
67522                 else {
67523                     return wrapped;
67524                 }
67525             }
67526             return ts.visitNode(node, visitorDestructuringTarget);
67527         }
67528         function visitObjectAssignmentTarget(node) {
67529             if (ts.isPropertyAssignment(node)) {
67530                 var target = ts.getTargetOfBindingOrAssignmentElement(node);
67531                 if (target && ts.isPrivateIdentifierPropertyAccessExpression(target)) {
67532                     var initializer = ts.getInitializerOfBindingOrAssignmentElement(node);
67533                     var wrapped = wrapPrivateIdentifierForDestructuringTarget(target);
67534                     return ts.updatePropertyAssignment(node, ts.visitNode(node.name, visitor), initializer ? ts.createAssignment(wrapped, ts.visitNode(initializer, visitor)) : wrapped);
67535                 }
67536                 return ts.updatePropertyAssignment(node, ts.visitNode(node.name, visitor), ts.visitNode(node.initializer, visitorDestructuringTarget));
67537             }
67538             return ts.visitNode(node, visitor);
67539         }
67540         function visitAssignmentPattern(node) {
67541             if (ts.isArrayLiteralExpression(node)) {
67542                 return ts.updateArrayLiteral(node, ts.visitNodes(node.elements, visitArrayAssignmentTarget, ts.isExpression));
67543             }
67544             else {
67545                 return ts.updateObjectLiteral(node, ts.visitNodes(node.properties, visitObjectAssignmentTarget, ts.isObjectLiteralElementLike));
67546             }
67547         }
67548     }
67549     ts.transformClassFields = transformClassFields;
67550     function createPrivateInstanceFieldInitializer(receiver, initializer, weakMapName) {
67551         return ts.createCall(ts.createPropertyAccess(weakMapName, "set"), undefined, [receiver, initializer || ts.createVoidZero()]);
67552     }
67553     ts.classPrivateFieldGetHelper = {
67554         name: "typescript:classPrivateFieldGet",
67555         scoped: false,
67556         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            };"
67557     };
67558     function createClassPrivateFieldGetHelper(context, receiver, privateField) {
67559         context.requestEmitHelper(ts.classPrivateFieldGetHelper);
67560         return ts.createCall(ts.getUnscopedHelperName("__classPrivateFieldGet"), undefined, [receiver, privateField]);
67561     }
67562     ts.classPrivateFieldSetHelper = {
67563         name: "typescript:classPrivateFieldSet",
67564         scoped: false,
67565         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            };"
67566     };
67567     function createClassPrivateFieldSetHelper(context, receiver, privateField, value) {
67568         context.requestEmitHelper(ts.classPrivateFieldSetHelper);
67569         return ts.createCall(ts.getUnscopedHelperName("__classPrivateFieldSet"), undefined, [receiver, privateField, value]);
67570     }
67571 })(ts || (ts = {}));
67572 var ts;
67573 (function (ts) {
67574     function transformES2017(context) {
67575         var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
67576         var resolver = context.getEmitResolver();
67577         var compilerOptions = context.getCompilerOptions();
67578         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
67579         var enabledSubstitutions;
67580         var enclosingSuperContainerFlags = 0;
67581         var enclosingFunctionParameterNames;
67582         var capturedSuperProperties;
67583         var hasSuperElementAccess;
67584         var substitutedSuperAccessors = [];
67585         var contextFlags = 0;
67586         var previousOnEmitNode = context.onEmitNode;
67587         var previousOnSubstituteNode = context.onSubstituteNode;
67588         context.onEmitNode = onEmitNode;
67589         context.onSubstituteNode = onSubstituteNode;
67590         return ts.chainBundle(transformSourceFile);
67591         function transformSourceFile(node) {
67592             if (node.isDeclarationFile) {
67593                 return node;
67594             }
67595             setContextFlag(1, false);
67596             setContextFlag(2, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions));
67597             var visited = ts.visitEachChild(node, visitor, context);
67598             ts.addEmitHelpers(visited, context.readEmitHelpers());
67599             return visited;
67600         }
67601         function setContextFlag(flag, val) {
67602             contextFlags = val ? contextFlags | flag : contextFlags & ~flag;
67603         }
67604         function inContext(flags) {
67605             return (contextFlags & flags) !== 0;
67606         }
67607         function inTopLevelContext() {
67608             return !inContext(1);
67609         }
67610         function inHasLexicalThisContext() {
67611             return inContext(2);
67612         }
67613         function doWithContext(flags, cb, value) {
67614             var contextFlagsToSet = flags & ~contextFlags;
67615             if (contextFlagsToSet) {
67616                 setContextFlag(contextFlagsToSet, true);
67617                 var result = cb(value);
67618                 setContextFlag(contextFlagsToSet, false);
67619                 return result;
67620             }
67621             return cb(value);
67622         }
67623         function visitDefault(node) {
67624             return ts.visitEachChild(node, visitor, context);
67625         }
67626         function visitor(node) {
67627             if ((node.transformFlags & 64) === 0) {
67628                 return node;
67629             }
67630             switch (node.kind) {
67631                 case 126:
67632                     return undefined;
67633                 case 206:
67634                     return visitAwaitExpression(node);
67635                 case 161:
67636                     return doWithContext(1 | 2, visitMethodDeclaration, node);
67637                 case 244:
67638                     return doWithContext(1 | 2, visitFunctionDeclaration, node);
67639                 case 201:
67640                     return doWithContext(1 | 2, visitFunctionExpression, node);
67641                 case 202:
67642                     return doWithContext(1, visitArrowFunction, node);
67643                 case 194:
67644                     if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 102) {
67645                         capturedSuperProperties.set(node.name.escapedText, true);
67646                     }
67647                     return ts.visitEachChild(node, visitor, context);
67648                 case 195:
67649                     if (capturedSuperProperties && node.expression.kind === 102) {
67650                         hasSuperElementAccess = true;
67651                     }
67652                     return ts.visitEachChild(node, visitor, context);
67653                 case 163:
67654                 case 164:
67655                 case 162:
67656                 case 245:
67657                 case 214:
67658                     return doWithContext(1 | 2, visitDefault, node);
67659                 default:
67660                     return ts.visitEachChild(node, visitor, context);
67661             }
67662         }
67663         function asyncBodyVisitor(node) {
67664             if (ts.isNodeWithPossibleHoistedDeclaration(node)) {
67665                 switch (node.kind) {
67666                     case 225:
67667                         return visitVariableStatementInAsyncBody(node);
67668                     case 230:
67669                         return visitForStatementInAsyncBody(node);
67670                     case 231:
67671                         return visitForInStatementInAsyncBody(node);
67672                     case 232:
67673                         return visitForOfStatementInAsyncBody(node);
67674                     case 280:
67675                         return visitCatchClauseInAsyncBody(node);
67676                     case 223:
67677                     case 237:
67678                     case 251:
67679                     case 277:
67680                     case 278:
67681                     case 240:
67682                     case 228:
67683                     case 229:
67684                     case 227:
67685                     case 236:
67686                     case 238:
67687                         return ts.visitEachChild(node, asyncBodyVisitor, context);
67688                     default:
67689                         return ts.Debug.assertNever(node, "Unhandled node.");
67690                 }
67691             }
67692             return visitor(node);
67693         }
67694         function visitCatchClauseInAsyncBody(node) {
67695             var catchClauseNames = ts.createUnderscoreEscapedMap();
67696             recordDeclarationName(node.variableDeclaration, catchClauseNames);
67697             var catchClauseUnshadowedNames;
67698             catchClauseNames.forEach(function (_, escapedName) {
67699                 if (enclosingFunctionParameterNames.has(escapedName)) {
67700                     if (!catchClauseUnshadowedNames) {
67701                         catchClauseUnshadowedNames = ts.cloneMap(enclosingFunctionParameterNames);
67702                     }
67703                     catchClauseUnshadowedNames.delete(escapedName);
67704                 }
67705             });
67706             if (catchClauseUnshadowedNames) {
67707                 var savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames;
67708                 enclosingFunctionParameterNames = catchClauseUnshadowedNames;
67709                 var result = ts.visitEachChild(node, asyncBodyVisitor, context);
67710                 enclosingFunctionParameterNames = savedEnclosingFunctionParameterNames;
67711                 return result;
67712             }
67713             else {
67714                 return ts.visitEachChild(node, asyncBodyVisitor, context);
67715             }
67716         }
67717         function visitVariableStatementInAsyncBody(node) {
67718             if (isVariableDeclarationListWithCollidingName(node.declarationList)) {
67719                 var expression = visitVariableDeclarationListWithCollidingNames(node.declarationList, false);
67720                 return expression ? ts.createExpressionStatement(expression) : undefined;
67721             }
67722             return ts.visitEachChild(node, visitor, context);
67723         }
67724         function visitForInStatementInAsyncBody(node) {
67725             return ts.updateForIn(node, isVariableDeclarationListWithCollidingName(node.initializer)
67726                 ? visitVariableDeclarationListWithCollidingNames(node.initializer, true)
67727                 : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, ts.liftToBlock));
67728         }
67729         function visitForOfStatementInAsyncBody(node) {
67730             return ts.updateForOf(node, ts.visitNode(node.awaitModifier, visitor, ts.isToken), isVariableDeclarationListWithCollidingName(node.initializer)
67731                 ? visitVariableDeclarationListWithCollidingNames(node.initializer, true)
67732                 : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, ts.liftToBlock));
67733         }
67734         function visitForStatementInAsyncBody(node) {
67735             var initializer = node.initializer;
67736             return ts.updateFor(node, isVariableDeclarationListWithCollidingName(initializer)
67737                 ? visitVariableDeclarationListWithCollidingNames(initializer, false)
67738                 : 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));
67739         }
67740         function visitAwaitExpression(node) {
67741             if (inTopLevelContext()) {
67742                 return ts.visitEachChild(node, visitor, context);
67743             }
67744             return ts.setOriginalNode(ts.setTextRange(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node);
67745         }
67746         function visitMethodDeclaration(node) {
67747             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
67748                 ? transformAsyncFunctionBody(node)
67749                 : ts.visitFunctionBody(node.body, visitor, context));
67750         }
67751         function visitFunctionDeclaration(node) {
67752             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
67753                 ? transformAsyncFunctionBody(node)
67754                 : ts.visitFunctionBody(node.body, visitor, context));
67755         }
67756         function visitFunctionExpression(node) {
67757             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
67758                 ? transformAsyncFunctionBody(node)
67759                 : ts.visitFunctionBody(node.body, visitor, context));
67760         }
67761         function visitArrowFunction(node) {
67762             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
67763                 ? transformAsyncFunctionBody(node)
67764                 : ts.visitFunctionBody(node.body, visitor, context));
67765         }
67766         function recordDeclarationName(_a, names) {
67767             var name = _a.name;
67768             if (ts.isIdentifier(name)) {
67769                 names.set(name.escapedText, true);
67770             }
67771             else {
67772                 for (var _i = 0, _b = name.elements; _i < _b.length; _i++) {
67773                     var element = _b[_i];
67774                     if (!ts.isOmittedExpression(element)) {
67775                         recordDeclarationName(element, names);
67776                     }
67777                 }
67778             }
67779         }
67780         function isVariableDeclarationListWithCollidingName(node) {
67781             return !!node
67782                 && ts.isVariableDeclarationList(node)
67783                 && !(node.flags & 3)
67784                 && node.declarations.some(collidesWithParameterName);
67785         }
67786         function visitVariableDeclarationListWithCollidingNames(node, hasReceiver) {
67787             hoistVariableDeclarationList(node);
67788             var variables = ts.getInitializedVariables(node);
67789             if (variables.length === 0) {
67790                 if (hasReceiver) {
67791                     return ts.visitNode(ts.convertToAssignmentElementTarget(node.declarations[0].name), visitor, ts.isExpression);
67792                 }
67793                 return undefined;
67794             }
67795             return ts.inlineExpressions(ts.map(variables, transformInitializedVariable));
67796         }
67797         function hoistVariableDeclarationList(node) {
67798             ts.forEach(node.declarations, hoistVariable);
67799         }
67800         function hoistVariable(_a) {
67801             var name = _a.name;
67802             if (ts.isIdentifier(name)) {
67803                 hoistVariableDeclaration(name);
67804             }
67805             else {
67806                 for (var _i = 0, _b = name.elements; _i < _b.length; _i++) {
67807                     var element = _b[_i];
67808                     if (!ts.isOmittedExpression(element)) {
67809                         hoistVariable(element);
67810                     }
67811                 }
67812             }
67813         }
67814         function transformInitializedVariable(node) {
67815             var converted = ts.setSourceMapRange(ts.createAssignment(ts.convertToAssignmentElementTarget(node.name), node.initializer), node);
67816             return ts.visitNode(converted, visitor, ts.isExpression);
67817         }
67818         function collidesWithParameterName(_a) {
67819             var name = _a.name;
67820             if (ts.isIdentifier(name)) {
67821                 return enclosingFunctionParameterNames.has(name.escapedText);
67822             }
67823             else {
67824                 for (var _i = 0, _b = name.elements; _i < _b.length; _i++) {
67825                     var element = _b[_i];
67826                     if (!ts.isOmittedExpression(element) && collidesWithParameterName(element)) {
67827                         return true;
67828                     }
67829                 }
67830             }
67831             return false;
67832         }
67833         function transformAsyncFunctionBody(node) {
67834             resumeLexicalEnvironment();
67835             var original = ts.getOriginalNode(node, ts.isFunctionLike);
67836             var nodeType = original.type;
67837             var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined;
67838             var isArrowFunction = node.kind === 202;
67839             var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0;
67840             var savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames;
67841             enclosingFunctionParameterNames = ts.createUnderscoreEscapedMap();
67842             for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
67843                 var parameter = _a[_i];
67844                 recordDeclarationName(parameter, enclosingFunctionParameterNames);
67845             }
67846             var savedCapturedSuperProperties = capturedSuperProperties;
67847             var savedHasSuperElementAccess = hasSuperElementAccess;
67848             if (!isArrowFunction) {
67849                 capturedSuperProperties = ts.createUnderscoreEscapedMap();
67850                 hasSuperElementAccess = false;
67851             }
67852             var result;
67853             if (!isArrowFunction) {
67854                 var statements = [];
67855                 var statementOffset = ts.addPrologue(statements, node.body.statements, false, visitor);
67856                 statements.push(ts.createReturn(createAwaiterHelper(context, inHasLexicalThisContext(), hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset))));
67857                 ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
67858                 var emitSuperHelpers = languageVersion >= 2 && resolver.getNodeCheckFlags(node) & (4096 | 2048);
67859                 if (emitSuperHelpers) {
67860                     enableSubstitutionForAsyncMethodsWithSuper();
67861                     if (ts.hasEntries(capturedSuperProperties)) {
67862                         var variableStatement = createSuperAccessVariableStatement(resolver, node, capturedSuperProperties);
67863                         substitutedSuperAccessors[ts.getNodeId(variableStatement)] = true;
67864                         ts.insertStatementsAfterStandardPrologue(statements, [variableStatement]);
67865                     }
67866                 }
67867                 var block = ts.createBlock(statements, true);
67868                 ts.setTextRange(block, node.body);
67869                 if (emitSuperHelpers && hasSuperElementAccess) {
67870                     if (resolver.getNodeCheckFlags(node) & 4096) {
67871                         ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
67872                     }
67873                     else if (resolver.getNodeCheckFlags(node) & 2048) {
67874                         ts.addEmitHelper(block, ts.asyncSuperHelper);
67875                     }
67876                 }
67877                 result = block;
67878             }
67879             else {
67880                 var expression = createAwaiterHelper(context, inHasLexicalThisContext(), hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body));
67881                 var declarations = endLexicalEnvironment();
67882                 if (ts.some(declarations)) {
67883                     var block = ts.convertToFunctionBody(expression);
67884                     result = ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, block.statements)), block.statements));
67885                 }
67886                 else {
67887                     result = expression;
67888                 }
67889             }
67890             enclosingFunctionParameterNames = savedEnclosingFunctionParameterNames;
67891             if (!isArrowFunction) {
67892                 capturedSuperProperties = savedCapturedSuperProperties;
67893                 hasSuperElementAccess = savedHasSuperElementAccess;
67894             }
67895             return result;
67896         }
67897         function transformAsyncFunctionBodyWorker(body, start) {
67898             if (ts.isBlock(body)) {
67899                 return ts.updateBlock(body, ts.visitNodes(body.statements, asyncBodyVisitor, ts.isStatement, start));
67900             }
67901             else {
67902                 return ts.convertToFunctionBody(ts.visitNode(body, asyncBodyVisitor, ts.isConciseBody));
67903             }
67904         }
67905         function getPromiseConstructor(type) {
67906             var typeName = type && ts.getEntityNameFromTypeNode(type);
67907             if (typeName && ts.isEntityName(typeName)) {
67908                 var serializationKind = resolver.getTypeReferenceSerializationKind(typeName);
67909                 if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue
67910                     || serializationKind === ts.TypeReferenceSerializationKind.Unknown) {
67911                     return typeName;
67912                 }
67913             }
67914             return undefined;
67915         }
67916         function enableSubstitutionForAsyncMethodsWithSuper() {
67917             if ((enabledSubstitutions & 1) === 0) {
67918                 enabledSubstitutions |= 1;
67919                 context.enableSubstitution(196);
67920                 context.enableSubstitution(194);
67921                 context.enableSubstitution(195);
67922                 context.enableEmitNotification(245);
67923                 context.enableEmitNotification(161);
67924                 context.enableEmitNotification(163);
67925                 context.enableEmitNotification(164);
67926                 context.enableEmitNotification(162);
67927                 context.enableEmitNotification(225);
67928             }
67929         }
67930         function onEmitNode(hint, node, emitCallback) {
67931             if (enabledSubstitutions & 1 && isSuperContainer(node)) {
67932                 var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 | 4096);
67933                 if (superContainerFlags !== enclosingSuperContainerFlags) {
67934                     var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
67935                     enclosingSuperContainerFlags = superContainerFlags;
67936                     previousOnEmitNode(hint, node, emitCallback);
67937                     enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
67938                     return;
67939                 }
67940             }
67941             else if (enabledSubstitutions && substitutedSuperAccessors[ts.getNodeId(node)]) {
67942                 var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
67943                 enclosingSuperContainerFlags = 0;
67944                 previousOnEmitNode(hint, node, emitCallback);
67945                 enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
67946                 return;
67947             }
67948             previousOnEmitNode(hint, node, emitCallback);
67949         }
67950         function onSubstituteNode(hint, node) {
67951             node = previousOnSubstituteNode(hint, node);
67952             if (hint === 1 && enclosingSuperContainerFlags) {
67953                 return substituteExpression(node);
67954             }
67955             return node;
67956         }
67957         function substituteExpression(node) {
67958             switch (node.kind) {
67959                 case 194:
67960                     return substitutePropertyAccessExpression(node);
67961                 case 195:
67962                     return substituteElementAccessExpression(node);
67963                 case 196:
67964                     return substituteCallExpression(node);
67965             }
67966             return node;
67967         }
67968         function substitutePropertyAccessExpression(node) {
67969             if (node.expression.kind === 102) {
67970                 return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node);
67971             }
67972             return node;
67973         }
67974         function substituteElementAccessExpression(node) {
67975             if (node.expression.kind === 102) {
67976                 return createSuperElementAccessInAsyncMethod(node.argumentExpression, node);
67977             }
67978             return node;
67979         }
67980         function substituteCallExpression(node) {
67981             var expression = node.expression;
67982             if (ts.isSuperProperty(expression)) {
67983                 var argumentExpression = ts.isPropertyAccessExpression(expression)
67984                     ? substitutePropertyAccessExpression(expression)
67985                     : substituteElementAccessExpression(expression);
67986                 return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, __spreadArrays([
67987                     ts.createThis()
67988                 ], node.arguments));
67989             }
67990             return node;
67991         }
67992         function isSuperContainer(node) {
67993             var kind = node.kind;
67994             return kind === 245
67995                 || kind === 162
67996                 || kind === 161
67997                 || kind === 163
67998                 || kind === 164;
67999         }
68000         function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
68001             if (enclosingSuperContainerFlags & 4096) {
68002                 return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createFileLevelUniqueName("_superIndex"), undefined, [argumentExpression]), "value"), location);
68003             }
68004             else {
68005                 return ts.setTextRange(ts.createCall(ts.createFileLevelUniqueName("_superIndex"), undefined, [argumentExpression]), location);
68006             }
68007         }
68008     }
68009     ts.transformES2017 = transformES2017;
68010     function createSuperAccessVariableStatement(resolver, node, names) {
68011         var hasBinding = (resolver.getNodeCheckFlags(node) & 4096) !== 0;
68012         var accessors = [];
68013         names.forEach(function (_, key) {
68014             var name = ts.unescapeLeadingUnderscores(key);
68015             var getterAndSetter = [];
68016             getterAndSetter.push(ts.createPropertyAssignment("get", ts.createArrowFunction(undefined, undefined, [], undefined, undefined, ts.setEmitFlags(ts.createPropertyAccess(ts.setEmitFlags(ts.createSuper(), 4), name), 4))));
68017             if (hasBinding) {
68018                 getterAndSetter.push(ts.createPropertyAssignment("set", ts.createArrowFunction(undefined, undefined, [
68019                     ts.createParameter(undefined, undefined, undefined, "v", undefined, undefined, undefined)
68020                 ], undefined, undefined, ts.createAssignment(ts.setEmitFlags(ts.createPropertyAccess(ts.setEmitFlags(ts.createSuper(), 4), name), 4), ts.createIdentifier("v")))));
68021             }
68022             accessors.push(ts.createPropertyAssignment(name, ts.createObjectLiteral(getterAndSetter)));
68023         });
68024         return ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
68025             ts.createVariableDeclaration(ts.createFileLevelUniqueName("_super"), undefined, ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "create"), undefined, [
68026                 ts.createNull(),
68027                 ts.createObjectLiteral(accessors, true)
68028             ]))
68029         ], 2));
68030     }
68031     ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement;
68032     ts.awaiterHelper = {
68033         name: "typescript:awaiter",
68034         importName: "__awaiter",
68035         scoped: false,
68036         priority: 5,
68037         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            };"
68038     };
68039     function createAwaiterHelper(context, hasLexicalThis, hasLexicalArguments, promiseConstructor, body) {
68040         context.requestEmitHelper(ts.awaiterHelper);
68041         var generatorFunc = ts.createFunctionExpression(undefined, ts.createToken(41), undefined, undefined, [], undefined, body);
68042         (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 | 524288;
68043         return ts.createCall(ts.getUnscopedHelperName("__awaiter"), undefined, [
68044             hasLexicalThis ? ts.createThis() : ts.createVoidZero(),
68045             hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(),
68046             promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(),
68047             generatorFunc
68048         ]);
68049     }
68050     ts.asyncSuperHelper = {
68051         name: "typescript:async-super",
68052         scoped: true,
68053         text: ts.helperString(__makeTemplateObject(["\n            const ", " = name => super[name];"], ["\n            const ", " = name => super[name];"]), "_superIndex")
68054     };
68055     ts.advancedAsyncSuperHelper = {
68056         name: "typescript:advanced-async-super",
68057         scoped: true,
68058         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")
68059     };
68060 })(ts || (ts = {}));
68061 var ts;
68062 (function (ts) {
68063     function transformES2018(context) {
68064         var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
68065         var resolver = context.getEmitResolver();
68066         var compilerOptions = context.getCompilerOptions();
68067         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
68068         var previousOnEmitNode = context.onEmitNode;
68069         context.onEmitNode = onEmitNode;
68070         var previousOnSubstituteNode = context.onSubstituteNode;
68071         context.onSubstituteNode = onSubstituteNode;
68072         var exportedVariableStatement = false;
68073         var enabledSubstitutions;
68074         var enclosingFunctionFlags;
68075         var enclosingSuperContainerFlags = 0;
68076         var hierarchyFacts = 0;
68077         var currentSourceFile;
68078         var taggedTemplateStringDeclarations;
68079         var capturedSuperProperties;
68080         var hasSuperElementAccess;
68081         var substitutedSuperAccessors = [];
68082         return ts.chainBundle(transformSourceFile);
68083         function affectsSubtree(excludeFacts, includeFacts) {
68084             return hierarchyFacts !== (hierarchyFacts & ~excludeFacts | includeFacts);
68085         }
68086         function enterSubtree(excludeFacts, includeFacts) {
68087             var ancestorFacts = hierarchyFacts;
68088             hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3;
68089             return ancestorFacts;
68090         }
68091         function exitSubtree(ancestorFacts) {
68092             hierarchyFacts = ancestorFacts;
68093         }
68094         function recordTaggedTemplateString(temp) {
68095             taggedTemplateStringDeclarations = ts.append(taggedTemplateStringDeclarations, ts.createVariableDeclaration(temp));
68096         }
68097         function transformSourceFile(node) {
68098             if (node.isDeclarationFile) {
68099                 return node;
68100             }
68101             currentSourceFile = node;
68102             var visited = visitSourceFile(node);
68103             ts.addEmitHelpers(visited, context.readEmitHelpers());
68104             currentSourceFile = undefined;
68105             taggedTemplateStringDeclarations = undefined;
68106             return visited;
68107         }
68108         function visitor(node) {
68109             return visitorWorker(node, false);
68110         }
68111         function visitorNoDestructuringValue(node) {
68112             return visitorWorker(node, true);
68113         }
68114         function visitorNoAsyncModifier(node) {
68115             if (node.kind === 126) {
68116                 return undefined;
68117             }
68118             return node;
68119         }
68120         function doWithHierarchyFacts(cb, value, excludeFacts, includeFacts) {
68121             if (affectsSubtree(excludeFacts, includeFacts)) {
68122                 var ancestorFacts = enterSubtree(excludeFacts, includeFacts);
68123                 var result = cb(value);
68124                 exitSubtree(ancestorFacts);
68125                 return result;
68126             }
68127             return cb(value);
68128         }
68129         function visitDefault(node) {
68130             return ts.visitEachChild(node, visitor, context);
68131         }
68132         function visitorWorker(node, noDestructuringValue) {
68133             if ((node.transformFlags & 32) === 0) {
68134                 return node;
68135             }
68136             switch (node.kind) {
68137                 case 206:
68138                     return visitAwaitExpression(node);
68139                 case 212:
68140                     return visitYieldExpression(node);
68141                 case 235:
68142                     return visitReturnStatement(node);
68143                 case 238:
68144                     return visitLabeledStatement(node);
68145                 case 193:
68146                     return visitObjectLiteralExpression(node);
68147                 case 209:
68148                     return visitBinaryExpression(node, noDestructuringValue);
68149                 case 280:
68150                     return visitCatchClause(node);
68151                 case 225:
68152                     return visitVariableStatement(node);
68153                 case 242:
68154                     return visitVariableDeclaration(node);
68155                 case 228:
68156                 case 229:
68157                 case 231:
68158                     return doWithHierarchyFacts(visitDefault, node, 0, 2);
68159                 case 232:
68160                     return visitForOfStatement(node, undefined);
68161                 case 230:
68162                     return doWithHierarchyFacts(visitForStatement, node, 0, 2);
68163                 case 205:
68164                     return visitVoidExpression(node);
68165                 case 162:
68166                     return doWithHierarchyFacts(visitConstructorDeclaration, node, 2, 1);
68167                 case 161:
68168                     return doWithHierarchyFacts(visitMethodDeclaration, node, 2, 1);
68169                 case 163:
68170                     return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2, 1);
68171                 case 164:
68172                     return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2, 1);
68173                 case 244:
68174                     return doWithHierarchyFacts(visitFunctionDeclaration, node, 2, 1);
68175                 case 201:
68176                     return doWithHierarchyFacts(visitFunctionExpression, node, 2, 1);
68177                 case 202:
68178                     return doWithHierarchyFacts(visitArrowFunction, node, 2, 0);
68179                 case 156:
68180                     return visitParameter(node);
68181                 case 226:
68182                     return visitExpressionStatement(node);
68183                 case 200:
68184                     return visitParenthesizedExpression(node, noDestructuringValue);
68185                 case 198:
68186                     return visitTaggedTemplateExpression(node);
68187                 case 194:
68188                     if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 102) {
68189                         capturedSuperProperties.set(node.name.escapedText, true);
68190                     }
68191                     return ts.visitEachChild(node, visitor, context);
68192                 case 195:
68193                     if (capturedSuperProperties && node.expression.kind === 102) {
68194                         hasSuperElementAccess = true;
68195                     }
68196                     return ts.visitEachChild(node, visitor, context);
68197                 case 245:
68198                 case 214:
68199                     return doWithHierarchyFacts(visitDefault, node, 2, 1);
68200                 default:
68201                     return ts.visitEachChild(node, visitor, context);
68202             }
68203         }
68204         function visitAwaitExpression(node) {
68205             if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) {
68206                 return ts.setOriginalNode(ts.setTextRange(ts.createYield(createAwaitHelper(context, ts.visitNode(node.expression, visitor, ts.isExpression))), node), node);
68207             }
68208             return ts.visitEachChild(node, visitor, context);
68209         }
68210         function visitYieldExpression(node) {
68211             if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) {
68212                 if (node.asteriskToken) {
68213                     var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
68214                     return ts.setOriginalNode(ts.setTextRange(ts.createYield(createAwaitHelper(context, ts.updateYield(node, node.asteriskToken, createAsyncDelegatorHelper(context, createAsyncValuesHelper(context, expression, expression), expression)))), node), node);
68215                 }
68216                 return ts.setOriginalNode(ts.setTextRange(ts.createYield(createDownlevelAwait(node.expression
68217                     ? ts.visitNode(node.expression, visitor, ts.isExpression)
68218                     : ts.createVoidZero())), node), node);
68219             }
68220             return ts.visitEachChild(node, visitor, context);
68221         }
68222         function visitReturnStatement(node) {
68223             if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) {
68224                 return ts.updateReturn(node, createDownlevelAwait(node.expression ? ts.visitNode(node.expression, visitor, ts.isExpression) : ts.createVoidZero()));
68225             }
68226             return ts.visitEachChild(node, visitor, context);
68227         }
68228         function visitLabeledStatement(node) {
68229             if (enclosingFunctionFlags & 2) {
68230                 var statement = ts.unwrapInnermostStatementOfLabel(node);
68231                 if (statement.kind === 232 && statement.awaitModifier) {
68232                     return visitForOfStatement(statement, node);
68233                 }
68234                 return ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, ts.liftToBlock), node);
68235             }
68236             return ts.visitEachChild(node, visitor, context);
68237         }
68238         function chunkObjectLiteralElements(elements) {
68239             var chunkObject;
68240             var objects = [];
68241             for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) {
68242                 var e = elements_4[_i];
68243                 if (e.kind === 283) {
68244                     if (chunkObject) {
68245                         objects.push(ts.createObjectLiteral(chunkObject));
68246                         chunkObject = undefined;
68247                     }
68248                     var target = e.expression;
68249                     objects.push(ts.visitNode(target, visitor, ts.isExpression));
68250                 }
68251                 else {
68252                     chunkObject = ts.append(chunkObject, e.kind === 281
68253                         ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression))
68254                         : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike));
68255                 }
68256             }
68257             if (chunkObject) {
68258                 objects.push(ts.createObjectLiteral(chunkObject));
68259             }
68260             return objects;
68261         }
68262         function visitObjectLiteralExpression(node) {
68263             if (node.transformFlags & 16384) {
68264                 var objects = chunkObjectLiteralElements(node.properties);
68265                 if (objects.length && objects[0].kind !== 193) {
68266                     objects.unshift(ts.createObjectLiteral());
68267                 }
68268                 var expression = objects[0];
68269                 if (objects.length > 1) {
68270                     for (var i = 1; i < objects.length; i++) {
68271                         expression = createAssignHelper(context, [expression, objects[i]]);
68272                     }
68273                     return expression;
68274                 }
68275                 else {
68276                     return createAssignHelper(context, objects);
68277                 }
68278             }
68279             return ts.visitEachChild(node, visitor, context);
68280         }
68281         function visitExpressionStatement(node) {
68282             return ts.visitEachChild(node, visitorNoDestructuringValue, context);
68283         }
68284         function visitParenthesizedExpression(node, noDestructuringValue) {
68285             return ts.visitEachChild(node, noDestructuringValue ? visitorNoDestructuringValue : visitor, context);
68286         }
68287         function visitSourceFile(node) {
68288             var ancestorFacts = enterSubtree(2, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ?
68289                 0 :
68290                 1);
68291             exportedVariableStatement = false;
68292             var visited = ts.visitEachChild(node, visitor, context);
68293             var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [
68294                 ts.createVariableStatement(undefined, ts.createVariableDeclarationList(taggedTemplateStringDeclarations))
68295             ]);
68296             var result = ts.updateSourceFileNode(visited, ts.setTextRange(ts.createNodeArray(statement), node.statements));
68297             exitSubtree(ancestorFacts);
68298             return result;
68299         }
68300         function visitTaggedTemplateExpression(node) {
68301             return ts.processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, ts.ProcessLevel.LiftRestriction);
68302         }
68303         function visitBinaryExpression(node, noDestructuringValue) {
68304             if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 16384) {
68305                 return ts.flattenDestructuringAssignment(node, visitor, context, 1, !noDestructuringValue);
68306             }
68307             else if (node.operatorToken.kind === 27) {
68308                 return ts.updateBinary(node, ts.visitNode(node.left, visitorNoDestructuringValue, ts.isExpression), ts.visitNode(node.right, noDestructuringValue ? visitorNoDestructuringValue : visitor, ts.isExpression));
68309             }
68310             return ts.visitEachChild(node, visitor, context);
68311         }
68312         function visitCatchClause(node) {
68313             if (node.variableDeclaration &&
68314                 ts.isBindingPattern(node.variableDeclaration.name) &&
68315                 node.variableDeclaration.name.transformFlags & 16384) {
68316                 var name = ts.getGeneratedNameForNode(node.variableDeclaration.name);
68317                 var updatedDecl = ts.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, undefined, name);
68318                 var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1);
68319                 var block = ts.visitNode(node.block, visitor, ts.isBlock);
68320                 if (ts.some(visitedBindings)) {
68321                     block = ts.updateBlock(block, __spreadArrays([
68322                         ts.createVariableStatement(undefined, visitedBindings)
68323                     ], block.statements));
68324                 }
68325                 return ts.updateCatchClause(node, ts.updateVariableDeclaration(node.variableDeclaration, name, undefined, undefined), block);
68326             }
68327             return ts.visitEachChild(node, visitor, context);
68328         }
68329         function visitVariableStatement(node) {
68330             if (ts.hasModifier(node, 1)) {
68331                 var savedExportedVariableStatement = exportedVariableStatement;
68332                 exportedVariableStatement = true;
68333                 var visited = ts.visitEachChild(node, visitor, context);
68334                 exportedVariableStatement = savedExportedVariableStatement;
68335                 return visited;
68336             }
68337             return ts.visitEachChild(node, visitor, context);
68338         }
68339         function visitVariableDeclaration(node) {
68340             if (exportedVariableStatement) {
68341                 var savedExportedVariableStatement = exportedVariableStatement;
68342                 exportedVariableStatement = false;
68343                 var visited = visitVariableDeclarationWorker(node, true);
68344                 exportedVariableStatement = savedExportedVariableStatement;
68345                 return visited;
68346             }
68347             return visitVariableDeclarationWorker(node, false);
68348         }
68349         function visitVariableDeclarationWorker(node, exportedVariableStatement) {
68350             if (ts.isBindingPattern(node.name) && node.name.transformFlags & 16384) {
68351                 return ts.flattenDestructuringBinding(node, visitor, context, 1, undefined, exportedVariableStatement);
68352             }
68353             return ts.visitEachChild(node, visitor, context);
68354         }
68355         function visitForStatement(node) {
68356             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));
68357         }
68358         function visitVoidExpression(node) {
68359             return ts.visitEachChild(node, visitorNoDestructuringValue, context);
68360         }
68361         function visitForOfStatement(node, outermostLabeledStatement) {
68362             var ancestorFacts = enterSubtree(0, 2);
68363             if (node.initializer.transformFlags & 16384) {
68364                 node = transformForOfStatementWithObjectRest(node);
68365             }
68366             var result = node.awaitModifier ?
68367                 transformForAwaitOfStatement(node, outermostLabeledStatement, ancestorFacts) :
68368                 ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement);
68369             exitSubtree(ancestorFacts);
68370             return result;
68371         }
68372         function transformForOfStatementWithObjectRest(node) {
68373             var initializerWithoutParens = ts.skipParentheses(node.initializer);
68374             if (ts.isVariableDeclarationList(initializerWithoutParens) || ts.isAssignmentPattern(initializerWithoutParens)) {
68375                 var bodyLocation = void 0;
68376                 var statementsLocation = void 0;
68377                 var temp = ts.createTempVariable(undefined);
68378                 var statements = [ts.createForOfBindingStatement(initializerWithoutParens, temp)];
68379                 if (ts.isBlock(node.statement)) {
68380                     ts.addRange(statements, node.statement.statements);
68381                     bodyLocation = node.statement;
68382                     statementsLocation = node.statement.statements;
68383                 }
68384                 else if (node.statement) {
68385                     ts.append(statements, node.statement);
68386                     bodyLocation = node.statement;
68387                     statementsLocation = node.statement;
68388                 }
68389                 return ts.updateForOf(node, node.awaitModifier, ts.setTextRange(ts.createVariableDeclarationList([
68390                     ts.setTextRange(ts.createVariableDeclaration(temp), node.initializer)
68391                 ], 1), node.initializer), node.expression, ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true), bodyLocation));
68392             }
68393             return node;
68394         }
68395         function convertForOfStatementHead(node, boundValue) {
68396             var binding = ts.createForOfBindingStatement(node.initializer, boundValue);
68397             var bodyLocation;
68398             var statementsLocation;
68399             var statements = [ts.visitNode(binding, visitor, ts.isStatement)];
68400             var statement = ts.visitNode(node.statement, visitor, ts.isStatement);
68401             if (ts.isBlock(statement)) {
68402                 ts.addRange(statements, statement.statements);
68403                 bodyLocation = statement;
68404                 statementsLocation = statement.statements;
68405             }
68406             else {
68407                 statements.push(statement);
68408             }
68409             return ts.setEmitFlags(ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true), bodyLocation), 48 | 384);
68410         }
68411         function createDownlevelAwait(expression) {
68412             return enclosingFunctionFlags & 1
68413                 ? ts.createYield(undefined, createAwaitHelper(context, expression))
68414                 : ts.createAwait(expression);
68415         }
68416         function transformForAwaitOfStatement(node, outermostLabeledStatement, ancestorFacts) {
68417             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
68418             var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(undefined);
68419             var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(undefined);
68420             var errorRecord = ts.createUniqueName("e");
68421             var catchVariable = ts.getGeneratedNameForNode(errorRecord);
68422             var returnMethod = ts.createTempVariable(undefined);
68423             var callValues = createAsyncValuesHelper(context, expression, node.expression);
68424             var callNext = ts.createCall(ts.createPropertyAccess(iterator, "next"), undefined, []);
68425             var getDone = ts.createPropertyAccess(result, "done");
68426             var getValue = ts.createPropertyAccess(result, "value");
68427             var callReturn = ts.createFunctionCall(returnMethod, iterator, []);
68428             hoistVariableDeclaration(errorRecord);
68429             hoistVariableDeclaration(returnMethod);
68430             var initializer = ancestorFacts & 2 ?
68431                 ts.inlineExpressions([ts.createAssignment(errorRecord, ts.createVoidZero()), callValues]) :
68432                 callValues;
68433             var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([
68434                 ts.setTextRange(ts.createVariableDeclaration(iterator, undefined, initializer), node.expression),
68435                 ts.createVariableDeclaration(result)
68436             ]), node.expression), 2097152), ts.createComma(ts.createAssignment(result, createDownlevelAwait(callNext)), ts.createLogicalNot(getDone)), undefined, convertForOfStatementHead(node, getValue)), node), 256);
68437             return ts.createTry(ts.createBlock([
68438                 ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement)
68439             ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([
68440                 ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([
68441                     ts.createPropertyAssignment("error", catchVariable)
68442                 ])))
68443             ]), 1)), ts.createBlock([
68444                 ts.createTry(ts.createBlock([
68445                     ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(createDownlevelAwait(callReturn))), 1)
68446                 ]), undefined, ts.setEmitFlags(ts.createBlock([
68447                     ts.setEmitFlags(ts.createIf(errorRecord, ts.createThrow(ts.createPropertyAccess(errorRecord, "error"))), 1)
68448                 ]), 1))
68449             ]));
68450         }
68451         function visitParameter(node) {
68452             if (node.transformFlags & 16384) {
68453                 return ts.updateParameter(node, undefined, undefined, node.dotDotDotToken, ts.getGeneratedNameForNode(node), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
68454             }
68455             return ts.visitEachChild(node, visitor, context);
68456         }
68457         function visitConstructorDeclaration(node) {
68458             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68459             enclosingFunctionFlags = 0;
68460             var updated = ts.updateConstructor(node, undefined, node.modifiers, ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
68461             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68462             return updated;
68463         }
68464         function visitGetAccessorDeclaration(node) {
68465             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68466             enclosingFunctionFlags = 0;
68467             var updated = ts.updateGetAccessor(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node));
68468             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68469             return updated;
68470         }
68471         function visitSetAccessorDeclaration(node) {
68472             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68473             enclosingFunctionFlags = 0;
68474             var updated = ts.updateSetAccessor(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
68475             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68476             return updated;
68477         }
68478         function visitMethodDeclaration(node) {
68479             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68480             enclosingFunctionFlags = ts.getFunctionFlags(node);
68481             var updated = ts.updateMethod(node, undefined, enclosingFunctionFlags & 1
68482                 ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
68483                 : node.modifiers, enclosingFunctionFlags & 2
68484                 ? undefined
68485                 : 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
68486                 ? transformAsyncGeneratorFunctionBody(node)
68487                 : transformFunctionBody(node));
68488             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68489             return updated;
68490         }
68491         function visitFunctionDeclaration(node) {
68492             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68493             enclosingFunctionFlags = ts.getFunctionFlags(node);
68494             var updated = ts.updateFunctionDeclaration(node, undefined, enclosingFunctionFlags & 1
68495                 ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
68496                 : node.modifiers, enclosingFunctionFlags & 2
68497                 ? undefined
68498                 : node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1
68499                 ? transformAsyncGeneratorFunctionBody(node)
68500                 : transformFunctionBody(node));
68501             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68502             return updated;
68503         }
68504         function visitArrowFunction(node) {
68505             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68506             enclosingFunctionFlags = ts.getFunctionFlags(node);
68507             var updated = ts.updateArrowFunction(node, node.modifiers, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.equalsGreaterThanToken, transformFunctionBody(node));
68508             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68509             return updated;
68510         }
68511         function visitFunctionExpression(node) {
68512             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68513             enclosingFunctionFlags = ts.getFunctionFlags(node);
68514             var updated = ts.updateFunctionExpression(node, enclosingFunctionFlags & 1
68515                 ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
68516                 : node.modifiers, enclosingFunctionFlags & 2
68517                 ? undefined
68518                 : node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1
68519                 ? transformAsyncGeneratorFunctionBody(node)
68520                 : transformFunctionBody(node));
68521             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68522             return updated;
68523         }
68524         function transformAsyncGeneratorFunctionBody(node) {
68525             resumeLexicalEnvironment();
68526             var statements = [];
68527             var statementOffset = ts.addPrologue(statements, node.body.statements, false, visitor);
68528             appendObjectRestAssignmentsIfNeeded(statements, node);
68529             var savedCapturedSuperProperties = capturedSuperProperties;
68530             var savedHasSuperElementAccess = hasSuperElementAccess;
68531             capturedSuperProperties = ts.createUnderscoreEscapedMap();
68532             hasSuperElementAccess = false;
68533             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)));
68534             var emitSuperHelpers = languageVersion >= 2 && resolver.getNodeCheckFlags(node) & (4096 | 2048);
68535             if (emitSuperHelpers) {
68536                 enableSubstitutionForAsyncMethodsWithSuper();
68537                 var variableStatement = ts.createSuperAccessVariableStatement(resolver, node, capturedSuperProperties);
68538                 substitutedSuperAccessors[ts.getNodeId(variableStatement)] = true;
68539                 ts.insertStatementsAfterStandardPrologue(statements, [variableStatement]);
68540             }
68541             statements.push(returnStatement);
68542             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
68543             var block = ts.updateBlock(node.body, statements);
68544             if (emitSuperHelpers && hasSuperElementAccess) {
68545                 if (resolver.getNodeCheckFlags(node) & 4096) {
68546                     ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
68547                 }
68548                 else if (resolver.getNodeCheckFlags(node) & 2048) {
68549                     ts.addEmitHelper(block, ts.asyncSuperHelper);
68550                 }
68551             }
68552             capturedSuperProperties = savedCapturedSuperProperties;
68553             hasSuperElementAccess = savedHasSuperElementAccess;
68554             return block;
68555         }
68556         function transformFunctionBody(node) {
68557             resumeLexicalEnvironment();
68558             var statementOffset = 0;
68559             var statements = [];
68560             var body = ts.visitNode(node.body, visitor, ts.isConciseBody);
68561             if (ts.isBlock(body)) {
68562                 statementOffset = ts.addPrologue(statements, body.statements, false, visitor);
68563             }
68564             ts.addRange(statements, appendObjectRestAssignmentsIfNeeded(undefined, node));
68565             var leadingStatements = endLexicalEnvironment();
68566             if (statementOffset > 0 || ts.some(statements) || ts.some(leadingStatements)) {
68567                 var block = ts.convertToFunctionBody(body, true);
68568                 ts.insertStatementsAfterStandardPrologue(statements, leadingStatements);
68569                 ts.addRange(statements, block.statements.slice(statementOffset));
68570                 return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(statements), block.statements));
68571             }
68572             return body;
68573         }
68574         function appendObjectRestAssignmentsIfNeeded(statements, node) {
68575             for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
68576                 var parameter = _a[_i];
68577                 if (parameter.transformFlags & 16384) {
68578                     var temp = ts.getGeneratedNameForNode(parameter);
68579                     var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1, temp, false, true);
68580                     if (ts.some(declarations)) {
68581                         var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList(declarations));
68582                         ts.setEmitFlags(statement, 1048576);
68583                         statements = ts.append(statements, statement);
68584                     }
68585                 }
68586             }
68587             return statements;
68588         }
68589         function enableSubstitutionForAsyncMethodsWithSuper() {
68590             if ((enabledSubstitutions & 1) === 0) {
68591                 enabledSubstitutions |= 1;
68592                 context.enableSubstitution(196);
68593                 context.enableSubstitution(194);
68594                 context.enableSubstitution(195);
68595                 context.enableEmitNotification(245);
68596                 context.enableEmitNotification(161);
68597                 context.enableEmitNotification(163);
68598                 context.enableEmitNotification(164);
68599                 context.enableEmitNotification(162);
68600                 context.enableEmitNotification(225);
68601             }
68602         }
68603         function onEmitNode(hint, node, emitCallback) {
68604             if (enabledSubstitutions & 1 && isSuperContainer(node)) {
68605                 var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 | 4096);
68606                 if (superContainerFlags !== enclosingSuperContainerFlags) {
68607                     var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
68608                     enclosingSuperContainerFlags = superContainerFlags;
68609                     previousOnEmitNode(hint, node, emitCallback);
68610                     enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
68611                     return;
68612                 }
68613             }
68614             else if (enabledSubstitutions && substitutedSuperAccessors[ts.getNodeId(node)]) {
68615                 var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
68616                 enclosingSuperContainerFlags = 0;
68617                 previousOnEmitNode(hint, node, emitCallback);
68618                 enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
68619                 return;
68620             }
68621             previousOnEmitNode(hint, node, emitCallback);
68622         }
68623         function onSubstituteNode(hint, node) {
68624             node = previousOnSubstituteNode(hint, node);
68625             if (hint === 1 && enclosingSuperContainerFlags) {
68626                 return substituteExpression(node);
68627             }
68628             return node;
68629         }
68630         function substituteExpression(node) {
68631             switch (node.kind) {
68632                 case 194:
68633                     return substitutePropertyAccessExpression(node);
68634                 case 195:
68635                     return substituteElementAccessExpression(node);
68636                 case 196:
68637                     return substituteCallExpression(node);
68638             }
68639             return node;
68640         }
68641         function substitutePropertyAccessExpression(node) {
68642             if (node.expression.kind === 102) {
68643                 return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node);
68644             }
68645             return node;
68646         }
68647         function substituteElementAccessExpression(node) {
68648             if (node.expression.kind === 102) {
68649                 return createSuperElementAccessInAsyncMethod(node.argumentExpression, node);
68650             }
68651             return node;
68652         }
68653         function substituteCallExpression(node) {
68654             var expression = node.expression;
68655             if (ts.isSuperProperty(expression)) {
68656                 var argumentExpression = ts.isPropertyAccessExpression(expression)
68657                     ? substitutePropertyAccessExpression(expression)
68658                     : substituteElementAccessExpression(expression);
68659                 return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, __spreadArrays([
68660                     ts.createThis()
68661                 ], node.arguments));
68662             }
68663             return node;
68664         }
68665         function isSuperContainer(node) {
68666             var kind = node.kind;
68667             return kind === 245
68668                 || kind === 162
68669                 || kind === 161
68670                 || kind === 163
68671                 || kind === 164;
68672         }
68673         function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
68674             if (enclosingSuperContainerFlags & 4096) {
68675                 return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_superIndex"), undefined, [argumentExpression]), "value"), location);
68676             }
68677             else {
68678                 return ts.setTextRange(ts.createCall(ts.createIdentifier("_superIndex"), undefined, [argumentExpression]), location);
68679             }
68680         }
68681     }
68682     ts.transformES2018 = transformES2018;
68683     ts.assignHelper = {
68684         name: "typescript:assign",
68685         importName: "__assign",
68686         scoped: false,
68687         priority: 1,
68688         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            };"
68689     };
68690     function createAssignHelper(context, attributesSegments) {
68691         if (context.getCompilerOptions().target >= 2) {
68692             return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), undefined, attributesSegments);
68693         }
68694         context.requestEmitHelper(ts.assignHelper);
68695         return ts.createCall(ts.getUnscopedHelperName("__assign"), undefined, attributesSegments);
68696     }
68697     ts.createAssignHelper = createAssignHelper;
68698     ts.awaitHelper = {
68699         name: "typescript:await",
68700         importName: "__await",
68701         scoped: false,
68702         text: "\n            var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }"
68703     };
68704     function createAwaitHelper(context, expression) {
68705         context.requestEmitHelper(ts.awaitHelper);
68706         return ts.createCall(ts.getUnscopedHelperName("__await"), undefined, [expression]);
68707     }
68708     ts.asyncGeneratorHelper = {
68709         name: "typescript:asyncGenerator",
68710         importName: "__asyncGenerator",
68711         scoped: false,
68712         dependencies: [ts.awaitHelper],
68713         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            };"
68714     };
68715     function createAsyncGeneratorHelper(context, generatorFunc, hasLexicalThis) {
68716         context.requestEmitHelper(ts.asyncGeneratorHelper);
68717         (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 | 524288;
68718         return ts.createCall(ts.getUnscopedHelperName("__asyncGenerator"), undefined, [
68719             hasLexicalThis ? ts.createThis() : ts.createVoidZero(),
68720             ts.createIdentifier("arguments"),
68721             generatorFunc
68722         ]);
68723     }
68724     ts.asyncDelegator = {
68725         name: "typescript:asyncDelegator",
68726         importName: "__asyncDelegator",
68727         scoped: false,
68728         dependencies: [ts.awaitHelper],
68729         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            };"
68730     };
68731     function createAsyncDelegatorHelper(context, expression, location) {
68732         context.requestEmitHelper(ts.asyncDelegator);
68733         return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncDelegator"), undefined, [expression]), location);
68734     }
68735     ts.asyncValues = {
68736         name: "typescript:asyncValues",
68737         importName: "__asyncValues",
68738         scoped: false,
68739         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            };"
68740     };
68741     function createAsyncValuesHelper(context, expression, location) {
68742         context.requestEmitHelper(ts.asyncValues);
68743         return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncValues"), undefined, [expression]), location);
68744     }
68745 })(ts || (ts = {}));
68746 var ts;
68747 (function (ts) {
68748     function transformES2019(context) {
68749         return ts.chainBundle(transformSourceFile);
68750         function transformSourceFile(node) {
68751             if (node.isDeclarationFile) {
68752                 return node;
68753             }
68754             return ts.visitEachChild(node, visitor, context);
68755         }
68756         function visitor(node) {
68757             if ((node.transformFlags & 16) === 0) {
68758                 return node;
68759             }
68760             switch (node.kind) {
68761                 case 280:
68762                     return visitCatchClause(node);
68763                 default:
68764                     return ts.visitEachChild(node, visitor, context);
68765             }
68766         }
68767         function visitCatchClause(node) {
68768             if (!node.variableDeclaration) {
68769                 return ts.updateCatchClause(node, ts.createVariableDeclaration(ts.createTempVariable(undefined)), ts.visitNode(node.block, visitor, ts.isBlock));
68770             }
68771             return ts.visitEachChild(node, visitor, context);
68772         }
68773     }
68774     ts.transformES2019 = transformES2019;
68775 })(ts || (ts = {}));
68776 var ts;
68777 (function (ts) {
68778     function transformES2020(context) {
68779         var hoistVariableDeclaration = context.hoistVariableDeclaration;
68780         return ts.chainBundle(transformSourceFile);
68781         function transformSourceFile(node) {
68782             if (node.isDeclarationFile) {
68783                 return node;
68784             }
68785             return ts.visitEachChild(node, visitor, context);
68786         }
68787         function visitor(node) {
68788             if ((node.transformFlags & 8) === 0) {
68789                 return node;
68790             }
68791             switch (node.kind) {
68792                 case 194:
68793                 case 195:
68794                 case 196:
68795                     if (node.flags & 32) {
68796                         var updated = visitOptionalExpression(node, false, false);
68797                         ts.Debug.assertNotNode(updated, ts.isSyntheticReference);
68798                         return updated;
68799                     }
68800                     return ts.visitEachChild(node, visitor, context);
68801                 case 209:
68802                     if (node.operatorToken.kind === 60) {
68803                         return transformNullishCoalescingExpression(node);
68804                     }
68805                     return ts.visitEachChild(node, visitor, context);
68806                 case 203:
68807                     return visitDeleteExpression(node);
68808                 default:
68809                     return ts.visitEachChild(node, visitor, context);
68810             }
68811         }
68812         function flattenChain(chain) {
68813             ts.Debug.assertNotNode(chain, ts.isNonNullChain);
68814             var links = [chain];
68815             while (!chain.questionDotToken && !ts.isTaggedTemplateExpression(chain)) {
68816                 chain = ts.cast(ts.skipPartiallyEmittedExpressions(chain.expression), ts.isOptionalChain);
68817                 ts.Debug.assertNotNode(chain, ts.isNonNullChain);
68818                 links.unshift(chain);
68819             }
68820             return { expression: chain.expression, chain: links };
68821         }
68822         function visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete) {
68823             var expression = visitNonOptionalExpression(node.expression, captureThisArg, isDelete);
68824             if (ts.isSyntheticReference(expression)) {
68825                 return ts.createSyntheticReferenceExpression(ts.updateParen(node, expression.expression), expression.thisArg);
68826             }
68827             return ts.updateParen(node, expression);
68828         }
68829         function visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete) {
68830             if (ts.isOptionalChain(node)) {
68831                 return visitOptionalExpression(node, captureThisArg, isDelete);
68832             }
68833             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
68834             ts.Debug.assertNotNode(expression, ts.isSyntheticReference);
68835             var thisArg;
68836             if (captureThisArg) {
68837                 if (shouldCaptureInTempVariable(expression)) {
68838                     thisArg = ts.createTempVariable(hoistVariableDeclaration);
68839                     expression = ts.createAssignment(thisArg, expression);
68840                 }
68841                 else {
68842                     thisArg = expression;
68843                 }
68844             }
68845             expression = node.kind === 194
68846                 ? ts.updatePropertyAccess(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier))
68847                 : ts.updateElementAccess(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression));
68848             return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression;
68849         }
68850         function visitNonOptionalCallExpression(node, captureThisArg) {
68851             if (ts.isOptionalChain(node)) {
68852                 return visitOptionalExpression(node, captureThisArg, false);
68853             }
68854             return ts.visitEachChild(node, visitor, context);
68855         }
68856         function visitNonOptionalExpression(node, captureThisArg, isDelete) {
68857             switch (node.kind) {
68858                 case 200: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete);
68859                 case 194:
68860                 case 195: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete);
68861                 case 196: return visitNonOptionalCallExpression(node, captureThisArg);
68862                 default: return ts.visitNode(node, visitor, ts.isExpression);
68863             }
68864         }
68865         function visitOptionalExpression(node, captureThisArg, isDelete) {
68866             var _a = flattenChain(node), expression = _a.expression, chain = _a.chain;
68867             var left = visitNonOptionalExpression(expression, ts.isCallChain(chain[0]), false);
68868             var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined;
68869             var leftExpression = ts.isSyntheticReference(left) ? left.expression : left;
68870             var capturedLeft = leftExpression;
68871             if (shouldCaptureInTempVariable(leftExpression)) {
68872                 capturedLeft = ts.createTempVariable(hoistVariableDeclaration);
68873                 leftExpression = ts.createAssignment(capturedLeft, leftExpression);
68874             }
68875             var rightExpression = capturedLeft;
68876             var thisArg;
68877             for (var i = 0; i < chain.length; i++) {
68878                 var segment = chain[i];
68879                 switch (segment.kind) {
68880                     case 194:
68881                     case 195:
68882                         if (i === chain.length - 1 && captureThisArg) {
68883                             if (shouldCaptureInTempVariable(rightExpression)) {
68884                                 thisArg = ts.createTempVariable(hoistVariableDeclaration);
68885                                 rightExpression = ts.createAssignment(thisArg, rightExpression);
68886                             }
68887                             else {
68888                                 thisArg = rightExpression;
68889                             }
68890                         }
68891                         rightExpression = segment.kind === 194
68892                             ? ts.createPropertyAccess(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier))
68893                             : ts.createElementAccess(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression));
68894                         break;
68895                     case 196:
68896                         if (i === 0 && leftThisArg) {
68897                             rightExpression = ts.createFunctionCall(rightExpression, leftThisArg.kind === 102 ? ts.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression));
68898                         }
68899                         else {
68900                             rightExpression = ts.createCall(rightExpression, undefined, ts.visitNodes(segment.arguments, visitor, ts.isExpression));
68901                         }
68902                         break;
68903                 }
68904                 ts.setOriginalNode(rightExpression, segment);
68905             }
68906             var target = isDelete
68907                 ? ts.createConditional(createNotNullCondition(leftExpression, capturedLeft, true), ts.createTrue(), ts.createDelete(rightExpression))
68908                 : ts.createConditional(createNotNullCondition(leftExpression, capturedLeft, true), ts.createVoidZero(), rightExpression);
68909             return thisArg ? ts.createSyntheticReferenceExpression(target, thisArg) : target;
68910         }
68911         function createNotNullCondition(left, right, invert) {
68912             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()));
68913         }
68914         function transformNullishCoalescingExpression(node) {
68915             var left = ts.visitNode(node.left, visitor, ts.isExpression);
68916             var right = left;
68917             if (shouldCaptureInTempVariable(left)) {
68918                 right = ts.createTempVariable(hoistVariableDeclaration);
68919                 left = ts.createAssignment(right, left);
68920             }
68921             return ts.createConditional(createNotNullCondition(left, right), right, ts.visitNode(node.right, visitor, ts.isExpression));
68922         }
68923         function shouldCaptureInTempVariable(expression) {
68924             return !ts.isIdentifier(expression) &&
68925                 expression.kind !== 104 &&
68926                 expression.kind !== 102;
68927         }
68928         function visitDeleteExpression(node) {
68929             return ts.isOptionalChain(ts.skipParentheses(node.expression))
68930                 ? ts.setOriginalNode(visitNonOptionalExpression(node.expression, false, true), node)
68931                 : ts.updateDelete(node, ts.visitNode(node.expression, visitor, ts.isExpression));
68932         }
68933     }
68934     ts.transformES2020 = transformES2020;
68935 })(ts || (ts = {}));
68936 var ts;
68937 (function (ts) {
68938     function transformESNext(context) {
68939         return ts.chainBundle(transformSourceFile);
68940         function transformSourceFile(node) {
68941             if (node.isDeclarationFile) {
68942                 return node;
68943             }
68944             return ts.visitEachChild(node, visitor, context);
68945         }
68946         function visitor(node) {
68947             if ((node.transformFlags & 4) === 0) {
68948                 return node;
68949             }
68950             switch (node.kind) {
68951                 default:
68952                     return ts.visitEachChild(node, visitor, context);
68953             }
68954         }
68955     }
68956     ts.transformESNext = transformESNext;
68957 })(ts || (ts = {}));
68958 var ts;
68959 (function (ts) {
68960     function transformJsx(context) {
68961         var compilerOptions = context.getCompilerOptions();
68962         var currentSourceFile;
68963         return ts.chainBundle(transformSourceFile);
68964         function transformSourceFile(node) {
68965             if (node.isDeclarationFile) {
68966                 return node;
68967             }
68968             currentSourceFile = node;
68969             var visited = ts.visitEachChild(node, visitor, context);
68970             ts.addEmitHelpers(visited, context.readEmitHelpers());
68971             return visited;
68972         }
68973         function visitor(node) {
68974             if (node.transformFlags & 2) {
68975                 return visitorWorker(node);
68976             }
68977             else {
68978                 return node;
68979             }
68980         }
68981         function visitorWorker(node) {
68982             switch (node.kind) {
68983                 case 266:
68984                     return visitJsxElement(node, false);
68985                 case 267:
68986                     return visitJsxSelfClosingElement(node, false);
68987                 case 270:
68988                     return visitJsxFragment(node, false);
68989                 case 276:
68990                     return visitJsxExpression(node);
68991                 default:
68992                     return ts.visitEachChild(node, visitor, context);
68993             }
68994         }
68995         function transformJsxChildToExpression(node) {
68996             switch (node.kind) {
68997                 case 11:
68998                     return visitJsxText(node);
68999                 case 276:
69000                     return visitJsxExpression(node);
69001                 case 266:
69002                     return visitJsxElement(node, true);
69003                 case 267:
69004                     return visitJsxSelfClosingElement(node, true);
69005                 case 270:
69006                     return visitJsxFragment(node, true);
69007                 default:
69008                     return ts.Debug.failBadSyntaxKind(node);
69009             }
69010         }
69011         function visitJsxElement(node, isChild) {
69012             return visitJsxOpeningLikeElement(node.openingElement, node.children, isChild, node);
69013         }
69014         function visitJsxSelfClosingElement(node, isChild) {
69015             return visitJsxOpeningLikeElement(node, undefined, isChild, node);
69016         }
69017         function visitJsxFragment(node, isChild) {
69018             return visitJsxOpeningFragment(node.openingFragment, node.children, isChild, node);
69019         }
69020         function visitJsxOpeningLikeElement(node, children, isChild, location) {
69021             var tagName = getTagName(node);
69022             var objectProperties;
69023             var attrs = node.attributes.properties;
69024             if (attrs.length === 0) {
69025                 objectProperties = ts.createNull();
69026             }
69027             else {
69028                 var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
69029                     ? ts.map(attrs, transformJsxSpreadAttributeToExpression)
69030                     : ts.createObjectLiteral(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
69031                 if (ts.isJsxSpreadAttribute(attrs[0])) {
69032                     segments.unshift(ts.createObjectLiteral());
69033                 }
69034                 objectProperties = ts.singleOrUndefined(segments);
69035                 if (!objectProperties) {
69036                     objectProperties = ts.createAssignHelper(context, segments);
69037                 }
69038             }
69039             var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, tagName, objectProperties, ts.mapDefined(children, transformJsxChildToExpression), node, location);
69040             if (isChild) {
69041                 ts.startOnNewLine(element);
69042             }
69043             return element;
69044         }
69045         function visitJsxOpeningFragment(node, children, isChild, location) {
69046             var element = ts.createExpressionForJsxFragment(context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, ts.mapDefined(children, transformJsxChildToExpression), node, location);
69047             if (isChild) {
69048                 ts.startOnNewLine(element);
69049             }
69050             return element;
69051         }
69052         function transformJsxSpreadAttributeToExpression(node) {
69053             return ts.visitNode(node.expression, visitor, ts.isExpression);
69054         }
69055         function transformJsxAttributeToObjectLiteralElement(node) {
69056             var name = getAttributeName(node);
69057             var expression = transformJsxAttributeInitializer(node.initializer);
69058             return ts.createPropertyAssignment(name, expression);
69059         }
69060         function transformJsxAttributeInitializer(node) {
69061             if (node === undefined) {
69062                 return ts.createTrue();
69063             }
69064             else if (node.kind === 10) {
69065                 var literal = ts.createLiteral(tryDecodeEntities(node.text) || node.text);
69066                 literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile);
69067                 return ts.setTextRange(literal, node);
69068             }
69069             else if (node.kind === 276) {
69070                 if (node.expression === undefined) {
69071                     return ts.createTrue();
69072                 }
69073                 return visitJsxExpression(node);
69074             }
69075             else {
69076                 return ts.Debug.failBadSyntaxKind(node);
69077             }
69078         }
69079         function visitJsxText(node) {
69080             var fixed = fixupWhitespaceAndDecodeEntities(node.text);
69081             return fixed === undefined ? undefined : ts.createLiteral(fixed);
69082         }
69083         function fixupWhitespaceAndDecodeEntities(text) {
69084             var acc;
69085             var firstNonWhitespace = 0;
69086             var lastNonWhitespace = -1;
69087             for (var i = 0; i < text.length; i++) {
69088                 var c = text.charCodeAt(i);
69089                 if (ts.isLineBreak(c)) {
69090                     if (firstNonWhitespace !== -1 && lastNonWhitespace !== -1) {
69091                         acc = addLineOfJsxText(acc, text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1));
69092                     }
69093                     firstNonWhitespace = -1;
69094                 }
69095                 else if (!ts.isWhiteSpaceSingleLine(c)) {
69096                     lastNonWhitespace = i;
69097                     if (firstNonWhitespace === -1) {
69098                         firstNonWhitespace = i;
69099                     }
69100                 }
69101             }
69102             return firstNonWhitespace !== -1
69103                 ? addLineOfJsxText(acc, text.substr(firstNonWhitespace))
69104                 : acc;
69105         }
69106         function addLineOfJsxText(acc, trimmedLine) {
69107             var decoded = decodeEntities(trimmedLine);
69108             return acc === undefined ? decoded : acc + " " + decoded;
69109         }
69110         function decodeEntities(text) {
69111             return text.replace(/&((#((\d+)|x([\da-fA-F]+)))|(\w+));/g, function (match, _all, _number, _digits, decimal, hex, word) {
69112                 if (decimal) {
69113                     return ts.utf16EncodeAsString(parseInt(decimal, 10));
69114                 }
69115                 else if (hex) {
69116                     return ts.utf16EncodeAsString(parseInt(hex, 16));
69117                 }
69118                 else {
69119                     var ch = entities.get(word);
69120                     return ch ? ts.utf16EncodeAsString(ch) : match;
69121                 }
69122             });
69123         }
69124         function tryDecodeEntities(text) {
69125             var decoded = decodeEntities(text);
69126             return decoded === text ? undefined : decoded;
69127         }
69128         function getTagName(node) {
69129             if (node.kind === 266) {
69130                 return getTagName(node.openingElement);
69131             }
69132             else {
69133                 var name = node.tagName;
69134                 if (ts.isIdentifier(name) && ts.isIntrinsicJsxName(name.escapedText)) {
69135                     return ts.createLiteral(ts.idText(name));
69136                 }
69137                 else {
69138                     return ts.createExpressionFromEntityName(name);
69139                 }
69140             }
69141         }
69142         function getAttributeName(node) {
69143             var name = node.name;
69144             var text = ts.idText(name);
69145             if (/^[A-Za-z_]\w*$/.test(text)) {
69146                 return name;
69147             }
69148             else {
69149                 return ts.createLiteral(text);
69150             }
69151         }
69152         function visitJsxExpression(node) {
69153             return ts.visitNode(node.expression, visitor, ts.isExpression);
69154         }
69155     }
69156     ts.transformJsx = transformJsx;
69157     var entities = ts.createMapFromTemplate({
69158         quot: 0x0022,
69159         amp: 0x0026,
69160         apos: 0x0027,
69161         lt: 0x003C,
69162         gt: 0x003E,
69163         nbsp: 0x00A0,
69164         iexcl: 0x00A1,
69165         cent: 0x00A2,
69166         pound: 0x00A3,
69167         curren: 0x00A4,
69168         yen: 0x00A5,
69169         brvbar: 0x00A6,
69170         sect: 0x00A7,
69171         uml: 0x00A8,
69172         copy: 0x00A9,
69173         ordf: 0x00AA,
69174         laquo: 0x00AB,
69175         not: 0x00AC,
69176         shy: 0x00AD,
69177         reg: 0x00AE,
69178         macr: 0x00AF,
69179         deg: 0x00B0,
69180         plusmn: 0x00B1,
69181         sup2: 0x00B2,
69182         sup3: 0x00B3,
69183         acute: 0x00B4,
69184         micro: 0x00B5,
69185         para: 0x00B6,
69186         middot: 0x00B7,
69187         cedil: 0x00B8,
69188         sup1: 0x00B9,
69189         ordm: 0x00BA,
69190         raquo: 0x00BB,
69191         frac14: 0x00BC,
69192         frac12: 0x00BD,
69193         frac34: 0x00BE,
69194         iquest: 0x00BF,
69195         Agrave: 0x00C0,
69196         Aacute: 0x00C1,
69197         Acirc: 0x00C2,
69198         Atilde: 0x00C3,
69199         Auml: 0x00C4,
69200         Aring: 0x00C5,
69201         AElig: 0x00C6,
69202         Ccedil: 0x00C7,
69203         Egrave: 0x00C8,
69204         Eacute: 0x00C9,
69205         Ecirc: 0x00CA,
69206         Euml: 0x00CB,
69207         Igrave: 0x00CC,
69208         Iacute: 0x00CD,
69209         Icirc: 0x00CE,
69210         Iuml: 0x00CF,
69211         ETH: 0x00D0,
69212         Ntilde: 0x00D1,
69213         Ograve: 0x00D2,
69214         Oacute: 0x00D3,
69215         Ocirc: 0x00D4,
69216         Otilde: 0x00D5,
69217         Ouml: 0x00D6,
69218         times: 0x00D7,
69219         Oslash: 0x00D8,
69220         Ugrave: 0x00D9,
69221         Uacute: 0x00DA,
69222         Ucirc: 0x00DB,
69223         Uuml: 0x00DC,
69224         Yacute: 0x00DD,
69225         THORN: 0x00DE,
69226         szlig: 0x00DF,
69227         agrave: 0x00E0,
69228         aacute: 0x00E1,
69229         acirc: 0x00E2,
69230         atilde: 0x00E3,
69231         auml: 0x00E4,
69232         aring: 0x00E5,
69233         aelig: 0x00E6,
69234         ccedil: 0x00E7,
69235         egrave: 0x00E8,
69236         eacute: 0x00E9,
69237         ecirc: 0x00EA,
69238         euml: 0x00EB,
69239         igrave: 0x00EC,
69240         iacute: 0x00ED,
69241         icirc: 0x00EE,
69242         iuml: 0x00EF,
69243         eth: 0x00F0,
69244         ntilde: 0x00F1,
69245         ograve: 0x00F2,
69246         oacute: 0x00F3,
69247         ocirc: 0x00F4,
69248         otilde: 0x00F5,
69249         ouml: 0x00F6,
69250         divide: 0x00F7,
69251         oslash: 0x00F8,
69252         ugrave: 0x00F9,
69253         uacute: 0x00FA,
69254         ucirc: 0x00FB,
69255         uuml: 0x00FC,
69256         yacute: 0x00FD,
69257         thorn: 0x00FE,
69258         yuml: 0x00FF,
69259         OElig: 0x0152,
69260         oelig: 0x0153,
69261         Scaron: 0x0160,
69262         scaron: 0x0161,
69263         Yuml: 0x0178,
69264         fnof: 0x0192,
69265         circ: 0x02C6,
69266         tilde: 0x02DC,
69267         Alpha: 0x0391,
69268         Beta: 0x0392,
69269         Gamma: 0x0393,
69270         Delta: 0x0394,
69271         Epsilon: 0x0395,
69272         Zeta: 0x0396,
69273         Eta: 0x0397,
69274         Theta: 0x0398,
69275         Iota: 0x0399,
69276         Kappa: 0x039A,
69277         Lambda: 0x039B,
69278         Mu: 0x039C,
69279         Nu: 0x039D,
69280         Xi: 0x039E,
69281         Omicron: 0x039F,
69282         Pi: 0x03A0,
69283         Rho: 0x03A1,
69284         Sigma: 0x03A3,
69285         Tau: 0x03A4,
69286         Upsilon: 0x03A5,
69287         Phi: 0x03A6,
69288         Chi: 0x03A7,
69289         Psi: 0x03A8,
69290         Omega: 0x03A9,
69291         alpha: 0x03B1,
69292         beta: 0x03B2,
69293         gamma: 0x03B3,
69294         delta: 0x03B4,
69295         epsilon: 0x03B5,
69296         zeta: 0x03B6,
69297         eta: 0x03B7,
69298         theta: 0x03B8,
69299         iota: 0x03B9,
69300         kappa: 0x03BA,
69301         lambda: 0x03BB,
69302         mu: 0x03BC,
69303         nu: 0x03BD,
69304         xi: 0x03BE,
69305         omicron: 0x03BF,
69306         pi: 0x03C0,
69307         rho: 0x03C1,
69308         sigmaf: 0x03C2,
69309         sigma: 0x03C3,
69310         tau: 0x03C4,
69311         upsilon: 0x03C5,
69312         phi: 0x03C6,
69313         chi: 0x03C7,
69314         psi: 0x03C8,
69315         omega: 0x03C9,
69316         thetasym: 0x03D1,
69317         upsih: 0x03D2,
69318         piv: 0x03D6,
69319         ensp: 0x2002,
69320         emsp: 0x2003,
69321         thinsp: 0x2009,
69322         zwnj: 0x200C,
69323         zwj: 0x200D,
69324         lrm: 0x200E,
69325         rlm: 0x200F,
69326         ndash: 0x2013,
69327         mdash: 0x2014,
69328         lsquo: 0x2018,
69329         rsquo: 0x2019,
69330         sbquo: 0x201A,
69331         ldquo: 0x201C,
69332         rdquo: 0x201D,
69333         bdquo: 0x201E,
69334         dagger: 0x2020,
69335         Dagger: 0x2021,
69336         bull: 0x2022,
69337         hellip: 0x2026,
69338         permil: 0x2030,
69339         prime: 0x2032,
69340         Prime: 0x2033,
69341         lsaquo: 0x2039,
69342         rsaquo: 0x203A,
69343         oline: 0x203E,
69344         frasl: 0x2044,
69345         euro: 0x20AC,
69346         image: 0x2111,
69347         weierp: 0x2118,
69348         real: 0x211C,
69349         trade: 0x2122,
69350         alefsym: 0x2135,
69351         larr: 0x2190,
69352         uarr: 0x2191,
69353         rarr: 0x2192,
69354         darr: 0x2193,
69355         harr: 0x2194,
69356         crarr: 0x21B5,
69357         lArr: 0x21D0,
69358         uArr: 0x21D1,
69359         rArr: 0x21D2,
69360         dArr: 0x21D3,
69361         hArr: 0x21D4,
69362         forall: 0x2200,
69363         part: 0x2202,
69364         exist: 0x2203,
69365         empty: 0x2205,
69366         nabla: 0x2207,
69367         isin: 0x2208,
69368         notin: 0x2209,
69369         ni: 0x220B,
69370         prod: 0x220F,
69371         sum: 0x2211,
69372         minus: 0x2212,
69373         lowast: 0x2217,
69374         radic: 0x221A,
69375         prop: 0x221D,
69376         infin: 0x221E,
69377         ang: 0x2220,
69378         and: 0x2227,
69379         or: 0x2228,
69380         cap: 0x2229,
69381         cup: 0x222A,
69382         int: 0x222B,
69383         there4: 0x2234,
69384         sim: 0x223C,
69385         cong: 0x2245,
69386         asymp: 0x2248,
69387         ne: 0x2260,
69388         equiv: 0x2261,
69389         le: 0x2264,
69390         ge: 0x2265,
69391         sub: 0x2282,
69392         sup: 0x2283,
69393         nsub: 0x2284,
69394         sube: 0x2286,
69395         supe: 0x2287,
69396         oplus: 0x2295,
69397         otimes: 0x2297,
69398         perp: 0x22A5,
69399         sdot: 0x22C5,
69400         lceil: 0x2308,
69401         rceil: 0x2309,
69402         lfloor: 0x230A,
69403         rfloor: 0x230B,
69404         lang: 0x2329,
69405         rang: 0x232A,
69406         loz: 0x25CA,
69407         spades: 0x2660,
69408         clubs: 0x2663,
69409         hearts: 0x2665,
69410         diams: 0x2666
69411     });
69412 })(ts || (ts = {}));
69413 var ts;
69414 (function (ts) {
69415     function transformES2016(context) {
69416         var hoistVariableDeclaration = context.hoistVariableDeclaration;
69417         return ts.chainBundle(transformSourceFile);
69418         function transformSourceFile(node) {
69419             if (node.isDeclarationFile) {
69420                 return node;
69421             }
69422             return ts.visitEachChild(node, visitor, context);
69423         }
69424         function visitor(node) {
69425             if ((node.transformFlags & 128) === 0) {
69426                 return node;
69427             }
69428             switch (node.kind) {
69429                 case 209:
69430                     return visitBinaryExpression(node);
69431                 default:
69432                     return ts.visitEachChild(node, visitor, context);
69433             }
69434         }
69435         function visitBinaryExpression(node) {
69436             switch (node.operatorToken.kind) {
69437                 case 66:
69438                     return visitExponentiationAssignmentExpression(node);
69439                 case 42:
69440                     return visitExponentiationExpression(node);
69441                 default:
69442                     return ts.visitEachChild(node, visitor, context);
69443             }
69444         }
69445         function visitExponentiationAssignmentExpression(node) {
69446             var target;
69447             var value;
69448             var left = ts.visitNode(node.left, visitor, ts.isExpression);
69449             var right = ts.visitNode(node.right, visitor, ts.isExpression);
69450             if (ts.isElementAccessExpression(left)) {
69451                 var expressionTemp = ts.createTempVariable(hoistVariableDeclaration);
69452                 var argumentExpressionTemp = ts.createTempVariable(hoistVariableDeclaration);
69453                 target = ts.setTextRange(ts.createElementAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), ts.setTextRange(ts.createAssignment(argumentExpressionTemp, left.argumentExpression), left.argumentExpression)), left);
69454                 value = ts.setTextRange(ts.createElementAccess(expressionTemp, argumentExpressionTemp), left);
69455             }
69456             else if (ts.isPropertyAccessExpression(left)) {
69457                 var expressionTemp = ts.createTempVariable(hoistVariableDeclaration);
69458                 target = ts.setTextRange(ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), left.name), left);
69459                 value = ts.setTextRange(ts.createPropertyAccess(expressionTemp, left.name), left);
69460             }
69461             else {
69462                 target = left;
69463                 value = left;
69464             }
69465             return ts.setTextRange(ts.createAssignment(target, ts.createMathPow(value, right, node)), node);
69466         }
69467         function visitExponentiationExpression(node) {
69468             var left = ts.visitNode(node.left, visitor, ts.isExpression);
69469             var right = ts.visitNode(node.right, visitor, ts.isExpression);
69470             return ts.createMathPow(left, right, node);
69471         }
69472     }
69473     ts.transformES2016 = transformES2016;
69474 })(ts || (ts = {}));
69475 var ts;
69476 (function (ts) {
69477     function transformES2015(context) {
69478         var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
69479         var compilerOptions = context.getCompilerOptions();
69480         var resolver = context.getEmitResolver();
69481         var previousOnSubstituteNode = context.onSubstituteNode;
69482         var previousOnEmitNode = context.onEmitNode;
69483         context.onEmitNode = onEmitNode;
69484         context.onSubstituteNode = onSubstituteNode;
69485         var currentSourceFile;
69486         var currentText;
69487         var hierarchyFacts;
69488         var taggedTemplateStringDeclarations;
69489         function recordTaggedTemplateString(temp) {
69490             taggedTemplateStringDeclarations = ts.append(taggedTemplateStringDeclarations, ts.createVariableDeclaration(temp));
69491         }
69492         var convertedLoopState;
69493         var enabledSubstitutions;
69494         return ts.chainBundle(transformSourceFile);
69495         function transformSourceFile(node) {
69496             if (node.isDeclarationFile) {
69497                 return node;
69498             }
69499             currentSourceFile = node;
69500             currentText = node.text;
69501             var visited = visitSourceFile(node);
69502             ts.addEmitHelpers(visited, context.readEmitHelpers());
69503             currentSourceFile = undefined;
69504             currentText = undefined;
69505             taggedTemplateStringDeclarations = undefined;
69506             hierarchyFacts = 0;
69507             return visited;
69508         }
69509         function enterSubtree(excludeFacts, includeFacts) {
69510             var ancestorFacts = hierarchyFacts;
69511             hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383;
69512             return ancestorFacts;
69513         }
69514         function exitSubtree(ancestorFacts, excludeFacts, includeFacts) {
69515             hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 | ancestorFacts;
69516         }
69517         function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
69518             return (hierarchyFacts & 8192) !== 0
69519                 && node.kind === 235
69520                 && !node.expression;
69521         }
69522         function shouldVisitNode(node) {
69523             return (node.transformFlags & 256) !== 0
69524                 || convertedLoopState !== undefined
69525                 || (hierarchyFacts & 8192 && (ts.isStatement(node) || (node.kind === 223)))
69526                 || (ts.isIterationStatement(node, false) && shouldConvertIterationStatement(node))
69527                 || (ts.getEmitFlags(node) & 33554432) !== 0;
69528         }
69529         function visitor(node) {
69530             if (shouldVisitNode(node)) {
69531                 return visitJavaScript(node);
69532             }
69533             else {
69534                 return node;
69535             }
69536         }
69537         function callExpressionVisitor(node) {
69538             if (node.kind === 102) {
69539                 return visitSuperKeyword(true);
69540             }
69541             return visitor(node);
69542         }
69543         function visitJavaScript(node) {
69544             switch (node.kind) {
69545                 case 120:
69546                     return undefined;
69547                 case 245:
69548                     return visitClassDeclaration(node);
69549                 case 214:
69550                     return visitClassExpression(node);
69551                 case 156:
69552                     return visitParameter(node);
69553                 case 244:
69554                     return visitFunctionDeclaration(node);
69555                 case 202:
69556                     return visitArrowFunction(node);
69557                 case 201:
69558                     return visitFunctionExpression(node);
69559                 case 242:
69560                     return visitVariableDeclaration(node);
69561                 case 75:
69562                     return visitIdentifier(node);
69563                 case 243:
69564                     return visitVariableDeclarationList(node);
69565                 case 237:
69566                     return visitSwitchStatement(node);
69567                 case 251:
69568                     return visitCaseBlock(node);
69569                 case 223:
69570                     return visitBlock(node, false);
69571                 case 234:
69572                 case 233:
69573                     return visitBreakOrContinueStatement(node);
69574                 case 238:
69575                     return visitLabeledStatement(node);
69576                 case 228:
69577                 case 229:
69578                     return visitDoOrWhileStatement(node, undefined);
69579                 case 230:
69580                     return visitForStatement(node, undefined);
69581                 case 231:
69582                     return visitForInStatement(node, undefined);
69583                 case 232:
69584                     return visitForOfStatement(node, undefined);
69585                 case 226:
69586                     return visitExpressionStatement(node);
69587                 case 193:
69588                     return visitObjectLiteralExpression(node);
69589                 case 280:
69590                     return visitCatchClause(node);
69591                 case 282:
69592                     return visitShorthandPropertyAssignment(node);
69593                 case 154:
69594                     return visitComputedPropertyName(node);
69595                 case 192:
69596                     return visitArrayLiteralExpression(node);
69597                 case 196:
69598                     return visitCallExpression(node);
69599                 case 197:
69600                     return visitNewExpression(node);
69601                 case 200:
69602                     return visitParenthesizedExpression(node, true);
69603                 case 209:
69604                     return visitBinaryExpression(node, true);
69605                 case 14:
69606                 case 15:
69607                 case 16:
69608                 case 17:
69609                     return visitTemplateLiteral(node);
69610                 case 10:
69611                     return visitStringLiteral(node);
69612                 case 8:
69613                     return visitNumericLiteral(node);
69614                 case 198:
69615                     return visitTaggedTemplateExpression(node);
69616                 case 211:
69617                     return visitTemplateExpression(node);
69618                 case 212:
69619                     return visitYieldExpression(node);
69620                 case 213:
69621                     return visitSpreadElement(node);
69622                 case 102:
69623                     return visitSuperKeyword(false);
69624                 case 104:
69625                     return visitThisKeyword(node);
69626                 case 219:
69627                     return visitMetaProperty(node);
69628                 case 161:
69629                     return visitMethodDeclaration(node);
69630                 case 163:
69631                 case 164:
69632                     return visitAccessorDeclaration(node);
69633                 case 225:
69634                     return visitVariableStatement(node);
69635                 case 235:
69636                     return visitReturnStatement(node);
69637                 default:
69638                     return ts.visitEachChild(node, visitor, context);
69639             }
69640         }
69641         function visitSourceFile(node) {
69642             var ancestorFacts = enterSubtree(8064, 64);
69643             var prologue = [];
69644             var statements = [];
69645             startLexicalEnvironment();
69646             var statementOffset = ts.addStandardPrologue(prologue, node.statements, false);
69647             statementOffset = ts.addCustomPrologue(prologue, node.statements, statementOffset, visitor);
69648             ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset));
69649             if (taggedTemplateStringDeclarations) {
69650                 statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(taggedTemplateStringDeclarations)));
69651             }
69652             ts.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
69653             insertCaptureThisForNodeIfNeeded(prologue, node);
69654             exitSubtree(ancestorFacts, 0, 0);
69655             return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(ts.concatenate(prologue, statements)), node.statements));
69656         }
69657         function visitSwitchStatement(node) {
69658             if (convertedLoopState !== undefined) {
69659                 var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps;
69660                 convertedLoopState.allowedNonLabeledJumps |= 2;
69661                 var result = ts.visitEachChild(node, visitor, context);
69662                 convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps;
69663                 return result;
69664             }
69665             return ts.visitEachChild(node, visitor, context);
69666         }
69667         function visitCaseBlock(node) {
69668             var ancestorFacts = enterSubtree(7104, 0);
69669             var updated = ts.visitEachChild(node, visitor, context);
69670             exitSubtree(ancestorFacts, 0, 0);
69671             return updated;
69672         }
69673         function returnCapturedThis(node) {
69674             return ts.setOriginalNode(ts.createReturn(ts.createFileLevelUniqueName("_this")), node);
69675         }
69676         function visitReturnStatement(node) {
69677             if (convertedLoopState) {
69678                 convertedLoopState.nonLocalJumps |= 8;
69679                 if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) {
69680                     node = returnCapturedThis(node);
69681                 }
69682                 return ts.createReturn(ts.createObjectLiteral([
69683                     ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression
69684                         ? ts.visitNode(node.expression, visitor, ts.isExpression)
69685                         : ts.createVoidZero())
69686                 ]));
69687             }
69688             else if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) {
69689                 return returnCapturedThis(node);
69690             }
69691             return ts.visitEachChild(node, visitor, context);
69692         }
69693         function visitThisKeyword(node) {
69694             if (hierarchyFacts & 2) {
69695                 hierarchyFacts |= 32768;
69696             }
69697             if (convertedLoopState) {
69698                 if (hierarchyFacts & 2) {
69699                     convertedLoopState.containsLexicalThis = true;
69700                     return node;
69701                 }
69702                 return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this"));
69703             }
69704             return node;
69705         }
69706         function visitIdentifier(node) {
69707             if (!convertedLoopState) {
69708                 return node;
69709             }
69710             if (ts.isGeneratedIdentifier(node)) {
69711                 return node;
69712             }
69713             if (node.escapedText !== "arguments" || !resolver.isArgumentsLocalBinding(node)) {
69714                 return node;
69715             }
69716             return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments"));
69717         }
69718         function visitBreakOrContinueStatement(node) {
69719             if (convertedLoopState) {
69720                 var jump = node.kind === 234 ? 2 : 4;
69721                 var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) ||
69722                     (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump));
69723                 if (!canUseBreakOrContinue) {
69724                     var labelMarker = void 0;
69725                     var label = node.label;
69726                     if (!label) {
69727                         if (node.kind === 234) {
69728                             convertedLoopState.nonLocalJumps |= 2;
69729                             labelMarker = "break";
69730                         }
69731                         else {
69732                             convertedLoopState.nonLocalJumps |= 4;
69733                             labelMarker = "continue";
69734                         }
69735                     }
69736                     else {
69737                         if (node.kind === 234) {
69738                             labelMarker = "break-" + label.escapedText;
69739                             setLabeledJump(convertedLoopState, true, ts.idText(label), labelMarker);
69740                         }
69741                         else {
69742                             labelMarker = "continue-" + label.escapedText;
69743                             setLabeledJump(convertedLoopState, false, ts.idText(label), labelMarker);
69744                         }
69745                     }
69746                     var returnExpression = ts.createLiteral(labelMarker);
69747                     if (convertedLoopState.loopOutParameters.length) {
69748                         var outParams = convertedLoopState.loopOutParameters;
69749                         var expr = void 0;
69750                         for (var i = 0; i < outParams.length; i++) {
69751                             var copyExpr = copyOutParameter(outParams[i], 1);
69752                             if (i === 0) {
69753                                 expr = copyExpr;
69754                             }
69755                             else {
69756                                 expr = ts.createBinary(expr, 27, copyExpr);
69757                             }
69758                         }
69759                         returnExpression = ts.createBinary(expr, 27, returnExpression);
69760                     }
69761                     return ts.createReturn(returnExpression);
69762                 }
69763             }
69764             return ts.visitEachChild(node, visitor, context);
69765         }
69766         function visitClassDeclaration(node) {
69767             var variable = ts.createVariableDeclaration(ts.getLocalName(node, true), undefined, transformClassLikeDeclarationToExpression(node));
69768             ts.setOriginalNode(variable, node);
69769             var statements = [];
69770             var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([variable]));
69771             ts.setOriginalNode(statement, node);
69772             ts.setTextRange(statement, node);
69773             ts.startOnNewLine(statement);
69774             statements.push(statement);
69775             if (ts.hasModifier(node, 1)) {
69776                 var exportStatement = ts.hasModifier(node, 512)
69777                     ? ts.createExportDefault(ts.getLocalName(node))
69778                     : ts.createExternalModuleExport(ts.getLocalName(node));
69779                 ts.setOriginalNode(exportStatement, statement);
69780                 statements.push(exportStatement);
69781             }
69782             var emitFlags = ts.getEmitFlags(node);
69783             if ((emitFlags & 4194304) === 0) {
69784                 statements.push(ts.createEndOfDeclarationMarker(node));
69785                 ts.setEmitFlags(statement, emitFlags | 4194304);
69786             }
69787             return ts.singleOrMany(statements);
69788         }
69789         function visitClassExpression(node) {
69790             return transformClassLikeDeclarationToExpression(node);
69791         }
69792         function transformClassLikeDeclarationToExpression(node) {
69793             if (node.name) {
69794                 enableSubstitutionsForBlockScopedBindings();
69795             }
69796             var extendsClauseElement = ts.getClassExtendsHeritageElement(node);
69797             var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter(undefined, undefined, undefined, ts.createFileLevelUniqueName("_super"))] : [], undefined, transformClassBody(node, extendsClauseElement));
69798             ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536) | 524288);
69799             var inner = ts.createPartiallyEmittedExpression(classFunction);
69800             inner.end = node.end;
69801             ts.setEmitFlags(inner, 1536);
69802             var outer = ts.createPartiallyEmittedExpression(inner);
69803             outer.end = ts.skipTrivia(currentText, node.pos);
69804             ts.setEmitFlags(outer, 1536);
69805             var result = ts.createParen(ts.createCall(outer, undefined, extendsClauseElement
69806                 ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)]
69807                 : []));
69808             ts.addSyntheticLeadingComment(result, 3, "* @class ");
69809             return result;
69810         }
69811         function transformClassBody(node, extendsClauseElement) {
69812             var statements = [];
69813             startLexicalEnvironment();
69814             addExtendsHelperIfNeeded(statements, node, extendsClauseElement);
69815             addConstructor(statements, node, extendsClauseElement);
69816             addClassMembers(statements, node);
69817             var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19);
69818             var localName = ts.getInternalName(node);
69819             var outer = ts.createPartiallyEmittedExpression(localName);
69820             outer.end = closingBraceLocation.end;
69821             ts.setEmitFlags(outer, 1536);
69822             var statement = ts.createReturn(outer);
69823             statement.pos = closingBraceLocation.pos;
69824             ts.setEmitFlags(statement, 1536 | 384);
69825             statements.push(statement);
69826             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
69827             var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true);
69828             ts.setEmitFlags(block, 1536);
69829             return block;
69830         }
69831         function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) {
69832             if (extendsClauseElement) {
69833                 statements.push(ts.setTextRange(ts.createExpressionStatement(createExtendsHelper(context, ts.getInternalName(node))), extendsClauseElement));
69834             }
69835         }
69836         function addConstructor(statements, node, extendsClauseElement) {
69837             var savedConvertedLoopState = convertedLoopState;
69838             convertedLoopState = undefined;
69839             var ancestorFacts = enterSubtree(16278, 73);
69840             var constructor = ts.getFirstConstructorWithBody(node);
69841             var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined);
69842             var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getInternalName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper));
69843             ts.setTextRange(constructorFunction, constructor || node);
69844             if (extendsClauseElement) {
69845                 ts.setEmitFlags(constructorFunction, 8);
69846             }
69847             statements.push(constructorFunction);
69848             exitSubtree(ancestorFacts, 49152, 0);
69849             convertedLoopState = savedConvertedLoopState;
69850         }
69851         function transformConstructorParameters(constructor, hasSynthesizedSuper) {
69852             return ts.visitParameterList(constructor && !hasSynthesizedSuper ? constructor.parameters : undefined, visitor, context)
69853                 || [];
69854         }
69855         function createDefaultConstructorBody(node, isDerivedClass) {
69856             var statements = [];
69857             resumeLexicalEnvironment();
69858             ts.mergeLexicalEnvironment(statements, endLexicalEnvironment());
69859             if (isDerivedClass) {
69860                 statements.push(ts.createReturn(createDefaultSuperCallOrThis()));
69861             }
69862             var statementsArray = ts.createNodeArray(statements);
69863             ts.setTextRange(statementsArray, node.members);
69864             var block = ts.createBlock(statementsArray, true);
69865             ts.setTextRange(block, node);
69866             ts.setEmitFlags(block, 1536);
69867             return block;
69868         }
69869         function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) {
69870             var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 100;
69871             if (!constructor)
69872                 return createDefaultConstructorBody(node, isDerivedClass);
69873             var prologue = [];
69874             var statements = [];
69875             resumeLexicalEnvironment();
69876             var statementOffset = 0;
69877             if (!hasSynthesizedSuper)
69878                 statementOffset = ts.addStandardPrologue(prologue, constructor.body.statements, false);
69879             addDefaultValueAssignmentsIfNeeded(statements, constructor);
69880             addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper);
69881             if (!hasSynthesizedSuper)
69882                 statementOffset = ts.addCustomPrologue(statements, constructor.body.statements, statementOffset, visitor);
69883             var superCallExpression;
69884             if (hasSynthesizedSuper) {
69885                 superCallExpression = createDefaultSuperCallOrThis();
69886             }
69887             else if (isDerivedClass && statementOffset < constructor.body.statements.length) {
69888                 var firstStatement = constructor.body.statements[statementOffset];
69889                 if (ts.isExpressionStatement(firstStatement) && ts.isSuperCall(firstStatement.expression)) {
69890                     superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression);
69891                 }
69892             }
69893             if (superCallExpression) {
69894                 hierarchyFacts |= 8192;
69895                 statementOffset++;
69896             }
69897             ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset));
69898             ts.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
69899             insertCaptureNewTargetIfNeeded(prologue, constructor, false);
69900             if (isDerivedClass) {
69901                 if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 4096)) {
69902                     var superCall = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression);
69903                     var returnStatement = ts.createReturn(superCallExpression);
69904                     ts.setCommentRange(returnStatement, ts.getCommentRange(superCall));
69905                     ts.setEmitFlags(superCall, 1536);
69906                     statements.push(returnStatement);
69907                 }
69908                 else {
69909                     insertCaptureThisForNode(statements, constructor, superCallExpression || createActualThis());
69910                     if (!isSufficientlyCoveredByReturnStatements(constructor.body)) {
69911                         statements.push(ts.createReturn(ts.createFileLevelUniqueName("_this")));
69912                     }
69913                 }
69914             }
69915             else {
69916                 insertCaptureThisForNodeIfNeeded(prologue, constructor);
69917             }
69918             var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(ts.concatenate(prologue, statements)), constructor.body.statements), true);
69919             ts.setTextRange(block, constructor.body);
69920             return block;
69921         }
69922         function isSufficientlyCoveredByReturnStatements(statement) {
69923             if (statement.kind === 235) {
69924                 return true;
69925             }
69926             else if (statement.kind === 227) {
69927                 var ifStatement = statement;
69928                 if (ifStatement.elseStatement) {
69929                     return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) &&
69930                         isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement);
69931                 }
69932             }
69933             else if (statement.kind === 223) {
69934                 var lastStatement = ts.lastOrUndefined(statement.statements);
69935                 if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) {
69936                     return true;
69937                 }
69938             }
69939             return false;
69940         }
69941         function createActualThis() {
69942             return ts.setEmitFlags(ts.createThis(), 4);
69943         }
69944         function createDefaultSuperCallOrThis() {
69945             return ts.createLogicalOr(ts.createLogicalAnd(ts.createStrictInequality(ts.createFileLevelUniqueName("_super"), ts.createNull()), ts.createFunctionApply(ts.createFileLevelUniqueName("_super"), createActualThis(), ts.createIdentifier("arguments"))), createActualThis());
69946         }
69947         function visitParameter(node) {
69948             if (node.dotDotDotToken) {
69949                 return undefined;
69950             }
69951             else if (ts.isBindingPattern(node.name)) {
69952                 return ts.setOriginalNode(ts.setTextRange(ts.createParameter(undefined, undefined, undefined, ts.getGeneratedNameForNode(node), undefined, undefined, undefined), node), node);
69953             }
69954             else if (node.initializer) {
69955                 return ts.setOriginalNode(ts.setTextRange(ts.createParameter(undefined, undefined, undefined, node.name, undefined, undefined, undefined), node), node);
69956             }
69957             else {
69958                 return node;
69959             }
69960         }
69961         function hasDefaultValueOrBindingPattern(node) {
69962             return node.initializer !== undefined
69963                 || ts.isBindingPattern(node.name);
69964         }
69965         function addDefaultValueAssignmentsIfNeeded(statements, node) {
69966             if (!ts.some(node.parameters, hasDefaultValueOrBindingPattern)) {
69967                 return false;
69968             }
69969             var added = false;
69970             for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
69971                 var parameter = _a[_i];
69972                 var name = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken;
69973                 if (dotDotDotToken) {
69974                     continue;
69975                 }
69976                 if (ts.isBindingPattern(name)) {
69977                     added = insertDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) || added;
69978                 }
69979                 else if (initializer) {
69980                     insertDefaultValueAssignmentForInitializer(statements, parameter, name, initializer);
69981                     added = true;
69982                 }
69983             }
69984             return added;
69985         }
69986         function insertDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) {
69987             if (name.elements.length > 0) {
69988                 ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, ts.getGeneratedNameForNode(parameter)))), 1048576));
69989                 return true;
69990             }
69991             else if (initializer) {
69992                 ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(ts.createExpressionStatement(ts.createAssignment(ts.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576));
69993                 return true;
69994             }
69995             return false;
69996         }
69997         function insertDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) {
69998             initializer = ts.visitNode(initializer, visitor, ts.isExpression);
69999             var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([
70000                 ts.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer) | 1536)), parameter), 1536))
70001             ]), parameter), 1 | 32 | 384 | 1536));
70002             ts.startOnNewLine(statement);
70003             ts.setTextRange(statement, parameter);
70004             ts.setEmitFlags(statement, 384 | 32 | 1048576 | 1536);
70005             ts.insertStatementAfterCustomPrologue(statements, statement);
70006         }
70007         function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) {
70008             return !!(node && node.dotDotDotToken && !inConstructorWithSynthesizedSuper);
70009         }
70010         function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) {
70011             var prologueStatements = [];
70012             var parameter = ts.lastOrUndefined(node.parameters);
70013             if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) {
70014                 return false;
70015             }
70016             var declarationName = parameter.name.kind === 75 ? ts.getMutableClone(parameter.name) : ts.createTempVariable(undefined);
70017             ts.setEmitFlags(declarationName, 48);
70018             var expressionName = parameter.name.kind === 75 ? ts.getSynthesizedClone(parameter.name) : declarationName;
70019             var restIndex = node.parameters.length - 1;
70020             var temp = ts.createLoopVariable();
70021             prologueStatements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
70022                 ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([]))
70023             ])), parameter), 1048576));
70024             var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([
70025                 ts.createVariableDeclaration(temp, undefined, ts.createLiteral(restIndex))
70026             ]), parameter), ts.setTextRange(ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(ts.createPostfixIncrement(temp), parameter), ts.createBlock([
70027                 ts.startOnNewLine(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0
70028                     ? temp
70029                     : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), parameter))
70030             ]));
70031             ts.setEmitFlags(forStatement, 1048576);
70032             ts.startOnNewLine(forStatement);
70033             prologueStatements.push(forStatement);
70034             if (parameter.name.kind !== 75) {
70035                 prologueStatements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, expressionName))), parameter), 1048576));
70036             }
70037             ts.insertStatementsAfterCustomPrologue(statements, prologueStatements);
70038             return true;
70039         }
70040         function insertCaptureThisForNodeIfNeeded(statements, node) {
70041             if (hierarchyFacts & 32768 && node.kind !== 202) {
70042                 insertCaptureThisForNode(statements, node, ts.createThis());
70043                 return true;
70044             }
70045             return false;
70046         }
70047         function insertCaptureThisForNode(statements, node, initializer) {
70048             enableSubstitutionsForCapturedThis();
70049             var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
70050                 ts.createVariableDeclaration(ts.createFileLevelUniqueName("_this"), undefined, initializer)
70051             ]));
70052             ts.setEmitFlags(captureThisStatement, 1536 | 1048576);
70053             ts.setSourceMapRange(captureThisStatement, node);
70054             ts.insertStatementAfterCustomPrologue(statements, captureThisStatement);
70055         }
70056         function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) {
70057             if (hierarchyFacts & 16384) {
70058                 var newTarget = void 0;
70059                 switch (node.kind) {
70060                     case 202:
70061                         return statements;
70062                     case 161:
70063                     case 163:
70064                     case 164:
70065                         newTarget = ts.createVoidZero();
70066                         break;
70067                     case 162:
70068                         newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor");
70069                         break;
70070                     case 244:
70071                     case 201:
70072                         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());
70073                         break;
70074                     default:
70075                         return ts.Debug.failBadSyntaxKind(node);
70076                 }
70077                 var captureNewTargetStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
70078                     ts.createVariableDeclaration(ts.createFileLevelUniqueName("_newTarget"), undefined, newTarget)
70079                 ]));
70080                 ts.setEmitFlags(captureNewTargetStatement, 1536 | 1048576);
70081                 if (copyOnWrite) {
70082                     statements = statements.slice();
70083                 }
70084                 ts.insertStatementAfterCustomPrologue(statements, captureNewTargetStatement);
70085             }
70086             return statements;
70087         }
70088         function addClassMembers(statements, node) {
70089             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
70090                 var member = _a[_i];
70091                 switch (member.kind) {
70092                     case 222:
70093                         statements.push(transformSemicolonClassElementToStatement(member));
70094                         break;
70095                     case 161:
70096                         statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node));
70097                         break;
70098                     case 163:
70099                     case 164:
70100                         var accessors = ts.getAllAccessorDeclarations(node.members, member);
70101                         if (member === accessors.firstAccessor) {
70102                             statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node));
70103                         }
70104                         break;
70105                     case 162:
70106                         break;
70107                     default:
70108                         ts.Debug.failBadSyntaxKind(member, currentSourceFile && currentSourceFile.fileName);
70109                         break;
70110                 }
70111             }
70112         }
70113         function transformSemicolonClassElementToStatement(member) {
70114             return ts.setTextRange(ts.createEmptyStatement(), member);
70115         }
70116         function transformClassMethodDeclarationToStatement(receiver, member, container) {
70117             var commentRange = ts.getCommentRange(member);
70118             var sourceMapRange = ts.getSourceMapRange(member);
70119             var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container);
70120             var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName);
70121             var e;
70122             if (!ts.isPrivateIdentifier(propertyName) && context.getCompilerOptions().useDefineForClassFields) {
70123                 var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression
70124                     : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText))
70125                         : propertyName;
70126                 e = ts.createObjectDefinePropertyCall(receiver, name, ts.createPropertyDescriptor({ value: memberFunction, enumerable: false, writable: true, configurable: true }));
70127             }
70128             else {
70129                 var memberName = ts.createMemberAccessForPropertyName(receiver, propertyName, member.name);
70130                 e = ts.createAssignment(memberName, memberFunction);
70131             }
70132             ts.setEmitFlags(memberFunction, 1536);
70133             ts.setSourceMapRange(memberFunction, sourceMapRange);
70134             var statement = ts.setTextRange(ts.createExpressionStatement(e), member);
70135             ts.setOriginalNode(statement, member);
70136             ts.setCommentRange(statement, commentRange);
70137             ts.setEmitFlags(statement, 48);
70138             return statement;
70139         }
70140         function transformAccessorsToStatement(receiver, accessors, container) {
70141             var statement = ts.createExpressionStatement(transformAccessorsToExpression(receiver, accessors, container, false));
70142             ts.setEmitFlags(statement, 1536);
70143             ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor));
70144             return statement;
70145         }
70146         function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) {
70147             var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
70148             var target = ts.getMutableClone(receiver);
70149             ts.setEmitFlags(target, 1536 | 32);
70150             ts.setSourceMapRange(target, firstAccessor.name);
70151             var visitedAccessorName = ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName);
70152             if (ts.isPrivateIdentifier(visitedAccessorName)) {
70153                 return ts.Debug.failBadSyntaxKind(visitedAccessorName, "Encountered unhandled private identifier while transforming ES2015.");
70154             }
70155             var propertyName = ts.createExpressionForPropertyName(visitedAccessorName);
70156             ts.setEmitFlags(propertyName, 1536 | 16);
70157             ts.setSourceMapRange(propertyName, firstAccessor.name);
70158             var properties = [];
70159             if (getAccessor) {
70160                 var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined, container);
70161                 ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor));
70162                 ts.setEmitFlags(getterFunction, 512);
70163                 var getter = ts.createPropertyAssignment("get", getterFunction);
70164                 ts.setCommentRange(getter, ts.getCommentRange(getAccessor));
70165                 properties.push(getter);
70166             }
70167             if (setAccessor) {
70168                 var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined, container);
70169                 ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor));
70170                 ts.setEmitFlags(setterFunction, 512);
70171                 var setter = ts.createPropertyAssignment("set", setterFunction);
70172                 ts.setCommentRange(setter, ts.getCommentRange(setAccessor));
70173                 properties.push(setter);
70174             }
70175             properties.push(ts.createPropertyAssignment("enumerable", getAccessor || setAccessor ? ts.createFalse() : ts.createTrue()), ts.createPropertyAssignment("configurable", ts.createTrue()));
70176             var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [
70177                 target,
70178                 propertyName,
70179                 ts.createObjectLiteral(properties, true)
70180             ]);
70181             if (startsOnNewLine) {
70182                 ts.startOnNewLine(call);
70183             }
70184             return call;
70185         }
70186         function visitArrowFunction(node) {
70187             if (node.transformFlags & 4096) {
70188                 hierarchyFacts |= 32768;
70189             }
70190             var savedConvertedLoopState = convertedLoopState;
70191             convertedLoopState = undefined;
70192             var ancestorFacts = enterSubtree(15232, 66);
70193             var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node));
70194             ts.setTextRange(func, node);
70195             ts.setOriginalNode(func, node);
70196             ts.setEmitFlags(func, 8);
70197             if (hierarchyFacts & 32768) {
70198                 enableSubstitutionsForCapturedThis();
70199             }
70200             exitSubtree(ancestorFacts, 0, 0);
70201             convertedLoopState = savedConvertedLoopState;
70202             return func;
70203         }
70204         function visitFunctionExpression(node) {
70205             var ancestorFacts = ts.getEmitFlags(node) & 262144
70206                 ? enterSubtree(16278, 69)
70207                 : enterSubtree(16286, 65);
70208             var savedConvertedLoopState = convertedLoopState;
70209             convertedLoopState = undefined;
70210             var parameters = ts.visitParameterList(node.parameters, visitor, context);
70211             var body = transformFunctionBody(node);
70212             var name = hierarchyFacts & 16384
70213                 ? ts.getLocalName(node)
70214                 : node.name;
70215             exitSubtree(ancestorFacts, 49152, 0);
70216             convertedLoopState = savedConvertedLoopState;
70217             return ts.updateFunctionExpression(node, undefined, node.asteriskToken, name, undefined, parameters, undefined, body);
70218         }
70219         function visitFunctionDeclaration(node) {
70220             var savedConvertedLoopState = convertedLoopState;
70221             convertedLoopState = undefined;
70222             var ancestorFacts = enterSubtree(16286, 65);
70223             var parameters = ts.visitParameterList(node.parameters, visitor, context);
70224             var body = transformFunctionBody(node);
70225             var name = hierarchyFacts & 16384
70226                 ? ts.getLocalName(node)
70227                 : node.name;
70228             exitSubtree(ancestorFacts, 49152, 0);
70229             convertedLoopState = savedConvertedLoopState;
70230             return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, undefined, parameters, undefined, body);
70231         }
70232         function transformFunctionLikeToExpression(node, location, name, container) {
70233             var savedConvertedLoopState = convertedLoopState;
70234             convertedLoopState = undefined;
70235             var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32)
70236                 ? enterSubtree(16286, 65 | 8)
70237                 : enterSubtree(16286, 65);
70238             var parameters = ts.visitParameterList(node.parameters, visitor, context);
70239             var body = transformFunctionBody(node);
70240             if (hierarchyFacts & 16384 && !name && (node.kind === 244 || node.kind === 201)) {
70241                 name = ts.getGeneratedNameForNode(node);
70242             }
70243             exitSubtree(ancestorFacts, 49152, 0);
70244             convertedLoopState = savedConvertedLoopState;
70245             return ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, parameters, undefined, body), location), node);
70246         }
70247         function transformFunctionBody(node) {
70248             var multiLine = false;
70249             var singleLine = false;
70250             var statementsLocation;
70251             var closeBraceLocation;
70252             var prologue = [];
70253             var statements = [];
70254             var body = node.body;
70255             var statementOffset;
70256             resumeLexicalEnvironment();
70257             if (ts.isBlock(body)) {
70258                 statementOffset = ts.addStandardPrologue(prologue, body.statements, false);
70259                 statementOffset = ts.addCustomPrologue(statements, body.statements, statementOffset, visitor, ts.isHoistedFunction);
70260                 statementOffset = ts.addCustomPrologue(statements, body.statements, statementOffset, visitor, ts.isHoistedVariableStatement);
70261             }
70262             multiLine = addDefaultValueAssignmentsIfNeeded(statements, node) || multiLine;
70263             multiLine = addRestParameterIfNeeded(statements, node, false) || multiLine;
70264             if (ts.isBlock(body)) {
70265                 statementOffset = ts.addCustomPrologue(statements, body.statements, statementOffset, visitor);
70266                 statementsLocation = body.statements;
70267                 ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset));
70268                 if (!multiLine && body.multiLine) {
70269                     multiLine = true;
70270                 }
70271             }
70272             else {
70273                 ts.Debug.assert(node.kind === 202);
70274                 statementsLocation = ts.moveRangeEnd(body, -1);
70275                 var equalsGreaterThanToken = node.equalsGreaterThanToken;
70276                 if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) {
70277                     if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) {
70278                         singleLine = true;
70279                     }
70280                     else {
70281                         multiLine = true;
70282                     }
70283                 }
70284                 var expression = ts.visitNode(body, visitor, ts.isExpression);
70285                 var returnStatement = ts.createReturn(expression);
70286                 ts.setTextRange(returnStatement, body);
70287                 ts.moveSyntheticComments(returnStatement, body);
70288                 ts.setEmitFlags(returnStatement, 384 | 32 | 1024);
70289                 statements.push(returnStatement);
70290                 closeBraceLocation = body;
70291             }
70292             ts.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
70293             insertCaptureNewTargetIfNeeded(prologue, node, false);
70294             insertCaptureThisForNodeIfNeeded(prologue, node);
70295             if (ts.some(prologue)) {
70296                 multiLine = true;
70297             }
70298             statements.unshift.apply(statements, prologue);
70299             if (ts.isBlock(body) && ts.arrayIsEqualTo(statements, body.statements)) {
70300                 return body;
70301             }
70302             var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), multiLine);
70303             ts.setTextRange(block, node.body);
70304             if (!multiLine && singleLine) {
70305                 ts.setEmitFlags(block, 1);
70306             }
70307             if (closeBraceLocation) {
70308                 ts.setTokenSourceMapRange(block, 19, closeBraceLocation);
70309             }
70310             ts.setOriginalNode(block, node.body);
70311             return block;
70312         }
70313         function visitBlock(node, isFunctionBody) {
70314             if (isFunctionBody) {
70315                 return ts.visitEachChild(node, visitor, context);
70316             }
70317             var ancestorFacts = hierarchyFacts & 256
70318                 ? enterSubtree(7104, 512)
70319                 : enterSubtree(6976, 128);
70320             var updated = ts.visitEachChild(node, visitor, context);
70321             exitSubtree(ancestorFacts, 0, 0);
70322             return updated;
70323         }
70324         function visitExpressionStatement(node) {
70325             switch (node.expression.kind) {
70326                 case 200:
70327                     return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, false));
70328                 case 209:
70329                     return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, false));
70330             }
70331             return ts.visitEachChild(node, visitor, context);
70332         }
70333         function visitParenthesizedExpression(node, needsDestructuringValue) {
70334             if (!needsDestructuringValue) {
70335                 switch (node.expression.kind) {
70336                     case 200:
70337                         return ts.updateParen(node, visitParenthesizedExpression(node.expression, false));
70338                     case 209:
70339                         return ts.updateParen(node, visitBinaryExpression(node.expression, false));
70340                 }
70341             }
70342             return ts.visitEachChild(node, visitor, context);
70343         }
70344         function visitBinaryExpression(node, needsDestructuringValue) {
70345             if (ts.isDestructuringAssignment(node)) {
70346                 return ts.flattenDestructuringAssignment(node, visitor, context, 0, needsDestructuringValue);
70347             }
70348             return ts.visitEachChild(node, visitor, context);
70349         }
70350         function isVariableStatementOfTypeScriptClassWrapper(node) {
70351             return node.declarationList.declarations.length === 1
70352                 && !!node.declarationList.declarations[0].initializer
70353                 && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432);
70354         }
70355         function visitVariableStatement(node) {
70356             var ancestorFacts = enterSubtree(0, ts.hasModifier(node, 1) ? 32 : 0);
70357             var updated;
70358             if (convertedLoopState && (node.declarationList.flags & 3) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) {
70359                 var assignments = void 0;
70360                 for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
70361                     var decl = _a[_i];
70362                     hoistVariableDeclarationDeclaredInConvertedLoop(convertedLoopState, decl);
70363                     if (decl.initializer) {
70364                         var assignment = void 0;
70365                         if (ts.isBindingPattern(decl.name)) {
70366                             assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0);
70367                         }
70368                         else {
70369                             assignment = ts.createBinary(decl.name, 62, ts.visitNode(decl.initializer, visitor, ts.isExpression));
70370                             ts.setTextRange(assignment, decl);
70371                         }
70372                         assignments = ts.append(assignments, assignment);
70373                     }
70374                 }
70375                 if (assignments) {
70376                     updated = ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(assignments)), node);
70377                 }
70378                 else {
70379                     updated = undefined;
70380                 }
70381             }
70382             else {
70383                 updated = ts.visitEachChild(node, visitor, context);
70384             }
70385             exitSubtree(ancestorFacts, 0, 0);
70386             return updated;
70387         }
70388         function visitVariableDeclarationList(node) {
70389             if (node.flags & 3 || node.transformFlags & 131072) {
70390                 if (node.flags & 3) {
70391                     enableSubstitutionsForBlockScopedBindings();
70392                 }
70393                 var declarations = ts.flatMap(node.declarations, node.flags & 1
70394                     ? visitVariableDeclarationInLetDeclarationList
70395                     : visitVariableDeclaration);
70396                 var declarationList = ts.createVariableDeclarationList(declarations);
70397                 ts.setOriginalNode(declarationList, node);
70398                 ts.setTextRange(declarationList, node);
70399                 ts.setCommentRange(declarationList, node);
70400                 if (node.transformFlags & 131072
70401                     && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) {
70402                     ts.setSourceMapRange(declarationList, getRangeUnion(declarations));
70403                 }
70404                 return declarationList;
70405             }
70406             return ts.visitEachChild(node, visitor, context);
70407         }
70408         function getRangeUnion(declarations) {
70409             var pos = -1, end = -1;
70410             for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) {
70411                 var node = declarations_10[_i];
70412                 pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos);
70413                 end = Math.max(end, node.end);
70414             }
70415             return ts.createRange(pos, end);
70416         }
70417         function shouldEmitExplicitInitializerForLetDeclaration(node) {
70418             var flags = resolver.getNodeCheckFlags(node);
70419             var isCapturedInFunction = flags & 262144;
70420             var isDeclaredInLoop = flags & 524288;
70421             var emittedAsTopLevel = (hierarchyFacts & 64) !== 0
70422                 || (isCapturedInFunction
70423                     && isDeclaredInLoop
70424                     && (hierarchyFacts & 512) !== 0);
70425             var emitExplicitInitializer = !emittedAsTopLevel
70426                 && (hierarchyFacts & 4096) === 0
70427                 && (!resolver.isDeclarationWithCollidingName(node)
70428                     || (isDeclaredInLoop
70429                         && !isCapturedInFunction
70430                         && (hierarchyFacts & (2048 | 4096)) === 0));
70431             return emitExplicitInitializer;
70432         }
70433         function visitVariableDeclarationInLetDeclarationList(node) {
70434             var name = node.name;
70435             if (ts.isBindingPattern(name)) {
70436                 return visitVariableDeclaration(node);
70437             }
70438             if (!node.initializer && shouldEmitExplicitInitializerForLetDeclaration(node)) {
70439                 var clone_3 = ts.getMutableClone(node);
70440                 clone_3.initializer = ts.createVoidZero();
70441                 return clone_3;
70442             }
70443             return ts.visitEachChild(node, visitor, context);
70444         }
70445         function visitVariableDeclaration(node) {
70446             var ancestorFacts = enterSubtree(32, 0);
70447             var updated;
70448             if (ts.isBindingPattern(node.name)) {
70449                 updated = ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, (ancestorFacts & 32) !== 0);
70450             }
70451             else {
70452                 updated = ts.visitEachChild(node, visitor, context);
70453             }
70454             exitSubtree(ancestorFacts, 0, 0);
70455             return updated;
70456         }
70457         function recordLabel(node) {
70458             convertedLoopState.labels.set(ts.idText(node.label), true);
70459         }
70460         function resetLabel(node) {
70461             convertedLoopState.labels.set(ts.idText(node.label), false);
70462         }
70463         function visitLabeledStatement(node) {
70464             if (convertedLoopState && !convertedLoopState.labels) {
70465                 convertedLoopState.labels = ts.createMap();
70466             }
70467             var statement = ts.unwrapInnermostStatementOfLabel(node, convertedLoopState && recordLabel);
70468             return ts.isIterationStatement(statement, false)
70469                 ? visitIterationStatement(statement, node)
70470                 : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, ts.liftToBlock), node, convertedLoopState && resetLabel);
70471         }
70472         function visitIterationStatement(node, outermostLabeledStatement) {
70473             switch (node.kind) {
70474                 case 228:
70475                 case 229:
70476                     return visitDoOrWhileStatement(node, outermostLabeledStatement);
70477                 case 230:
70478                     return visitForStatement(node, outermostLabeledStatement);
70479                 case 231:
70480                     return visitForInStatement(node, outermostLabeledStatement);
70481                 case 232:
70482                     return visitForOfStatement(node, outermostLabeledStatement);
70483             }
70484         }
70485         function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) {
70486             var ancestorFacts = enterSubtree(excludeFacts, includeFacts);
70487             var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert);
70488             exitSubtree(ancestorFacts, 0, 0);
70489             return updated;
70490         }
70491         function visitDoOrWhileStatement(node, outermostLabeledStatement) {
70492             return visitIterationStatementWithFacts(0, 1280, node, outermostLabeledStatement);
70493         }
70494         function visitForStatement(node, outermostLabeledStatement) {
70495             return visitIterationStatementWithFacts(5056, 3328, node, outermostLabeledStatement);
70496         }
70497         function visitForInStatement(node, outermostLabeledStatement) {
70498             return visitIterationStatementWithFacts(3008, 5376, node, outermostLabeledStatement);
70499         }
70500         function visitForOfStatement(node, outermostLabeledStatement) {
70501             return visitIterationStatementWithFacts(3008, 5376, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray);
70502         }
70503         function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) {
70504             var statements = [];
70505             var initializer = node.initializer;
70506             if (ts.isVariableDeclarationList(initializer)) {
70507                 if (node.initializer.flags & 3) {
70508                     enableSubstitutionsForBlockScopedBindings();
70509                 }
70510                 var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations);
70511                 if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) {
70512                     var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0, boundValue);
70513                     var declarationList = ts.setTextRange(ts.createVariableDeclarationList(declarations), node.initializer);
70514                     ts.setOriginalNode(declarationList, node.initializer);
70515                     ts.setSourceMapRange(declarationList, ts.createRange(declarations[0].pos, ts.last(declarations).end));
70516                     statements.push(ts.createVariableStatement(undefined, declarationList));
70517                 }
70518                 else {
70519                     statements.push(ts.setTextRange(ts.createVariableStatement(undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([
70520                         ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, boundValue)
70521                     ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1)));
70522                 }
70523             }
70524             else {
70525                 var assignment = ts.createAssignment(initializer, boundValue);
70526                 if (ts.isDestructuringAssignment(assignment)) {
70527                     ts.aggregateTransformFlags(assignment);
70528                     statements.push(ts.createExpressionStatement(visitBinaryExpression(assignment, false)));
70529                 }
70530                 else {
70531                     assignment.end = initializer.end;
70532                     statements.push(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1)));
70533                 }
70534             }
70535             if (convertedLoopBodyStatements) {
70536                 return createSyntheticBlockForConvertedStatements(ts.addRange(statements, convertedLoopBodyStatements));
70537             }
70538             else {
70539                 var statement = ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock);
70540                 if (ts.isBlock(statement)) {
70541                     return ts.updateBlock(statement, ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, statement.statements)), statement.statements));
70542                 }
70543                 else {
70544                     statements.push(statement);
70545                     return createSyntheticBlockForConvertedStatements(statements);
70546                 }
70547             }
70548         }
70549         function createSyntheticBlockForConvertedStatements(statements) {
70550             return ts.setEmitFlags(ts.createBlock(ts.createNodeArray(statements), true), 48 | 384);
70551         }
70552         function convertForOfStatementForArray(node, outermostLabeledStatement, convertedLoopBodyStatements) {
70553             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
70554             var counter = ts.createLoopVariable();
70555             var rhsReference = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(undefined);
70556             ts.setEmitFlags(expression, 48 | ts.getEmitFlags(expression));
70557             var forStatement = ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([
70558                 ts.setTextRange(ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0)), ts.moveRangePos(node.expression, -1)),
70559                 ts.setTextRange(ts.createVariableDeclaration(rhsReference, undefined, expression), node.expression)
70560             ]), 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);
70561             ts.setEmitFlags(forStatement, 256);
70562             ts.setTextRange(forStatement, node);
70563             return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel);
70564         }
70565         function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements, ancestorFacts) {
70566             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
70567             var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(undefined);
70568             var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(undefined);
70569             var errorRecord = ts.createUniqueName("e");
70570             var catchVariable = ts.getGeneratedNameForNode(errorRecord);
70571             var returnMethod = ts.createTempVariable(undefined);
70572             var values = ts.createValuesHelper(context, expression, node.expression);
70573             var next = ts.createCall(ts.createPropertyAccess(iterator, "next"), undefined, []);
70574             hoistVariableDeclaration(errorRecord);
70575             hoistVariableDeclaration(returnMethod);
70576             var initializer = ancestorFacts & 1024
70577                 ? ts.inlineExpressions([ts.createAssignment(errorRecord, ts.createVoidZero()), values])
70578                 : values;
70579             var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([
70580                 ts.setTextRange(ts.createVariableDeclaration(iterator, undefined, initializer), node.expression),
70581                 ts.createVariableDeclaration(result, undefined, next)
70582             ]), node.expression), 2097152), ts.createLogicalNot(ts.createPropertyAccess(result, "done")), ts.createAssignment(result, next), convertForOfStatementHead(node, ts.createPropertyAccess(result, "value"), convertedLoopBodyStatements)), node), 256);
70583             return ts.createTry(ts.createBlock([
70584                 ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel)
70585             ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([
70586                 ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([
70587                     ts.createPropertyAssignment("error", catchVariable)
70588                 ])))
70589             ]), 1)), ts.createBlock([
70590                 ts.createTry(ts.createBlock([
70591                     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),
70592                 ]), undefined, ts.setEmitFlags(ts.createBlock([
70593                     ts.setEmitFlags(ts.createIf(errorRecord, ts.createThrow(ts.createPropertyAccess(errorRecord, "error"))), 1)
70594                 ]), 1))
70595             ]));
70596         }
70597         function visitObjectLiteralExpression(node) {
70598             var properties = node.properties;
70599             var numProperties = properties.length;
70600             var numInitialProperties = numProperties;
70601             var numInitialPropertiesWithoutYield = numProperties;
70602             for (var i = 0; i < numProperties; i++) {
70603                 var property = properties[i];
70604                 if ((property.transformFlags & 262144 && hierarchyFacts & 4)
70605                     && i < numInitialPropertiesWithoutYield) {
70606                     numInitialPropertiesWithoutYield = i;
70607                 }
70608                 if (property.name.kind === 154) {
70609                     numInitialProperties = i;
70610                     break;
70611                 }
70612             }
70613             if (numInitialProperties !== numProperties) {
70614                 if (numInitialPropertiesWithoutYield < numInitialProperties) {
70615                     numInitialProperties = numInitialPropertiesWithoutYield;
70616                 }
70617                 var temp = ts.createTempVariable(hoistVariableDeclaration);
70618                 var expressions = [];
70619                 var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 65536));
70620                 if (node.multiLine) {
70621                     ts.startOnNewLine(assignment);
70622                 }
70623                 expressions.push(assignment);
70624                 addObjectLiteralMembers(expressions, node, temp, numInitialProperties);
70625                 expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp);
70626                 return ts.inlineExpressions(expressions);
70627             }
70628             return ts.visitEachChild(node, visitor, context);
70629         }
70630         function shouldConvertPartOfIterationStatement(node) {
70631             return (resolver.getNodeCheckFlags(node) & 131072) !== 0;
70632         }
70633         function shouldConvertInitializerOfForStatement(node) {
70634             return ts.isForStatement(node) && !!node.initializer && shouldConvertPartOfIterationStatement(node.initializer);
70635         }
70636         function shouldConvertConditionOfForStatement(node) {
70637             return ts.isForStatement(node) && !!node.condition && shouldConvertPartOfIterationStatement(node.condition);
70638         }
70639         function shouldConvertIncrementorOfForStatement(node) {
70640             return ts.isForStatement(node) && !!node.incrementor && shouldConvertPartOfIterationStatement(node.incrementor);
70641         }
70642         function shouldConvertIterationStatement(node) {
70643             return shouldConvertBodyOfIterationStatement(node)
70644                 || shouldConvertInitializerOfForStatement(node);
70645         }
70646         function shouldConvertBodyOfIterationStatement(node) {
70647             return (resolver.getNodeCheckFlags(node) & 65536) !== 0;
70648         }
70649         function hoistVariableDeclarationDeclaredInConvertedLoop(state, node) {
70650             if (!state.hoistedLocalVariables) {
70651                 state.hoistedLocalVariables = [];
70652             }
70653             visit(node.name);
70654             function visit(node) {
70655                 if (node.kind === 75) {
70656                     state.hoistedLocalVariables.push(node);
70657                 }
70658                 else {
70659                     for (var _i = 0, _a = node.elements; _i < _a.length; _i++) {
70660                         var element = _a[_i];
70661                         if (!ts.isOmittedExpression(element)) {
70662                             visit(element.name);
70663                         }
70664                     }
70665                 }
70666             }
70667         }
70668         function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert) {
70669             if (!shouldConvertIterationStatement(node)) {
70670                 var saveAllowedNonLabeledJumps = void 0;
70671                 if (convertedLoopState) {
70672                     saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps;
70673                     convertedLoopState.allowedNonLabeledJumps = 2 | 4;
70674                 }
70675                 var result = convert
70676                     ? convert(node, outermostLabeledStatement, undefined, ancestorFacts)
70677                     : ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel);
70678                 if (convertedLoopState) {
70679                     convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps;
70680                 }
70681                 return result;
70682             }
70683             var currentState = createConvertedLoopState(node);
70684             var statements = [];
70685             var outerConvertedLoopState = convertedLoopState;
70686             convertedLoopState = currentState;
70687             var initializerFunction = shouldConvertInitializerOfForStatement(node) ? createFunctionForInitializerOfForStatement(node, currentState) : undefined;
70688             var bodyFunction = shouldConvertBodyOfIterationStatement(node) ? createFunctionForBodyOfIterationStatement(node, currentState, outerConvertedLoopState) : undefined;
70689             convertedLoopState = outerConvertedLoopState;
70690             if (initializerFunction)
70691                 statements.push(initializerFunction.functionDeclaration);
70692             if (bodyFunction)
70693                 statements.push(bodyFunction.functionDeclaration);
70694             addExtraDeclarationsForConvertedLoop(statements, currentState, outerConvertedLoopState);
70695             if (initializerFunction) {
70696                 statements.push(generateCallToConvertedLoopInitializer(initializerFunction.functionName, initializerFunction.containsYield));
70697             }
70698             var loop;
70699             if (bodyFunction) {
70700                 if (convert) {
70701                     loop = convert(node, outermostLabeledStatement, bodyFunction.part, ancestorFacts);
70702                 }
70703                 else {
70704                     var clone_4 = convertIterationStatementCore(node, initializerFunction, ts.createBlock(bodyFunction.part, true));
70705                     ts.aggregateTransformFlags(clone_4);
70706                     loop = ts.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel);
70707                 }
70708             }
70709             else {
70710                 var clone_5 = convertIterationStatementCore(node, initializerFunction, ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
70711                 ts.aggregateTransformFlags(clone_5);
70712                 loop = ts.restoreEnclosingLabel(clone_5, outermostLabeledStatement, convertedLoopState && resetLabel);
70713             }
70714             statements.push(loop);
70715             return statements;
70716         }
70717         function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) {
70718             switch (node.kind) {
70719                 case 230: return convertForStatement(node, initializerFunction, convertedLoopBody);
70720                 case 231: return convertForInStatement(node, convertedLoopBody);
70721                 case 232: return convertForOfStatement(node, convertedLoopBody);
70722                 case 228: return convertDoStatement(node, convertedLoopBody);
70723                 case 229: return convertWhileStatement(node, convertedLoopBody);
70724                 default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected");
70725             }
70726         }
70727         function convertForStatement(node, initializerFunction, convertedLoopBody) {
70728             var shouldConvertCondition = node.condition && shouldConvertPartOfIterationStatement(node.condition);
70729             var shouldConvertIncrementor = shouldConvertCondition || node.incrementor && shouldConvertPartOfIterationStatement(node.incrementor);
70730             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);
70731         }
70732         function convertForOfStatement(node, convertedLoopBody) {
70733             return ts.updateForOf(node, undefined, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), convertedLoopBody);
70734         }
70735         function convertForInStatement(node, convertedLoopBody) {
70736             return ts.updateForIn(node, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), convertedLoopBody);
70737         }
70738         function convertDoStatement(node, convertedLoopBody) {
70739             return ts.updateDo(node, convertedLoopBody, ts.visitNode(node.expression, visitor, ts.isExpression));
70740         }
70741         function convertWhileStatement(node, convertedLoopBody) {
70742             return ts.updateWhile(node, ts.visitNode(node.expression, visitor, ts.isExpression), convertedLoopBody);
70743         }
70744         function createConvertedLoopState(node) {
70745             var loopInitializer;
70746             switch (node.kind) {
70747                 case 230:
70748                 case 231:
70749                 case 232:
70750                     var initializer = node.initializer;
70751                     if (initializer && initializer.kind === 243) {
70752                         loopInitializer = initializer;
70753                     }
70754                     break;
70755             }
70756             var loopParameters = [];
70757             var loopOutParameters = [];
70758             if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3)) {
70759                 var hasCapturedBindingsInForInitializer = shouldConvertInitializerOfForStatement(node);
70760                 for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) {
70761                     var decl = _a[_i];
70762                     processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
70763                 }
70764             }
70765             var currentState = { loopParameters: loopParameters, loopOutParameters: loopOutParameters };
70766             if (convertedLoopState) {
70767                 if (convertedLoopState.argumentsName) {
70768                     currentState.argumentsName = convertedLoopState.argumentsName;
70769                 }
70770                 if (convertedLoopState.thisName) {
70771                     currentState.thisName = convertedLoopState.thisName;
70772                 }
70773                 if (convertedLoopState.hoistedLocalVariables) {
70774                     currentState.hoistedLocalVariables = convertedLoopState.hoistedLocalVariables;
70775                 }
70776             }
70777             return currentState;
70778         }
70779         function addExtraDeclarationsForConvertedLoop(statements, state, outerState) {
70780             var extraVariableDeclarations;
70781             if (state.argumentsName) {
70782                 if (outerState) {
70783                     outerState.argumentsName = state.argumentsName;
70784                 }
70785                 else {
70786                     (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(state.argumentsName, undefined, ts.createIdentifier("arguments")));
70787                 }
70788             }
70789             if (state.thisName) {
70790                 if (outerState) {
70791                     outerState.thisName = state.thisName;
70792                 }
70793                 else {
70794                     (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(state.thisName, undefined, ts.createIdentifier("this")));
70795                 }
70796             }
70797             if (state.hoistedLocalVariables) {
70798                 if (outerState) {
70799                     outerState.hoistedLocalVariables = state.hoistedLocalVariables;
70800                 }
70801                 else {
70802                     if (!extraVariableDeclarations) {
70803                         extraVariableDeclarations = [];
70804                     }
70805                     for (var _i = 0, _a = state.hoistedLocalVariables; _i < _a.length; _i++) {
70806                         var identifier = _a[_i];
70807                         extraVariableDeclarations.push(ts.createVariableDeclaration(identifier));
70808                     }
70809                 }
70810             }
70811             if (state.loopOutParameters.length) {
70812                 if (!extraVariableDeclarations) {
70813                     extraVariableDeclarations = [];
70814                 }
70815                 for (var _b = 0, _c = state.loopOutParameters; _b < _c.length; _b++) {
70816                     var outParam = _c[_b];
70817                     extraVariableDeclarations.push(ts.createVariableDeclaration(outParam.outParamName));
70818                 }
70819             }
70820             if (state.conditionVariable) {
70821                 if (!extraVariableDeclarations) {
70822                     extraVariableDeclarations = [];
70823                 }
70824                 extraVariableDeclarations.push(ts.createVariableDeclaration(state.conditionVariable, undefined, ts.createFalse()));
70825             }
70826             if (extraVariableDeclarations) {
70827                 statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(extraVariableDeclarations)));
70828             }
70829         }
70830         function createOutVariable(p) {
70831             return ts.createVariableDeclaration(p.originalName, undefined, p.outParamName);
70832         }
70833         function createFunctionForInitializerOfForStatement(node, currentState) {
70834             var functionName = ts.createUniqueName("_loop_init");
70835             var containsYield = (node.initializer.transformFlags & 262144) !== 0;
70836             var emitFlags = 0;
70837             if (currentState.containsLexicalThis)
70838                 emitFlags |= 8;
70839             if (containsYield && hierarchyFacts & 4)
70840                 emitFlags |= 262144;
70841             var statements = [];
70842             statements.push(ts.createVariableStatement(undefined, node.initializer));
70843             copyOutParameters(currentState.loopOutParameters, 2, 1, statements);
70844             var functionDeclaration = ts.createVariableStatement(undefined, ts.setEmitFlags(ts.createVariableDeclarationList([
70845                 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))
70846             ]), 2097152));
70847             var part = ts.createVariableDeclarationList(ts.map(currentState.loopOutParameters, createOutVariable));
70848             return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part };
70849         }
70850         function createFunctionForBodyOfIterationStatement(node, currentState, outerState) {
70851             var functionName = ts.createUniqueName("_loop");
70852             startLexicalEnvironment();
70853             var statement = ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock);
70854             var lexicalEnvironment = endLexicalEnvironment();
70855             var statements = [];
70856             if (shouldConvertConditionOfForStatement(node) || shouldConvertIncrementorOfForStatement(node)) {
70857                 currentState.conditionVariable = ts.createUniqueName("inc");
70858                 statements.push(ts.createIf(currentState.conditionVariable, ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), ts.createStatement(ts.createAssignment(currentState.conditionVariable, ts.createTrue()))));
70859                 if (shouldConvertConditionOfForStatement(node)) {
70860                     statements.push(ts.createIf(ts.createPrefix(53, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement)));
70861                 }
70862             }
70863             if (ts.isBlock(statement)) {
70864                 ts.addRange(statements, statement.statements);
70865             }
70866             else {
70867                 statements.push(statement);
70868             }
70869             copyOutParameters(currentState.loopOutParameters, 1, 1, statements);
70870             ts.insertStatementsAfterStandardPrologue(statements, lexicalEnvironment);
70871             var loopBody = ts.createBlock(statements, true);
70872             if (ts.isBlock(statement))
70873                 ts.setOriginalNode(loopBody, statement);
70874             var containsYield = (node.statement.transformFlags & 262144) !== 0;
70875             var emitFlags = 0;
70876             if (currentState.containsLexicalThis)
70877                 emitFlags |= 8;
70878             if (containsYield && (hierarchyFacts & 4) !== 0)
70879                 emitFlags |= 262144;
70880             var functionDeclaration = ts.createVariableStatement(undefined, ts.setEmitFlags(ts.createVariableDeclarationList([
70881                 ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, containsYield ? ts.createToken(41) : undefined, undefined, undefined, currentState.loopParameters, undefined, loopBody), emitFlags))
70882             ]), 2097152));
70883             var part = generateCallToConvertedLoop(functionName, currentState, outerState, containsYield);
70884             return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part };
70885         }
70886         function copyOutParameter(outParam, copyDirection) {
70887             var source = copyDirection === 0 ? outParam.outParamName : outParam.originalName;
70888             var target = copyDirection === 0 ? outParam.originalName : outParam.outParamName;
70889             return ts.createBinary(target, 62, source);
70890         }
70891         function copyOutParameters(outParams, partFlags, copyDirection, statements) {
70892             for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) {
70893                 var outParam = outParams_1[_i];
70894                 if (outParam.flags & partFlags) {
70895                     statements.push(ts.createExpressionStatement(copyOutParameter(outParam, copyDirection)));
70896                 }
70897             }
70898         }
70899         function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) {
70900             var call = ts.createCall(initFunctionExpressionName, undefined, []);
70901             var callResult = containsYield
70902                 ? ts.createYield(ts.createToken(41), ts.setEmitFlags(call, 8388608))
70903                 : call;
70904             return ts.createStatement(callResult);
70905         }
70906         function generateCallToConvertedLoop(loopFunctionExpressionName, state, outerState, containsYield) {
70907             var statements = [];
70908             var isSimpleLoop = !(state.nonLocalJumps & ~4) &&
70909                 !state.labeledNonLocalBreaks &&
70910                 !state.labeledNonLocalContinues;
70911             var call = ts.createCall(loopFunctionExpressionName, undefined, ts.map(state.loopParameters, function (p) { return p.name; }));
70912             var callResult = containsYield
70913                 ? ts.createYield(ts.createToken(41), ts.setEmitFlags(call, 8388608))
70914                 : call;
70915             if (isSimpleLoop) {
70916                 statements.push(ts.createExpressionStatement(callResult));
70917                 copyOutParameters(state.loopOutParameters, 1, 0, statements);
70918             }
70919             else {
70920                 var loopResultName = ts.createUniqueName("state");
70921                 var stateVariable = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ts.createVariableDeclaration(loopResultName, undefined, callResult)]));
70922                 statements.push(stateVariable);
70923                 copyOutParameters(state.loopOutParameters, 1, 0, statements);
70924                 if (state.nonLocalJumps & 8) {
70925                     var returnStatement = void 0;
70926                     if (outerState) {
70927                         outerState.nonLocalJumps |= 8;
70928                         returnStatement = ts.createReturn(loopResultName);
70929                     }
70930                     else {
70931                         returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value"));
70932                     }
70933                     statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 36, ts.createLiteral("object")), returnStatement));
70934                 }
70935                 if (state.nonLocalJumps & 2) {
70936                     statements.push(ts.createIf(ts.createBinary(loopResultName, 36, ts.createLiteral("break")), ts.createBreak()));
70937                 }
70938                 if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) {
70939                     var caseClauses = [];
70940                     processLabeledJumps(state.labeledNonLocalBreaks, true, loopResultName, outerState, caseClauses);
70941                     processLabeledJumps(state.labeledNonLocalContinues, false, loopResultName, outerState, caseClauses);
70942                     statements.push(ts.createSwitch(loopResultName, ts.createCaseBlock(caseClauses)));
70943                 }
70944             }
70945             return statements;
70946         }
70947         function setLabeledJump(state, isBreak, labelText, labelMarker) {
70948             if (isBreak) {
70949                 if (!state.labeledNonLocalBreaks) {
70950                     state.labeledNonLocalBreaks = ts.createMap();
70951                 }
70952                 state.labeledNonLocalBreaks.set(labelText, labelMarker);
70953             }
70954             else {
70955                 if (!state.labeledNonLocalContinues) {
70956                     state.labeledNonLocalContinues = ts.createMap();
70957                 }
70958                 state.labeledNonLocalContinues.set(labelText, labelMarker);
70959             }
70960         }
70961         function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) {
70962             if (!table) {
70963                 return;
70964             }
70965             table.forEach(function (labelMarker, labelText) {
70966                 var statements = [];
70967                 if (!outerLoop || (outerLoop.labels && outerLoop.labels.get(labelText))) {
70968                     var label = ts.createIdentifier(labelText);
70969                     statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label));
70970                 }
70971                 else {
70972                     setLabeledJump(outerLoop, isBreak, labelText, labelMarker);
70973                     statements.push(ts.createReturn(loopResultName));
70974                 }
70975                 caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements));
70976             });
70977         }
70978         function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer) {
70979             var name = decl.name;
70980             if (ts.isBindingPattern(name)) {
70981                 for (var _i = 0, _a = name.elements; _i < _a.length; _i++) {
70982                     var element = _a[_i];
70983                     if (!ts.isOmittedExpression(element)) {
70984                         processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
70985                     }
70986                 }
70987             }
70988             else {
70989                 loopParameters.push(ts.createParameter(undefined, undefined, undefined, name));
70990                 var checkFlags = resolver.getNodeCheckFlags(decl);
70991                 if (checkFlags & 4194304 || hasCapturedBindingsInForInitializer) {
70992                     var outParamName = ts.createUniqueName("out_" + ts.idText(name));
70993                     var flags = 0;
70994                     if (checkFlags & 4194304) {
70995                         flags |= 1;
70996                     }
70997                     if (ts.isForStatement(container) && container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
70998                         flags |= 2;
70999                     }
71000                     loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName });
71001                 }
71002             }
71003         }
71004         function addObjectLiteralMembers(expressions, node, receiver, start) {
71005             var properties = node.properties;
71006             var numProperties = properties.length;
71007             for (var i = start; i < numProperties; i++) {
71008                 var property = properties[i];
71009                 switch (property.kind) {
71010                     case 163:
71011                     case 164:
71012                         var accessors = ts.getAllAccessorDeclarations(node.properties, property);
71013                         if (property === accessors.firstAccessor) {
71014                             expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine));
71015                         }
71016                         break;
71017                     case 161:
71018                         expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine));
71019                         break;
71020                     case 281:
71021                         expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine));
71022                         break;
71023                     case 282:
71024                         expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine));
71025                         break;
71026                     default:
71027                         ts.Debug.failBadSyntaxKind(node);
71028                         break;
71029                 }
71030             }
71031         }
71032         function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) {
71033             var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression));
71034             ts.setTextRange(expression, property);
71035             if (startsOnNewLine) {
71036                 ts.startOnNewLine(expression);
71037             }
71038             return expression;
71039         }
71040         function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) {
71041             var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name));
71042             ts.setTextRange(expression, property);
71043             if (startsOnNewLine) {
71044                 ts.startOnNewLine(expression);
71045             }
71046             return expression;
71047         }
71048         function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) {
71049             var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined, container));
71050             ts.setTextRange(expression, method);
71051             if (startsOnNewLine) {
71052                 ts.startOnNewLine(expression);
71053             }
71054             return expression;
71055         }
71056         function visitCatchClause(node) {
71057             var ancestorFacts = enterSubtree(7104, 0);
71058             var updated;
71059             ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015.");
71060             if (ts.isBindingPattern(node.variableDeclaration.name)) {
71061                 var temp = ts.createTempVariable(undefined);
71062                 var newVariableDeclaration = ts.createVariableDeclaration(temp);
71063                 ts.setTextRange(newVariableDeclaration, node.variableDeclaration);
71064                 var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp);
71065                 var list = ts.createVariableDeclarationList(vars);
71066                 ts.setTextRange(list, node.variableDeclaration);
71067                 var destructure = ts.createVariableStatement(undefined, list);
71068                 updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure));
71069             }
71070             else {
71071                 updated = ts.visitEachChild(node, visitor, context);
71072             }
71073             exitSubtree(ancestorFacts, 0, 0);
71074             return updated;
71075         }
71076         function addStatementToStartOfBlock(block, statement) {
71077             var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement);
71078             return ts.updateBlock(block, __spreadArrays([statement], transformedStatements));
71079         }
71080         function visitMethodDeclaration(node) {
71081             ts.Debug.assert(!ts.isComputedPropertyName(node.name));
71082             var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined, undefined);
71083             ts.setEmitFlags(functionExpression, 512 | ts.getEmitFlags(functionExpression));
71084             return ts.setTextRange(ts.createPropertyAssignment(node.name, functionExpression), node);
71085         }
71086         function visitAccessorDeclaration(node) {
71087             ts.Debug.assert(!ts.isComputedPropertyName(node.name));
71088             var savedConvertedLoopState = convertedLoopState;
71089             convertedLoopState = undefined;
71090             var ancestorFacts = enterSubtree(16286, 65);
71091             var updated;
71092             var parameters = ts.visitParameterList(node.parameters, visitor, context);
71093             var body = transformFunctionBody(node);
71094             if (node.kind === 163) {
71095                 updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body);
71096             }
71097             else {
71098                 updated = ts.updateSetAccessor(node, node.decorators, node.modifiers, node.name, parameters, body);
71099             }
71100             exitSubtree(ancestorFacts, 49152, 0);
71101             convertedLoopState = savedConvertedLoopState;
71102             return updated;
71103         }
71104         function visitShorthandPropertyAssignment(node) {
71105             return ts.setTextRange(ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name)), node);
71106         }
71107         function visitComputedPropertyName(node) {
71108             return ts.visitEachChild(node, visitor, context);
71109         }
71110         function visitYieldExpression(node) {
71111             return ts.visitEachChild(node, visitor, context);
71112         }
71113         function visitArrayLiteralExpression(node) {
71114             if (ts.some(node.elements, ts.isSpreadElement)) {
71115                 return transformAndSpreadElements(node.elements, true, !!node.multiLine, !!node.elements.hasTrailingComma);
71116             }
71117             return ts.visitEachChild(node, visitor, context);
71118         }
71119         function visitCallExpression(node) {
71120             if (ts.getEmitFlags(node) & 33554432) {
71121                 return visitTypeScriptClassWrapper(node);
71122             }
71123             var expression = ts.skipOuterExpressions(node.expression);
71124             if (expression.kind === 102 ||
71125                 ts.isSuperProperty(expression) ||
71126                 ts.some(node.arguments, ts.isSpreadElement)) {
71127                 return visitCallExpressionWithPotentialCapturedThisAssignment(node, true);
71128             }
71129             return ts.updateCall(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression));
71130         }
71131         function visitTypeScriptClassWrapper(node) {
71132             var body = ts.cast(ts.cast(ts.skipOuterExpressions(node.expression), ts.isArrowFunction).body, ts.isBlock);
71133             var isVariableStatementWithInitializer = function (stmt) { return ts.isVariableStatement(stmt) && !!ts.first(stmt.declarationList.declarations).initializer; };
71134             var savedConvertedLoopState = convertedLoopState;
71135             convertedLoopState = undefined;
71136             var bodyStatements = ts.visitNodes(body.statements, visitor, ts.isStatement);
71137             convertedLoopState = savedConvertedLoopState;
71138             var classStatements = ts.filter(bodyStatements, isVariableStatementWithInitializer);
71139             var remainingStatements = ts.filter(bodyStatements, function (stmt) { return !isVariableStatementWithInitializer(stmt); });
71140             var varStatement = ts.cast(ts.first(classStatements), ts.isVariableStatement);
71141             var variable = varStatement.declarationList.declarations[0];
71142             var initializer = ts.skipOuterExpressions(variable.initializer);
71143             var aliasAssignment = ts.tryCast(initializer, ts.isAssignmentExpression);
71144             var call = ts.cast(aliasAssignment ? ts.skipOuterExpressions(aliasAssignment.right) : initializer, ts.isCallExpression);
71145             var func = ts.cast(ts.skipOuterExpressions(call.expression), ts.isFunctionExpression);
71146             var funcStatements = func.body.statements;
71147             var classBodyStart = 0;
71148             var classBodyEnd = -1;
71149             var statements = [];
71150             if (aliasAssignment) {
71151                 var extendsCall = ts.tryCast(funcStatements[classBodyStart], ts.isExpressionStatement);
71152                 if (extendsCall) {
71153                     statements.push(extendsCall);
71154                     classBodyStart++;
71155                 }
71156                 statements.push(funcStatements[classBodyStart]);
71157                 classBodyStart++;
71158                 statements.push(ts.createExpressionStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier))));
71159             }
71160             while (!ts.isReturnStatement(ts.elementAt(funcStatements, classBodyEnd))) {
71161                 classBodyEnd--;
71162             }
71163             ts.addRange(statements, funcStatements, classBodyStart, classBodyEnd);
71164             if (classBodyEnd < -1) {
71165                 ts.addRange(statements, funcStatements, classBodyEnd + 1);
71166             }
71167             ts.addRange(statements, remainingStatements);
71168             ts.addRange(statements, classStatements, 1);
71169             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))));
71170         }
71171         function visitImmediateSuperCallInBody(node) {
71172             return visitCallExpressionWithPotentialCapturedThisAssignment(node, false);
71173         }
71174         function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
71175             if (node.transformFlags & 8192 ||
71176                 node.expression.kind === 102 ||
71177                 ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) {
71178                 var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
71179                 if (node.expression.kind === 102) {
71180                     ts.setEmitFlags(thisArg, 4);
71181                 }
71182                 var resultingCall = void 0;
71183                 if (node.transformFlags & 8192) {
71184                     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));
71185                 }
71186                 else {
71187                     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);
71188                 }
71189                 if (node.expression.kind === 102) {
71190                     var initializer = ts.createLogicalOr(resultingCall, createActualThis());
71191                     resultingCall = assignToCapturedThis
71192                         ? ts.createAssignment(ts.createFileLevelUniqueName("_this"), initializer)
71193                         : initializer;
71194                 }
71195                 return ts.setOriginalNode(resultingCall, node);
71196             }
71197             return ts.visitEachChild(node, visitor, context);
71198         }
71199         function visitNewExpression(node) {
71200             if (ts.some(node.arguments, ts.isSpreadElement)) {
71201                 var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
71202                 return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray(__spreadArrays([ts.createVoidZero()], node.arguments)), false, false, false)), undefined, []);
71203             }
71204             return ts.visitEachChild(node, visitor, context);
71205         }
71206         function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) {
71207             var numElements = elements.length;
71208             var segments = ts.flatten(ts.spanMap(elements, partitionSpread, function (partition, visitPartition, _start, end) {
71209                 return visitPartition(partition, multiLine, hasTrailingComma && end === numElements);
71210             }));
71211             if (compilerOptions.downlevelIteration) {
71212                 if (segments.length === 1) {
71213                     var firstSegment = segments[0];
71214                     if (isCallToHelper(firstSegment, "___spread")) {
71215                         return segments[0];
71216                     }
71217                 }
71218                 return ts.createSpreadHelper(context, segments);
71219             }
71220             else {
71221                 if (segments.length === 1) {
71222                     var firstSegment = segments[0];
71223                     if (!needsUniqueCopy
71224                         || isPackedArrayLiteral(firstSegment)
71225                         || isCallToHelper(firstSegment, "___spreadArrays")) {
71226                         return segments[0];
71227                     }
71228                 }
71229                 return ts.createSpreadArraysHelper(context, segments);
71230             }
71231         }
71232         function isPackedElement(node) {
71233             return !ts.isOmittedExpression(node);
71234         }
71235         function isPackedArrayLiteral(node) {
71236             return ts.isArrayLiteralExpression(node) && ts.every(node.elements, isPackedElement);
71237         }
71238         function isCallToHelper(firstSegment, helperName) {
71239             return ts.isCallExpression(firstSegment)
71240                 && ts.isIdentifier(firstSegment.expression)
71241                 && (ts.getEmitFlags(firstSegment.expression) & 4096)
71242                 && firstSegment.expression.escapedText === helperName;
71243         }
71244         function partitionSpread(node) {
71245             return ts.isSpreadElement(node)
71246                 ? visitSpanOfSpreads
71247                 : visitSpanOfNonSpreads;
71248         }
71249         function visitSpanOfSpreads(chunk) {
71250             return ts.map(chunk, visitExpressionOfSpread);
71251         }
71252         function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) {
71253             return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine);
71254         }
71255         function visitSpreadElement(node) {
71256             return ts.visitNode(node.expression, visitor, ts.isExpression);
71257         }
71258         function visitExpressionOfSpread(node) {
71259             return ts.visitNode(node.expression, visitor, ts.isExpression);
71260         }
71261         function visitTemplateLiteral(node) {
71262             return ts.setTextRange(ts.createLiteral(node.text), node);
71263         }
71264         function visitStringLiteral(node) {
71265             if (node.hasExtendedUnicodeEscape) {
71266                 return ts.setTextRange(ts.createLiteral(node.text), node);
71267             }
71268             return node;
71269         }
71270         function visitNumericLiteral(node) {
71271             if (node.numericLiteralFlags & 384) {
71272                 return ts.setTextRange(ts.createNumericLiteral(node.text), node);
71273             }
71274             return node;
71275         }
71276         function visitTaggedTemplateExpression(node) {
71277             return ts.processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, ts.ProcessLevel.All);
71278         }
71279         function visitTemplateExpression(node) {
71280             var expressions = [];
71281             addTemplateHead(expressions, node);
71282             addTemplateSpans(expressions, node);
71283             var expression = ts.reduceLeft(expressions, ts.createAdd);
71284             if (ts.nodeIsSynthesized(expression)) {
71285                 expression.pos = node.pos;
71286                 expression.end = node.end;
71287             }
71288             return expression;
71289         }
71290         function shouldAddTemplateHead(node) {
71291             ts.Debug.assert(node.templateSpans.length !== 0);
71292             return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0;
71293         }
71294         function addTemplateHead(expressions, node) {
71295             if (!shouldAddTemplateHead(node)) {
71296                 return;
71297             }
71298             expressions.push(ts.createLiteral(node.head.text));
71299         }
71300         function addTemplateSpans(expressions, node) {
71301             for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) {
71302                 var span = _a[_i];
71303                 expressions.push(ts.visitNode(span.expression, visitor, ts.isExpression));
71304                 if (span.literal.text.length !== 0) {
71305                     expressions.push(ts.createLiteral(span.literal.text));
71306                 }
71307             }
71308         }
71309         function visitSuperKeyword(isExpressionOfCall) {
71310             return hierarchyFacts & 8 && !isExpressionOfCall ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") :
71311                 ts.createFileLevelUniqueName("_super");
71312         }
71313         function visitMetaProperty(node) {
71314             if (node.keywordToken === 99 && node.name.escapedText === "target") {
71315                 hierarchyFacts |= 16384;
71316                 return ts.createFileLevelUniqueName("_newTarget");
71317             }
71318             return node;
71319         }
71320         function onEmitNode(hint, node, emitCallback) {
71321             if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) {
71322                 var ancestorFacts = enterSubtree(16286, ts.getEmitFlags(node) & 8
71323                     ? 65 | 16
71324                     : 65);
71325                 previousOnEmitNode(hint, node, emitCallback);
71326                 exitSubtree(ancestorFacts, 0, 0);
71327                 return;
71328             }
71329             previousOnEmitNode(hint, node, emitCallback);
71330         }
71331         function enableSubstitutionsForBlockScopedBindings() {
71332             if ((enabledSubstitutions & 2) === 0) {
71333                 enabledSubstitutions |= 2;
71334                 context.enableSubstitution(75);
71335             }
71336         }
71337         function enableSubstitutionsForCapturedThis() {
71338             if ((enabledSubstitutions & 1) === 0) {
71339                 enabledSubstitutions |= 1;
71340                 context.enableSubstitution(104);
71341                 context.enableEmitNotification(162);
71342                 context.enableEmitNotification(161);
71343                 context.enableEmitNotification(163);
71344                 context.enableEmitNotification(164);
71345                 context.enableEmitNotification(202);
71346                 context.enableEmitNotification(201);
71347                 context.enableEmitNotification(244);
71348             }
71349         }
71350         function onSubstituteNode(hint, node) {
71351             node = previousOnSubstituteNode(hint, node);
71352             if (hint === 1) {
71353                 return substituteExpression(node);
71354             }
71355             if (ts.isIdentifier(node)) {
71356                 return substituteIdentifier(node);
71357             }
71358             return node;
71359         }
71360         function substituteIdentifier(node) {
71361             if (enabledSubstitutions & 2 && !ts.isInternalName(node)) {
71362                 var original = ts.getParseTreeNode(node, ts.isIdentifier);
71363                 if (original && isNameOfDeclarationWithCollidingName(original)) {
71364                     return ts.setTextRange(ts.getGeneratedNameForNode(original), node);
71365                 }
71366             }
71367             return node;
71368         }
71369         function isNameOfDeclarationWithCollidingName(node) {
71370             switch (node.parent.kind) {
71371                 case 191:
71372                 case 245:
71373                 case 248:
71374                 case 242:
71375                     return node.parent.name === node
71376                         && resolver.isDeclarationWithCollidingName(node.parent);
71377             }
71378             return false;
71379         }
71380         function substituteExpression(node) {
71381             switch (node.kind) {
71382                 case 75:
71383                     return substituteExpressionIdentifier(node);
71384                 case 104:
71385                     return substituteThisKeyword(node);
71386             }
71387             return node;
71388         }
71389         function substituteExpressionIdentifier(node) {
71390             if (enabledSubstitutions & 2 && !ts.isInternalName(node)) {
71391                 var declaration = resolver.getReferencedDeclarationWithCollidingName(node);
71392                 if (declaration && !(ts.isClassLike(declaration) && isPartOfClassBody(declaration, node))) {
71393                     return ts.setTextRange(ts.getGeneratedNameForNode(ts.getNameOfDeclaration(declaration)), node);
71394                 }
71395             }
71396             return node;
71397         }
71398         function isPartOfClassBody(declaration, node) {
71399             var currentNode = ts.getParseTreeNode(node);
71400             if (!currentNode || currentNode === declaration || currentNode.end <= declaration.pos || currentNode.pos >= declaration.end) {
71401                 return false;
71402             }
71403             var blockScope = ts.getEnclosingBlockScopeContainer(declaration);
71404             while (currentNode) {
71405                 if (currentNode === blockScope || currentNode === declaration) {
71406                     return false;
71407                 }
71408                 if (ts.isClassElement(currentNode) && currentNode.parent === declaration) {
71409                     return true;
71410                 }
71411                 currentNode = currentNode.parent;
71412             }
71413             return false;
71414         }
71415         function substituteThisKeyword(node) {
71416             if (enabledSubstitutions & 1
71417                 && hierarchyFacts & 16) {
71418                 return ts.setTextRange(ts.createFileLevelUniqueName("_this"), node);
71419             }
71420             return node;
71421         }
71422         function getClassMemberPrefix(node, member) {
71423             return ts.hasModifier(member, 32)
71424                 ? ts.getInternalName(node)
71425                 : ts.createPropertyAccess(ts.getInternalName(node), "prototype");
71426         }
71427         function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) {
71428             if (!constructor || !hasExtendsClause) {
71429                 return false;
71430             }
71431             if (ts.some(constructor.parameters)) {
71432                 return false;
71433             }
71434             var statement = ts.firstOrUndefined(constructor.body.statements);
71435             if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 226) {
71436                 return false;
71437             }
71438             var statementExpression = statement.expression;
71439             if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 196) {
71440                 return false;
71441             }
71442             var callTarget = statementExpression.expression;
71443             if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 102) {
71444                 return false;
71445             }
71446             var callArgument = ts.singleOrUndefined(statementExpression.arguments);
71447             if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 213) {
71448                 return false;
71449             }
71450             var expression = callArgument.expression;
71451             return ts.isIdentifier(expression) && expression.escapedText === "arguments";
71452         }
71453     }
71454     ts.transformES2015 = transformES2015;
71455     function createExtendsHelper(context, name) {
71456         context.requestEmitHelper(ts.extendsHelper);
71457         return ts.createCall(ts.getUnscopedHelperName("__extends"), undefined, [
71458             name,
71459             ts.createFileLevelUniqueName("_super")
71460         ]);
71461     }
71462     ts.extendsHelper = {
71463         name: "typescript:extends",
71464         importName: "__extends",
71465         scoped: false,
71466         priority: 0,
71467         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            })();"
71468     };
71469 })(ts || (ts = {}));
71470 var ts;
71471 (function (ts) {
71472     function transformES5(context) {
71473         var compilerOptions = context.getCompilerOptions();
71474         var previousOnEmitNode;
71475         var noSubstitution;
71476         if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) {
71477             previousOnEmitNode = context.onEmitNode;
71478             context.onEmitNode = onEmitNode;
71479             context.enableEmitNotification(268);
71480             context.enableEmitNotification(269);
71481             context.enableEmitNotification(267);
71482             noSubstitution = [];
71483         }
71484         var previousOnSubstituteNode = context.onSubstituteNode;
71485         context.onSubstituteNode = onSubstituteNode;
71486         context.enableSubstitution(194);
71487         context.enableSubstitution(281);
71488         return ts.chainBundle(transformSourceFile);
71489         function transformSourceFile(node) {
71490             return node;
71491         }
71492         function onEmitNode(hint, node, emitCallback) {
71493             switch (node.kind) {
71494                 case 268:
71495                 case 269:
71496                 case 267:
71497                     var tagName = node.tagName;
71498                     noSubstitution[ts.getOriginalNodeId(tagName)] = true;
71499                     break;
71500             }
71501             previousOnEmitNode(hint, node, emitCallback);
71502         }
71503         function onSubstituteNode(hint, node) {
71504             if (node.id && noSubstitution && noSubstitution[node.id]) {
71505                 return previousOnSubstituteNode(hint, node);
71506             }
71507             node = previousOnSubstituteNode(hint, node);
71508             if (ts.isPropertyAccessExpression(node)) {
71509                 return substitutePropertyAccessExpression(node);
71510             }
71511             else if (ts.isPropertyAssignment(node)) {
71512                 return substitutePropertyAssignment(node);
71513             }
71514             return node;
71515         }
71516         function substitutePropertyAccessExpression(node) {
71517             if (ts.isPrivateIdentifier(node.name)) {
71518                 return node;
71519             }
71520             var literalName = trySubstituteReservedName(node.name);
71521             if (literalName) {
71522                 return ts.setTextRange(ts.createElementAccess(node.expression, literalName), node);
71523             }
71524             return node;
71525         }
71526         function substitutePropertyAssignment(node) {
71527             var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name);
71528             if (literalName) {
71529                 return ts.updatePropertyAssignment(node, literalName, node.initializer);
71530             }
71531             return node;
71532         }
71533         function trySubstituteReservedName(name) {
71534             var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined);
71535             if (token !== undefined && token >= 77 && token <= 112) {
71536                 return ts.setTextRange(ts.createLiteral(name), name);
71537             }
71538             return undefined;
71539         }
71540     }
71541     ts.transformES5 = transformES5;
71542 })(ts || (ts = {}));
71543 var ts;
71544 (function (ts) {
71545     function getInstructionName(instruction) {
71546         switch (instruction) {
71547             case 2: return "return";
71548             case 3: return "break";
71549             case 4: return "yield";
71550             case 5: return "yield*";
71551             case 7: return "endfinally";
71552             default: return undefined;
71553         }
71554     }
71555     function transformGenerators(context) {
71556         var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration;
71557         var compilerOptions = context.getCompilerOptions();
71558         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
71559         var resolver = context.getEmitResolver();
71560         var previousOnSubstituteNode = context.onSubstituteNode;
71561         context.onSubstituteNode = onSubstituteNode;
71562         var renamedCatchVariables;
71563         var renamedCatchVariableDeclarations;
71564         var inGeneratorFunctionBody;
71565         var inStatementContainingYield;
71566         var blocks;
71567         var blockOffsets;
71568         var blockActions;
71569         var blockStack;
71570         var labelOffsets;
71571         var labelExpressions;
71572         var nextLabelId = 1;
71573         var operations;
71574         var operationArguments;
71575         var operationLocations;
71576         var state;
71577         var blockIndex = 0;
71578         var labelNumber = 0;
71579         var labelNumbers;
71580         var lastOperationWasAbrupt;
71581         var lastOperationWasCompletion;
71582         var clauses;
71583         var statements;
71584         var exceptionBlockStack;
71585         var currentExceptionBlock;
71586         var withBlockStack;
71587         return ts.chainBundle(transformSourceFile);
71588         function transformSourceFile(node) {
71589             if (node.isDeclarationFile || (node.transformFlags & 512) === 0) {
71590                 return node;
71591             }
71592             var visited = ts.visitEachChild(node, visitor, context);
71593             ts.addEmitHelpers(visited, context.readEmitHelpers());
71594             return visited;
71595         }
71596         function visitor(node) {
71597             var transformFlags = node.transformFlags;
71598             if (inStatementContainingYield) {
71599                 return visitJavaScriptInStatementContainingYield(node);
71600             }
71601             else if (inGeneratorFunctionBody) {
71602                 return visitJavaScriptInGeneratorFunctionBody(node);
71603             }
71604             else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) {
71605                 return visitGenerator(node);
71606             }
71607             else if (transformFlags & 512) {
71608                 return ts.visitEachChild(node, visitor, context);
71609             }
71610             else {
71611                 return node;
71612             }
71613         }
71614         function visitJavaScriptInStatementContainingYield(node) {
71615             switch (node.kind) {
71616                 case 228:
71617                     return visitDoStatement(node);
71618                 case 229:
71619                     return visitWhileStatement(node);
71620                 case 237:
71621                     return visitSwitchStatement(node);
71622                 case 238:
71623                     return visitLabeledStatement(node);
71624                 default:
71625                     return visitJavaScriptInGeneratorFunctionBody(node);
71626             }
71627         }
71628         function visitJavaScriptInGeneratorFunctionBody(node) {
71629             switch (node.kind) {
71630                 case 244:
71631                     return visitFunctionDeclaration(node);
71632                 case 201:
71633                     return visitFunctionExpression(node);
71634                 case 163:
71635                 case 164:
71636                     return visitAccessorDeclaration(node);
71637                 case 225:
71638                     return visitVariableStatement(node);
71639                 case 230:
71640                     return visitForStatement(node);
71641                 case 231:
71642                     return visitForInStatement(node);
71643                 case 234:
71644                     return visitBreakStatement(node);
71645                 case 233:
71646                     return visitContinueStatement(node);
71647                 case 235:
71648                     return visitReturnStatement(node);
71649                 default:
71650                     if (node.transformFlags & 262144) {
71651                         return visitJavaScriptContainingYield(node);
71652                     }
71653                     else if (node.transformFlags & (512 | 1048576)) {
71654                         return ts.visitEachChild(node, visitor, context);
71655                     }
71656                     else {
71657                         return node;
71658                     }
71659             }
71660         }
71661         function visitJavaScriptContainingYield(node) {
71662             switch (node.kind) {
71663                 case 209:
71664                     return visitBinaryExpression(node);
71665                 case 210:
71666                     return visitConditionalExpression(node);
71667                 case 212:
71668                     return visitYieldExpression(node);
71669                 case 192:
71670                     return visitArrayLiteralExpression(node);
71671                 case 193:
71672                     return visitObjectLiteralExpression(node);
71673                 case 195:
71674                     return visitElementAccessExpression(node);
71675                 case 196:
71676                     return visitCallExpression(node);
71677                 case 197:
71678                     return visitNewExpression(node);
71679                 default:
71680                     return ts.visitEachChild(node, visitor, context);
71681             }
71682         }
71683         function visitGenerator(node) {
71684             switch (node.kind) {
71685                 case 244:
71686                     return visitFunctionDeclaration(node);
71687                 case 201:
71688                     return visitFunctionExpression(node);
71689                 default:
71690                     return ts.Debug.failBadSyntaxKind(node);
71691             }
71692         }
71693         function visitFunctionDeclaration(node) {
71694             if (node.asteriskToken) {
71695                 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);
71696             }
71697             else {
71698                 var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
71699                 var savedInStatementContainingYield = inStatementContainingYield;
71700                 inGeneratorFunctionBody = false;
71701                 inStatementContainingYield = false;
71702                 node = ts.visitEachChild(node, visitor, context);
71703                 inGeneratorFunctionBody = savedInGeneratorFunctionBody;
71704                 inStatementContainingYield = savedInStatementContainingYield;
71705             }
71706             if (inGeneratorFunctionBody) {
71707                 hoistFunctionDeclaration(node);
71708                 return undefined;
71709             }
71710             else {
71711                 return node;
71712             }
71713         }
71714         function visitFunctionExpression(node) {
71715             if (node.asteriskToken) {
71716                 node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, 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             return node;
71728         }
71729         function visitAccessorDeclaration(node) {
71730             var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
71731             var savedInStatementContainingYield = inStatementContainingYield;
71732             inGeneratorFunctionBody = false;
71733             inStatementContainingYield = false;
71734             node = ts.visitEachChild(node, visitor, context);
71735             inGeneratorFunctionBody = savedInGeneratorFunctionBody;
71736             inStatementContainingYield = savedInStatementContainingYield;
71737             return node;
71738         }
71739         function transformGeneratorFunctionBody(body) {
71740             var statements = [];
71741             var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
71742             var savedInStatementContainingYield = inStatementContainingYield;
71743             var savedBlocks = blocks;
71744             var savedBlockOffsets = blockOffsets;
71745             var savedBlockActions = blockActions;
71746             var savedBlockStack = blockStack;
71747             var savedLabelOffsets = labelOffsets;
71748             var savedLabelExpressions = labelExpressions;
71749             var savedNextLabelId = nextLabelId;
71750             var savedOperations = operations;
71751             var savedOperationArguments = operationArguments;
71752             var savedOperationLocations = operationLocations;
71753             var savedState = state;
71754             inGeneratorFunctionBody = true;
71755             inStatementContainingYield = false;
71756             blocks = undefined;
71757             blockOffsets = undefined;
71758             blockActions = undefined;
71759             blockStack = undefined;
71760             labelOffsets = undefined;
71761             labelExpressions = undefined;
71762             nextLabelId = 1;
71763             operations = undefined;
71764             operationArguments = undefined;
71765             operationLocations = undefined;
71766             state = ts.createTempVariable(undefined);
71767             resumeLexicalEnvironment();
71768             var statementOffset = ts.addPrologue(statements, body.statements, false, visitor);
71769             transformAndEmitStatements(body.statements, statementOffset);
71770             var buildResult = build();
71771             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
71772             statements.push(ts.createReturn(buildResult));
71773             inGeneratorFunctionBody = savedInGeneratorFunctionBody;
71774             inStatementContainingYield = savedInStatementContainingYield;
71775             blocks = savedBlocks;
71776             blockOffsets = savedBlockOffsets;
71777             blockActions = savedBlockActions;
71778             blockStack = savedBlockStack;
71779             labelOffsets = savedLabelOffsets;
71780             labelExpressions = savedLabelExpressions;
71781             nextLabelId = savedNextLabelId;
71782             operations = savedOperations;
71783             operationArguments = savedOperationArguments;
71784             operationLocations = savedOperationLocations;
71785             state = savedState;
71786             return ts.setTextRange(ts.createBlock(statements, body.multiLine), body);
71787         }
71788         function visitVariableStatement(node) {
71789             if (node.transformFlags & 262144) {
71790                 transformAndEmitVariableDeclarationList(node.declarationList);
71791                 return undefined;
71792             }
71793             else {
71794                 if (ts.getEmitFlags(node) & 1048576) {
71795                     return node;
71796                 }
71797                 for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
71798                     var variable = _a[_i];
71799                     hoistVariableDeclaration(variable.name);
71800                 }
71801                 var variables = ts.getInitializedVariables(node.declarationList);
71802                 if (variables.length === 0) {
71803                     return undefined;
71804                 }
71805                 return ts.setSourceMapRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node);
71806             }
71807         }
71808         function visitBinaryExpression(node) {
71809             var assoc = ts.getExpressionAssociativity(node);
71810             switch (assoc) {
71811                 case 0:
71812                     return visitLeftAssociativeBinaryExpression(node);
71813                 case 1:
71814                     return visitRightAssociativeBinaryExpression(node);
71815                 default:
71816                     return ts.Debug.assertNever(assoc);
71817             }
71818         }
71819         function visitRightAssociativeBinaryExpression(node) {
71820             var left = node.left, right = node.right;
71821             if (containsYield(right)) {
71822                 var target = void 0;
71823                 switch (left.kind) {
71824                     case 194:
71825                         target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name);
71826                         break;
71827                     case 195:
71828                         target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression)));
71829                         break;
71830                     default:
71831                         target = ts.visitNode(left, visitor, ts.isExpression);
71832                         break;
71833                 }
71834                 var operator = node.operatorToken.kind;
71835                 if (ts.isCompoundAssignment(operator)) {
71836                     return ts.setTextRange(ts.createAssignment(target, ts.setTextRange(ts.createBinary(cacheExpression(target), ts.getNonAssignmentOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression)), node)), node);
71837                 }
71838                 else {
71839                     return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression));
71840                 }
71841             }
71842             return ts.visitEachChild(node, visitor, context);
71843         }
71844         function visitLeftAssociativeBinaryExpression(node) {
71845             if (containsYield(node.right)) {
71846                 if (ts.isLogicalOperator(node.operatorToken.kind)) {
71847                     return visitLogicalBinaryExpression(node);
71848                 }
71849                 else if (node.operatorToken.kind === 27) {
71850                     return visitCommaExpression(node);
71851                 }
71852                 var clone_6 = ts.getMutableClone(node);
71853                 clone_6.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression));
71854                 clone_6.right = ts.visitNode(node.right, visitor, ts.isExpression);
71855                 return clone_6;
71856             }
71857             return ts.visitEachChild(node, visitor, context);
71858         }
71859         function visitLogicalBinaryExpression(node) {
71860             var resultLabel = defineLabel();
71861             var resultLocal = declareLocal();
71862             emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), node.left);
71863             if (node.operatorToken.kind === 55) {
71864                 emitBreakWhenFalse(resultLabel, resultLocal, node.left);
71865             }
71866             else {
71867                 emitBreakWhenTrue(resultLabel, resultLocal, node.left);
71868             }
71869             emitAssignment(resultLocal, ts.visitNode(node.right, visitor, ts.isExpression), node.right);
71870             markLabel(resultLabel);
71871             return resultLocal;
71872         }
71873         function visitCommaExpression(node) {
71874             var pendingExpressions = [];
71875             visit(node.left);
71876             visit(node.right);
71877             return ts.inlineExpressions(pendingExpressions);
71878             function visit(node) {
71879                 if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27) {
71880                     visit(node.left);
71881                     visit(node.right);
71882                 }
71883                 else {
71884                     if (containsYield(node) && pendingExpressions.length > 0) {
71885                         emitWorker(1, [ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))]);
71886                         pendingExpressions = [];
71887                     }
71888                     pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression));
71889                 }
71890             }
71891         }
71892         function visitConditionalExpression(node) {
71893             if (containsYield(node.whenTrue) || containsYield(node.whenFalse)) {
71894                 var whenFalseLabel = defineLabel();
71895                 var resultLabel = defineLabel();
71896                 var resultLocal = declareLocal();
71897                 emitBreakWhenFalse(whenFalseLabel, ts.visitNode(node.condition, visitor, ts.isExpression), node.condition);
71898                 emitAssignment(resultLocal, ts.visitNode(node.whenTrue, visitor, ts.isExpression), node.whenTrue);
71899                 emitBreak(resultLabel);
71900                 markLabel(whenFalseLabel);
71901                 emitAssignment(resultLocal, ts.visitNode(node.whenFalse, visitor, ts.isExpression), node.whenFalse);
71902                 markLabel(resultLabel);
71903                 return resultLocal;
71904             }
71905             return ts.visitEachChild(node, visitor, context);
71906         }
71907         function visitYieldExpression(node) {
71908             var resumeLabel = defineLabel();
71909             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
71910             if (node.asteriskToken) {
71911                 var iterator = (ts.getEmitFlags(node.expression) & 8388608) === 0
71912                     ? ts.createValuesHelper(context, expression, node)
71913                     : expression;
71914                 emitYieldStar(iterator, node);
71915             }
71916             else {
71917                 emitYield(expression, node);
71918             }
71919             markLabel(resumeLabel);
71920             return createGeneratorResume(node);
71921         }
71922         function visitArrayLiteralExpression(node) {
71923             return visitElements(node.elements, undefined, undefined, node.multiLine);
71924         }
71925         function visitElements(elements, leadingElement, location, multiLine) {
71926             var numInitialElements = countInitialNodesWithoutYield(elements);
71927             var temp;
71928             if (numInitialElements > 0) {
71929                 temp = declareLocal();
71930                 var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements);
71931                 emitAssignment(temp, ts.createArrayLiteral(leadingElement
71932                     ? __spreadArrays([leadingElement], initialElements) : initialElements));
71933                 leadingElement = undefined;
71934             }
71935             var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements);
71936             return temp
71937                 ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)])
71938                 : ts.setTextRange(ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine), location);
71939             function reduceElement(expressions, element) {
71940                 if (containsYield(element) && expressions.length > 0) {
71941                     var hasAssignedTemp = temp !== undefined;
71942                     if (!temp) {
71943                         temp = declareLocal();
71944                     }
71945                     emitAssignment(temp, hasAssignedTemp
71946                         ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)])
71947                         : ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine));
71948                     leadingElement = undefined;
71949                     expressions = [];
71950                 }
71951                 expressions.push(ts.visitNode(element, visitor, ts.isExpression));
71952                 return expressions;
71953             }
71954         }
71955         function visitObjectLiteralExpression(node) {
71956             var properties = node.properties;
71957             var multiLine = node.multiLine;
71958             var numInitialProperties = countInitialNodesWithoutYield(properties);
71959             var temp = declareLocal();
71960             emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), multiLine));
71961             var expressions = ts.reduceLeft(properties, reduceProperty, [], numInitialProperties);
71962             expressions.push(multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp);
71963             return ts.inlineExpressions(expressions);
71964             function reduceProperty(expressions, property) {
71965                 if (containsYield(property) && expressions.length > 0) {
71966                     emitStatement(ts.createExpressionStatement(ts.inlineExpressions(expressions)));
71967                     expressions = [];
71968                 }
71969                 var expression = ts.createExpressionForObjectLiteralElementLike(node, property, temp);
71970                 var visited = ts.visitNode(expression, visitor, ts.isExpression);
71971                 if (visited) {
71972                     if (multiLine) {
71973                         ts.startOnNewLine(visited);
71974                     }
71975                     expressions.push(visited);
71976                 }
71977                 return expressions;
71978             }
71979         }
71980         function visitElementAccessExpression(node) {
71981             if (containsYield(node.argumentExpression)) {
71982                 var clone_7 = ts.getMutableClone(node);
71983                 clone_7.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression));
71984                 clone_7.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression);
71985                 return clone_7;
71986             }
71987             return ts.visitEachChild(node, visitor, context);
71988         }
71989         function visitCallExpression(node) {
71990             if (!ts.isImportCall(node) && ts.forEach(node.arguments, containsYield)) {
71991                 var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion, true), target = _a.target, thisArg = _a.thisArg;
71992                 return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments), node), node);
71993             }
71994             return ts.visitEachChild(node, visitor, context);
71995         }
71996         function visitNewExpression(node) {
71997             if (ts.forEach(node.arguments, containsYield)) {
71998                 var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
71999                 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);
72000             }
72001             return ts.visitEachChild(node, visitor, context);
72002         }
72003         function transformAndEmitStatements(statements, start) {
72004             if (start === void 0) { start = 0; }
72005             var numStatements = statements.length;
72006             for (var i = start; i < numStatements; i++) {
72007                 transformAndEmitStatement(statements[i]);
72008             }
72009         }
72010         function transformAndEmitEmbeddedStatement(node) {
72011             if (ts.isBlock(node)) {
72012                 transformAndEmitStatements(node.statements);
72013             }
72014             else {
72015                 transformAndEmitStatement(node);
72016             }
72017         }
72018         function transformAndEmitStatement(node) {
72019             var savedInStatementContainingYield = inStatementContainingYield;
72020             if (!inStatementContainingYield) {
72021                 inStatementContainingYield = containsYield(node);
72022             }
72023             transformAndEmitStatementWorker(node);
72024             inStatementContainingYield = savedInStatementContainingYield;
72025         }
72026         function transformAndEmitStatementWorker(node) {
72027             switch (node.kind) {
72028                 case 223:
72029                     return transformAndEmitBlock(node);
72030                 case 226:
72031                     return transformAndEmitExpressionStatement(node);
72032                 case 227:
72033                     return transformAndEmitIfStatement(node);
72034                 case 228:
72035                     return transformAndEmitDoStatement(node);
72036                 case 229:
72037                     return transformAndEmitWhileStatement(node);
72038                 case 230:
72039                     return transformAndEmitForStatement(node);
72040                 case 231:
72041                     return transformAndEmitForInStatement(node);
72042                 case 233:
72043                     return transformAndEmitContinueStatement(node);
72044                 case 234:
72045                     return transformAndEmitBreakStatement(node);
72046                 case 235:
72047                     return transformAndEmitReturnStatement(node);
72048                 case 236:
72049                     return transformAndEmitWithStatement(node);
72050                 case 237:
72051                     return transformAndEmitSwitchStatement(node);
72052                 case 238:
72053                     return transformAndEmitLabeledStatement(node);
72054                 case 239:
72055                     return transformAndEmitThrowStatement(node);
72056                 case 240:
72057                     return transformAndEmitTryStatement(node);
72058                 default:
72059                     return emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72060             }
72061         }
72062         function transformAndEmitBlock(node) {
72063             if (containsYield(node)) {
72064                 transformAndEmitStatements(node.statements);
72065             }
72066             else {
72067                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72068             }
72069         }
72070         function transformAndEmitExpressionStatement(node) {
72071             emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72072         }
72073         function transformAndEmitVariableDeclarationList(node) {
72074             for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) {
72075                 var variable = _a[_i];
72076                 var name = ts.getSynthesizedClone(variable.name);
72077                 ts.setCommentRange(name, variable.name);
72078                 hoistVariableDeclaration(name);
72079             }
72080             var variables = ts.getInitializedVariables(node);
72081             var numVariables = variables.length;
72082             var variablesWritten = 0;
72083             var pendingExpressions = [];
72084             while (variablesWritten < numVariables) {
72085                 for (var i = variablesWritten; i < numVariables; i++) {
72086                     var variable = variables[i];
72087                     if (containsYield(variable.initializer) && pendingExpressions.length > 0) {
72088                         break;
72089                     }
72090                     pendingExpressions.push(transformInitializedVariable(variable));
72091                 }
72092                 if (pendingExpressions.length) {
72093                     emitStatement(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions)));
72094                     variablesWritten += pendingExpressions.length;
72095                     pendingExpressions = [];
72096                 }
72097             }
72098             return undefined;
72099         }
72100         function transformInitializedVariable(node) {
72101             return ts.setSourceMapRange(ts.createAssignment(ts.setSourceMapRange(ts.getSynthesizedClone(node.name), node.name), ts.visitNode(node.initializer, visitor, ts.isExpression)), node);
72102         }
72103         function transformAndEmitIfStatement(node) {
72104             if (containsYield(node)) {
72105                 if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) {
72106                     var endLabel = defineLabel();
72107                     var elseLabel = node.elseStatement ? defineLabel() : undefined;
72108                     emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression), node.expression);
72109                     transformAndEmitEmbeddedStatement(node.thenStatement);
72110                     if (node.elseStatement) {
72111                         emitBreak(endLabel);
72112                         markLabel(elseLabel);
72113                         transformAndEmitEmbeddedStatement(node.elseStatement);
72114                     }
72115                     markLabel(endLabel);
72116                 }
72117                 else {
72118                     emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72119                 }
72120             }
72121             else {
72122                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72123             }
72124         }
72125         function transformAndEmitDoStatement(node) {
72126             if (containsYield(node)) {
72127                 var conditionLabel = defineLabel();
72128                 var loopLabel = defineLabel();
72129                 beginLoopBlock(conditionLabel);
72130                 markLabel(loopLabel);
72131                 transformAndEmitEmbeddedStatement(node.statement);
72132                 markLabel(conditionLabel);
72133                 emitBreakWhenTrue(loopLabel, ts.visitNode(node.expression, visitor, ts.isExpression));
72134                 endLoopBlock();
72135             }
72136             else {
72137                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72138             }
72139         }
72140         function visitDoStatement(node) {
72141             if (inStatementContainingYield) {
72142                 beginScriptLoopBlock();
72143                 node = ts.visitEachChild(node, visitor, context);
72144                 endLoopBlock();
72145                 return node;
72146             }
72147             else {
72148                 return ts.visitEachChild(node, visitor, context);
72149             }
72150         }
72151         function transformAndEmitWhileStatement(node) {
72152             if (containsYield(node)) {
72153                 var loopLabel = defineLabel();
72154                 var endLabel = beginLoopBlock(loopLabel);
72155                 markLabel(loopLabel);
72156                 emitBreakWhenFalse(endLabel, ts.visitNode(node.expression, visitor, ts.isExpression));
72157                 transformAndEmitEmbeddedStatement(node.statement);
72158                 emitBreak(loopLabel);
72159                 endLoopBlock();
72160             }
72161             else {
72162                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72163             }
72164         }
72165         function visitWhileStatement(node) {
72166             if (inStatementContainingYield) {
72167                 beginScriptLoopBlock();
72168                 node = ts.visitEachChild(node, visitor, context);
72169                 endLoopBlock();
72170                 return node;
72171             }
72172             else {
72173                 return ts.visitEachChild(node, visitor, context);
72174             }
72175         }
72176         function transformAndEmitForStatement(node) {
72177             if (containsYield(node)) {
72178                 var conditionLabel = defineLabel();
72179                 var incrementLabel = defineLabel();
72180                 var endLabel = beginLoopBlock(incrementLabel);
72181                 if (node.initializer) {
72182                     var initializer = node.initializer;
72183                     if (ts.isVariableDeclarationList(initializer)) {
72184                         transformAndEmitVariableDeclarationList(initializer);
72185                     }
72186                     else {
72187                         emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer));
72188                     }
72189                 }
72190                 markLabel(conditionLabel);
72191                 if (node.condition) {
72192                     emitBreakWhenFalse(endLabel, ts.visitNode(node.condition, visitor, ts.isExpression));
72193                 }
72194                 transformAndEmitEmbeddedStatement(node.statement);
72195                 markLabel(incrementLabel);
72196                 if (node.incrementor) {
72197                     emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor));
72198                 }
72199                 emitBreak(conditionLabel);
72200                 endLoopBlock();
72201             }
72202             else {
72203                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72204             }
72205         }
72206         function visitForStatement(node) {
72207             if (inStatementContainingYield) {
72208                 beginScriptLoopBlock();
72209             }
72210             var initializer = node.initializer;
72211             if (initializer && ts.isVariableDeclarationList(initializer)) {
72212                 for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
72213                     var variable = _a[_i];
72214                     hoistVariableDeclaration(variable.name);
72215                 }
72216                 var variables = ts.getInitializedVariables(initializer);
72217                 node = ts.updateFor(node, variables.length > 0
72218                     ? ts.inlineExpressions(ts.map(variables, transformInitializedVariable))
72219                     : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
72220             }
72221             else {
72222                 node = ts.visitEachChild(node, visitor, context);
72223             }
72224             if (inStatementContainingYield) {
72225                 endLoopBlock();
72226             }
72227             return node;
72228         }
72229         function transformAndEmitForInStatement(node) {
72230             if (containsYield(node)) {
72231                 var keysArray = declareLocal();
72232                 var key = declareLocal();
72233                 var keysIndex = ts.createLoopVariable();
72234                 var initializer = node.initializer;
72235                 hoistVariableDeclaration(keysIndex);
72236                 emitAssignment(keysArray, ts.createArrayLiteral());
72237                 emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), undefined, [key]))));
72238                 emitAssignment(keysIndex, ts.createLiteral(0));
72239                 var conditionLabel = defineLabel();
72240                 var incrementLabel = defineLabel();
72241                 var endLabel = beginLoopBlock(incrementLabel);
72242                 markLabel(conditionLabel);
72243                 emitBreakWhenFalse(endLabel, ts.createLessThan(keysIndex, ts.createPropertyAccess(keysArray, "length")));
72244                 var variable = void 0;
72245                 if (ts.isVariableDeclarationList(initializer)) {
72246                     for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
72247                         var variable_1 = _a[_i];
72248                         hoistVariableDeclaration(variable_1.name);
72249                     }
72250                     variable = ts.getSynthesizedClone(initializer.declarations[0].name);
72251                 }
72252                 else {
72253                     variable = ts.visitNode(initializer, visitor, ts.isExpression);
72254                     ts.Debug.assert(ts.isLeftHandSideExpression(variable));
72255                 }
72256                 emitAssignment(variable, ts.createElementAccess(keysArray, keysIndex));
72257                 transformAndEmitEmbeddedStatement(node.statement);
72258                 markLabel(incrementLabel);
72259                 emitStatement(ts.createExpressionStatement(ts.createPostfixIncrement(keysIndex)));
72260                 emitBreak(conditionLabel);
72261                 endLoopBlock();
72262             }
72263             else {
72264                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72265             }
72266         }
72267         function visitForInStatement(node) {
72268             if (inStatementContainingYield) {
72269                 beginScriptLoopBlock();
72270             }
72271             var initializer = node.initializer;
72272             if (ts.isVariableDeclarationList(initializer)) {
72273                 for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
72274                     var variable = _a[_i];
72275                     hoistVariableDeclaration(variable.name);
72276                 }
72277                 node = ts.updateForIn(node, initializer.declarations[0].name, ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
72278             }
72279             else {
72280                 node = ts.visitEachChild(node, visitor, context);
72281             }
72282             if (inStatementContainingYield) {
72283                 endLoopBlock();
72284             }
72285             return node;
72286         }
72287         function transformAndEmitContinueStatement(node) {
72288             var label = findContinueTarget(node.label ? ts.idText(node.label) : undefined);
72289             if (label > 0) {
72290                 emitBreak(label, node);
72291             }
72292             else {
72293                 emitStatement(node);
72294             }
72295         }
72296         function visitContinueStatement(node) {
72297             if (inStatementContainingYield) {
72298                 var label = findContinueTarget(node.label && ts.idText(node.label));
72299                 if (label > 0) {
72300                     return createInlineBreak(label, node);
72301                 }
72302             }
72303             return ts.visitEachChild(node, visitor, context);
72304         }
72305         function transformAndEmitBreakStatement(node) {
72306             var label = findBreakTarget(node.label ? ts.idText(node.label) : undefined);
72307             if (label > 0) {
72308                 emitBreak(label, node);
72309             }
72310             else {
72311                 emitStatement(node);
72312             }
72313         }
72314         function visitBreakStatement(node) {
72315             if (inStatementContainingYield) {
72316                 var label = findBreakTarget(node.label && ts.idText(node.label));
72317                 if (label > 0) {
72318                     return createInlineBreak(label, node);
72319                 }
72320             }
72321             return ts.visitEachChild(node, visitor, context);
72322         }
72323         function transformAndEmitReturnStatement(node) {
72324             emitReturn(ts.visitNode(node.expression, visitor, ts.isExpression), node);
72325         }
72326         function visitReturnStatement(node) {
72327             return createInlineReturn(ts.visitNode(node.expression, visitor, ts.isExpression), node);
72328         }
72329         function transformAndEmitWithStatement(node) {
72330             if (containsYield(node)) {
72331                 beginWithBlock(cacheExpression(ts.visitNode(node.expression, visitor, ts.isExpression)));
72332                 transformAndEmitEmbeddedStatement(node.statement);
72333                 endWithBlock();
72334             }
72335             else {
72336                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72337             }
72338         }
72339         function transformAndEmitSwitchStatement(node) {
72340             if (containsYield(node.caseBlock)) {
72341                 var caseBlock = node.caseBlock;
72342                 var numClauses = caseBlock.clauses.length;
72343                 var endLabel = beginSwitchBlock();
72344                 var expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isExpression));
72345                 var clauseLabels = [];
72346                 var defaultClauseIndex = -1;
72347                 for (var i = 0; i < numClauses; i++) {
72348                     var clause = caseBlock.clauses[i];
72349                     clauseLabels.push(defineLabel());
72350                     if (clause.kind === 278 && defaultClauseIndex === -1) {
72351                         defaultClauseIndex = i;
72352                     }
72353                 }
72354                 var clausesWritten = 0;
72355                 var pendingClauses = [];
72356                 while (clausesWritten < numClauses) {
72357                     var defaultClausesSkipped = 0;
72358                     for (var i = clausesWritten; i < numClauses; i++) {
72359                         var clause = caseBlock.clauses[i];
72360                         if (clause.kind === 277) {
72361                             if (containsYield(clause.expression) && pendingClauses.length > 0) {
72362                                 break;
72363                             }
72364                             pendingClauses.push(ts.createCaseClause(ts.visitNode(clause.expression, visitor, ts.isExpression), [
72365                                 createInlineBreak(clauseLabels[i], clause.expression)
72366                             ]));
72367                         }
72368                         else {
72369                             defaultClausesSkipped++;
72370                         }
72371                     }
72372                     if (pendingClauses.length) {
72373                         emitStatement(ts.createSwitch(expression, ts.createCaseBlock(pendingClauses)));
72374                         clausesWritten += pendingClauses.length;
72375                         pendingClauses = [];
72376                     }
72377                     if (defaultClausesSkipped > 0) {
72378                         clausesWritten += defaultClausesSkipped;
72379                         defaultClausesSkipped = 0;
72380                     }
72381                 }
72382                 if (defaultClauseIndex >= 0) {
72383                     emitBreak(clauseLabels[defaultClauseIndex]);
72384                 }
72385                 else {
72386                     emitBreak(endLabel);
72387                 }
72388                 for (var i = 0; i < numClauses; i++) {
72389                     markLabel(clauseLabels[i]);
72390                     transformAndEmitStatements(caseBlock.clauses[i].statements);
72391                 }
72392                 endSwitchBlock();
72393             }
72394             else {
72395                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72396             }
72397         }
72398         function visitSwitchStatement(node) {
72399             if (inStatementContainingYield) {
72400                 beginScriptSwitchBlock();
72401             }
72402             node = ts.visitEachChild(node, visitor, context);
72403             if (inStatementContainingYield) {
72404                 endSwitchBlock();
72405             }
72406             return node;
72407         }
72408         function transformAndEmitLabeledStatement(node) {
72409             if (containsYield(node)) {
72410                 beginLabeledBlock(ts.idText(node.label));
72411                 transformAndEmitEmbeddedStatement(node.statement);
72412                 endLabeledBlock();
72413             }
72414             else {
72415                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72416             }
72417         }
72418         function visitLabeledStatement(node) {
72419             if (inStatementContainingYield) {
72420                 beginScriptLabeledBlock(ts.idText(node.label));
72421             }
72422             node = ts.visitEachChild(node, visitor, context);
72423             if (inStatementContainingYield) {
72424                 endLabeledBlock();
72425             }
72426             return node;
72427         }
72428         function transformAndEmitThrowStatement(node) {
72429             emitThrow(ts.visitNode(node.expression, visitor, ts.isExpression), node);
72430         }
72431         function transformAndEmitTryStatement(node) {
72432             if (containsYield(node)) {
72433                 beginExceptionBlock();
72434                 transformAndEmitEmbeddedStatement(node.tryBlock);
72435                 if (node.catchClause) {
72436                     beginCatchBlock(node.catchClause.variableDeclaration);
72437                     transformAndEmitEmbeddedStatement(node.catchClause.block);
72438                 }
72439                 if (node.finallyBlock) {
72440                     beginFinallyBlock();
72441                     transformAndEmitEmbeddedStatement(node.finallyBlock);
72442                 }
72443                 endExceptionBlock();
72444             }
72445             else {
72446                 emitStatement(ts.visitEachChild(node, visitor, context));
72447             }
72448         }
72449         function containsYield(node) {
72450             return !!node && (node.transformFlags & 262144) !== 0;
72451         }
72452         function countInitialNodesWithoutYield(nodes) {
72453             var numNodes = nodes.length;
72454             for (var i = 0; i < numNodes; i++) {
72455                 if (containsYield(nodes[i])) {
72456                     return i;
72457                 }
72458             }
72459             return -1;
72460         }
72461         function onSubstituteNode(hint, node) {
72462             node = previousOnSubstituteNode(hint, node);
72463             if (hint === 1) {
72464                 return substituteExpression(node);
72465             }
72466             return node;
72467         }
72468         function substituteExpression(node) {
72469             if (ts.isIdentifier(node)) {
72470                 return substituteExpressionIdentifier(node);
72471             }
72472             return node;
72473         }
72474         function substituteExpressionIdentifier(node) {
72475             if (!ts.isGeneratedIdentifier(node) && renamedCatchVariables && renamedCatchVariables.has(ts.idText(node))) {
72476                 var original = ts.getOriginalNode(node);
72477                 if (ts.isIdentifier(original) && original.parent) {
72478                     var declaration = resolver.getReferencedValueDeclaration(original);
72479                     if (declaration) {
72480                         var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)];
72481                         if (name) {
72482                             var clone_8 = ts.getMutableClone(name);
72483                             ts.setSourceMapRange(clone_8, node);
72484                             ts.setCommentRange(clone_8, node);
72485                             return clone_8;
72486                         }
72487                     }
72488                 }
72489             }
72490             return node;
72491         }
72492         function cacheExpression(node) {
72493             if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096) {
72494                 return node;
72495             }
72496             var temp = ts.createTempVariable(hoistVariableDeclaration);
72497             emitAssignment(temp, node, node);
72498             return temp;
72499         }
72500         function declareLocal(name) {
72501             var temp = name
72502                 ? ts.createUniqueName(name)
72503                 : ts.createTempVariable(undefined);
72504             hoistVariableDeclaration(temp);
72505             return temp;
72506         }
72507         function defineLabel() {
72508             if (!labelOffsets) {
72509                 labelOffsets = [];
72510             }
72511             var label = nextLabelId;
72512             nextLabelId++;
72513             labelOffsets[label] = -1;
72514             return label;
72515         }
72516         function markLabel(label) {
72517             ts.Debug.assert(labelOffsets !== undefined, "No labels were defined.");
72518             labelOffsets[label] = operations ? operations.length : 0;
72519         }
72520         function beginBlock(block) {
72521             if (!blocks) {
72522                 blocks = [];
72523                 blockActions = [];
72524                 blockOffsets = [];
72525                 blockStack = [];
72526             }
72527             var index = blockActions.length;
72528             blockActions[index] = 0;
72529             blockOffsets[index] = operations ? operations.length : 0;
72530             blocks[index] = block;
72531             blockStack.push(block);
72532             return index;
72533         }
72534         function endBlock() {
72535             var block = peekBlock();
72536             if (block === undefined)
72537                 return ts.Debug.fail("beginBlock was never called.");
72538             var index = blockActions.length;
72539             blockActions[index] = 1;
72540             blockOffsets[index] = operations ? operations.length : 0;
72541             blocks[index] = block;
72542             blockStack.pop();
72543             return block;
72544         }
72545         function peekBlock() {
72546             return ts.lastOrUndefined(blockStack);
72547         }
72548         function peekBlockKind() {
72549             var block = peekBlock();
72550             return block && block.kind;
72551         }
72552         function beginWithBlock(expression) {
72553             var startLabel = defineLabel();
72554             var endLabel = defineLabel();
72555             markLabel(startLabel);
72556             beginBlock({
72557                 kind: 1,
72558                 expression: expression,
72559                 startLabel: startLabel,
72560                 endLabel: endLabel
72561             });
72562         }
72563         function endWithBlock() {
72564             ts.Debug.assert(peekBlockKind() === 1);
72565             var block = endBlock();
72566             markLabel(block.endLabel);
72567         }
72568         function beginExceptionBlock() {
72569             var startLabel = defineLabel();
72570             var endLabel = defineLabel();
72571             markLabel(startLabel);
72572             beginBlock({
72573                 kind: 0,
72574                 state: 0,
72575                 startLabel: startLabel,
72576                 endLabel: endLabel
72577             });
72578             emitNop();
72579             return endLabel;
72580         }
72581         function beginCatchBlock(variable) {
72582             ts.Debug.assert(peekBlockKind() === 0);
72583             var name;
72584             if (ts.isGeneratedIdentifier(variable.name)) {
72585                 name = variable.name;
72586                 hoistVariableDeclaration(variable.name);
72587             }
72588             else {
72589                 var text = ts.idText(variable.name);
72590                 name = declareLocal(text);
72591                 if (!renamedCatchVariables) {
72592                     renamedCatchVariables = ts.createMap();
72593                     renamedCatchVariableDeclarations = [];
72594                     context.enableSubstitution(75);
72595                 }
72596                 renamedCatchVariables.set(text, true);
72597                 renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name;
72598             }
72599             var exception = peekBlock();
72600             ts.Debug.assert(exception.state < 1);
72601             var endLabel = exception.endLabel;
72602             emitBreak(endLabel);
72603             var catchLabel = defineLabel();
72604             markLabel(catchLabel);
72605             exception.state = 1;
72606             exception.catchVariable = name;
72607             exception.catchLabel = catchLabel;
72608             emitAssignment(name, ts.createCall(ts.createPropertyAccess(state, "sent"), undefined, []));
72609             emitNop();
72610         }
72611         function beginFinallyBlock() {
72612             ts.Debug.assert(peekBlockKind() === 0);
72613             var exception = peekBlock();
72614             ts.Debug.assert(exception.state < 2);
72615             var endLabel = exception.endLabel;
72616             emitBreak(endLabel);
72617             var finallyLabel = defineLabel();
72618             markLabel(finallyLabel);
72619             exception.state = 2;
72620             exception.finallyLabel = finallyLabel;
72621         }
72622         function endExceptionBlock() {
72623             ts.Debug.assert(peekBlockKind() === 0);
72624             var exception = endBlock();
72625             var state = exception.state;
72626             if (state < 2) {
72627                 emitBreak(exception.endLabel);
72628             }
72629             else {
72630                 emitEndfinally();
72631             }
72632             markLabel(exception.endLabel);
72633             emitNop();
72634             exception.state = 3;
72635         }
72636         function beginScriptLoopBlock() {
72637             beginBlock({
72638                 kind: 3,
72639                 isScript: true,
72640                 breakLabel: -1,
72641                 continueLabel: -1
72642             });
72643         }
72644         function beginLoopBlock(continueLabel) {
72645             var breakLabel = defineLabel();
72646             beginBlock({
72647                 kind: 3,
72648                 isScript: false,
72649                 breakLabel: breakLabel,
72650                 continueLabel: continueLabel,
72651             });
72652             return breakLabel;
72653         }
72654         function endLoopBlock() {
72655             ts.Debug.assert(peekBlockKind() === 3);
72656             var block = endBlock();
72657             var breakLabel = block.breakLabel;
72658             if (!block.isScript) {
72659                 markLabel(breakLabel);
72660             }
72661         }
72662         function beginScriptSwitchBlock() {
72663             beginBlock({
72664                 kind: 2,
72665                 isScript: true,
72666                 breakLabel: -1
72667             });
72668         }
72669         function beginSwitchBlock() {
72670             var breakLabel = defineLabel();
72671             beginBlock({
72672                 kind: 2,
72673                 isScript: false,
72674                 breakLabel: breakLabel,
72675             });
72676             return breakLabel;
72677         }
72678         function endSwitchBlock() {
72679             ts.Debug.assert(peekBlockKind() === 2);
72680             var block = endBlock();
72681             var breakLabel = block.breakLabel;
72682             if (!block.isScript) {
72683                 markLabel(breakLabel);
72684             }
72685         }
72686         function beginScriptLabeledBlock(labelText) {
72687             beginBlock({
72688                 kind: 4,
72689                 isScript: true,
72690                 labelText: labelText,
72691                 breakLabel: -1
72692             });
72693         }
72694         function beginLabeledBlock(labelText) {
72695             var breakLabel = defineLabel();
72696             beginBlock({
72697                 kind: 4,
72698                 isScript: false,
72699                 labelText: labelText,
72700                 breakLabel: breakLabel
72701             });
72702         }
72703         function endLabeledBlock() {
72704             ts.Debug.assert(peekBlockKind() === 4);
72705             var block = endBlock();
72706             if (!block.isScript) {
72707                 markLabel(block.breakLabel);
72708             }
72709         }
72710         function supportsUnlabeledBreak(block) {
72711             return block.kind === 2
72712                 || block.kind === 3;
72713         }
72714         function supportsLabeledBreakOrContinue(block) {
72715             return block.kind === 4;
72716         }
72717         function supportsUnlabeledContinue(block) {
72718             return block.kind === 3;
72719         }
72720         function hasImmediateContainingLabeledBlock(labelText, start) {
72721             for (var j = start; j >= 0; j--) {
72722                 var containingBlock = blockStack[j];
72723                 if (supportsLabeledBreakOrContinue(containingBlock)) {
72724                     if (containingBlock.labelText === labelText) {
72725                         return true;
72726                     }
72727                 }
72728                 else {
72729                     break;
72730                 }
72731             }
72732             return false;
72733         }
72734         function findBreakTarget(labelText) {
72735             if (blockStack) {
72736                 if (labelText) {
72737                     for (var i = blockStack.length - 1; i >= 0; i--) {
72738                         var block = blockStack[i];
72739                         if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) {
72740                             return block.breakLabel;
72741                         }
72742                         else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) {
72743                             return block.breakLabel;
72744                         }
72745                     }
72746                 }
72747                 else {
72748                     for (var i = blockStack.length - 1; i >= 0; i--) {
72749                         var block = blockStack[i];
72750                         if (supportsUnlabeledBreak(block)) {
72751                             return block.breakLabel;
72752                         }
72753                     }
72754                 }
72755             }
72756             return 0;
72757         }
72758         function findContinueTarget(labelText) {
72759             if (blockStack) {
72760                 if (labelText) {
72761                     for (var i = blockStack.length - 1; i >= 0; i--) {
72762                         var block = blockStack[i];
72763                         if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) {
72764                             return block.continueLabel;
72765                         }
72766                     }
72767                 }
72768                 else {
72769                     for (var i = blockStack.length - 1; i >= 0; i--) {
72770                         var block = blockStack[i];
72771                         if (supportsUnlabeledContinue(block)) {
72772                             return block.continueLabel;
72773                         }
72774                     }
72775                 }
72776             }
72777             return 0;
72778         }
72779         function createLabel(label) {
72780             if (label !== undefined && label > 0) {
72781                 if (labelExpressions === undefined) {
72782                     labelExpressions = [];
72783                 }
72784                 var expression = ts.createLiteral(-1);
72785                 if (labelExpressions[label] === undefined) {
72786                     labelExpressions[label] = [expression];
72787                 }
72788                 else {
72789                     labelExpressions[label].push(expression);
72790                 }
72791                 return expression;
72792             }
72793             return ts.createOmittedExpression();
72794         }
72795         function createInstruction(instruction) {
72796             var literal = ts.createLiteral(instruction);
72797             ts.addSyntheticTrailingComment(literal, 3, getInstructionName(instruction));
72798             return literal;
72799         }
72800         function createInlineBreak(label, location) {
72801             ts.Debug.assertLessThan(0, label, "Invalid label");
72802             return ts.setTextRange(ts.createReturn(ts.createArrayLiteral([
72803                 createInstruction(3),
72804                 createLabel(label)
72805             ])), location);
72806         }
72807         function createInlineReturn(expression, location) {
72808             return ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression
72809                 ? [createInstruction(2), expression]
72810                 : [createInstruction(2)])), location);
72811         }
72812         function createGeneratorResume(location) {
72813             return ts.setTextRange(ts.createCall(ts.createPropertyAccess(state, "sent"), undefined, []), location);
72814         }
72815         function emitNop() {
72816             emitWorker(0);
72817         }
72818         function emitStatement(node) {
72819             if (node) {
72820                 emitWorker(1, [node]);
72821             }
72822             else {
72823                 emitNop();
72824             }
72825         }
72826         function emitAssignment(left, right, location) {
72827             emitWorker(2, [left, right], location);
72828         }
72829         function emitBreak(label, location) {
72830             emitWorker(3, [label], location);
72831         }
72832         function emitBreakWhenTrue(label, condition, location) {
72833             emitWorker(4, [label, condition], location);
72834         }
72835         function emitBreakWhenFalse(label, condition, location) {
72836             emitWorker(5, [label, condition], location);
72837         }
72838         function emitYieldStar(expression, location) {
72839             emitWorker(7, [expression], location);
72840         }
72841         function emitYield(expression, location) {
72842             emitWorker(6, [expression], location);
72843         }
72844         function emitReturn(expression, location) {
72845             emitWorker(8, [expression], location);
72846         }
72847         function emitThrow(expression, location) {
72848             emitWorker(9, [expression], location);
72849         }
72850         function emitEndfinally() {
72851             emitWorker(10);
72852         }
72853         function emitWorker(code, args, location) {
72854             if (operations === undefined) {
72855                 operations = [];
72856                 operationArguments = [];
72857                 operationLocations = [];
72858             }
72859             if (labelOffsets === undefined) {
72860                 markLabel(defineLabel());
72861             }
72862             var operationIndex = operations.length;
72863             operations[operationIndex] = code;
72864             operationArguments[operationIndex] = args;
72865             operationLocations[operationIndex] = location;
72866         }
72867         function build() {
72868             blockIndex = 0;
72869             labelNumber = 0;
72870             labelNumbers = undefined;
72871             lastOperationWasAbrupt = false;
72872             lastOperationWasCompletion = false;
72873             clauses = undefined;
72874             statements = undefined;
72875             exceptionBlockStack = undefined;
72876             currentExceptionBlock = undefined;
72877             withBlockStack = undefined;
72878             var buildResult = buildStatements();
72879             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));
72880         }
72881         function buildStatements() {
72882             if (operations) {
72883                 for (var operationIndex = 0; operationIndex < operations.length; operationIndex++) {
72884                     writeOperation(operationIndex);
72885                 }
72886                 flushFinalLabel(operations.length);
72887             }
72888             else {
72889                 flushFinalLabel(0);
72890             }
72891             if (clauses) {
72892                 var labelExpression = ts.createPropertyAccess(state, "label");
72893                 var switchStatement = ts.createSwitch(labelExpression, ts.createCaseBlock(clauses));
72894                 return [ts.startOnNewLine(switchStatement)];
72895             }
72896             if (statements) {
72897                 return statements;
72898             }
72899             return [];
72900         }
72901         function flushLabel() {
72902             if (!statements) {
72903                 return;
72904             }
72905             appendLabel(!lastOperationWasAbrupt);
72906             lastOperationWasAbrupt = false;
72907             lastOperationWasCompletion = false;
72908             labelNumber++;
72909         }
72910         function flushFinalLabel(operationIndex) {
72911             if (isFinalLabelReachable(operationIndex)) {
72912                 tryEnterLabel(operationIndex);
72913                 withBlockStack = undefined;
72914                 writeReturn(undefined, undefined);
72915             }
72916             if (statements && clauses) {
72917                 appendLabel(false);
72918             }
72919             updateLabelExpressions();
72920         }
72921         function isFinalLabelReachable(operationIndex) {
72922             if (!lastOperationWasCompletion) {
72923                 return true;
72924             }
72925             if (!labelOffsets || !labelExpressions) {
72926                 return false;
72927             }
72928             for (var label = 0; label < labelOffsets.length; label++) {
72929                 if (labelOffsets[label] === operationIndex && labelExpressions[label]) {
72930                     return true;
72931                 }
72932             }
72933             return false;
72934         }
72935         function appendLabel(markLabelEnd) {
72936             if (!clauses) {
72937                 clauses = [];
72938             }
72939             if (statements) {
72940                 if (withBlockStack) {
72941                     for (var i = withBlockStack.length - 1; i >= 0; i--) {
72942                         var withBlock = withBlockStack[i];
72943                         statements = [ts.createWith(withBlock.expression, ts.createBlock(statements))];
72944                     }
72945                 }
72946                 if (currentExceptionBlock) {
72947                     var startLabel = currentExceptionBlock.startLabel, catchLabel = currentExceptionBlock.catchLabel, finallyLabel = currentExceptionBlock.finallyLabel, endLabel = currentExceptionBlock.endLabel;
72948                     statements.unshift(ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), undefined, [
72949                         ts.createArrayLiteral([
72950                             createLabel(startLabel),
72951                             createLabel(catchLabel),
72952                             createLabel(finallyLabel),
72953                             createLabel(endLabel)
72954                         ])
72955                     ])));
72956                     currentExceptionBlock = undefined;
72957                 }
72958                 if (markLabelEnd) {
72959                     statements.push(ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1))));
72960                 }
72961             }
72962             clauses.push(ts.createCaseClause(ts.createLiteral(labelNumber), statements || []));
72963             statements = undefined;
72964         }
72965         function tryEnterLabel(operationIndex) {
72966             if (!labelOffsets) {
72967                 return;
72968             }
72969             for (var label = 0; label < labelOffsets.length; label++) {
72970                 if (labelOffsets[label] === operationIndex) {
72971                     flushLabel();
72972                     if (labelNumbers === undefined) {
72973                         labelNumbers = [];
72974                     }
72975                     if (labelNumbers[labelNumber] === undefined) {
72976                         labelNumbers[labelNumber] = [label];
72977                     }
72978                     else {
72979                         labelNumbers[labelNumber].push(label);
72980                     }
72981                 }
72982             }
72983         }
72984         function updateLabelExpressions() {
72985             if (labelExpressions !== undefined && labelNumbers !== undefined) {
72986                 for (var labelNumber_1 = 0; labelNumber_1 < labelNumbers.length; labelNumber_1++) {
72987                     var labels = labelNumbers[labelNumber_1];
72988                     if (labels !== undefined) {
72989                         for (var _i = 0, labels_1 = labels; _i < labels_1.length; _i++) {
72990                             var label = labels_1[_i];
72991                             var expressions = labelExpressions[label];
72992                             if (expressions !== undefined) {
72993                                 for (var _a = 0, expressions_1 = expressions; _a < expressions_1.length; _a++) {
72994                                     var expression = expressions_1[_a];
72995                                     expression.text = String(labelNumber_1);
72996                                 }
72997                             }
72998                         }
72999                     }
73000                 }
73001             }
73002         }
73003         function tryEnterOrLeaveBlock(operationIndex) {
73004             if (blocks) {
73005                 for (; blockIndex < blockActions.length && blockOffsets[blockIndex] <= operationIndex; blockIndex++) {
73006                     var block = blocks[blockIndex];
73007                     var blockAction = blockActions[blockIndex];
73008                     switch (block.kind) {
73009                         case 0:
73010                             if (blockAction === 0) {
73011                                 if (!exceptionBlockStack) {
73012                                     exceptionBlockStack = [];
73013                                 }
73014                                 if (!statements) {
73015                                     statements = [];
73016                                 }
73017                                 exceptionBlockStack.push(currentExceptionBlock);
73018                                 currentExceptionBlock = block;
73019                             }
73020                             else if (blockAction === 1) {
73021                                 currentExceptionBlock = exceptionBlockStack.pop();
73022                             }
73023                             break;
73024                         case 1:
73025                             if (blockAction === 0) {
73026                                 if (!withBlockStack) {
73027                                     withBlockStack = [];
73028                                 }
73029                                 withBlockStack.push(block);
73030                             }
73031                             else if (blockAction === 1) {
73032                                 withBlockStack.pop();
73033                             }
73034                             break;
73035                     }
73036                 }
73037             }
73038         }
73039         function writeOperation(operationIndex) {
73040             tryEnterLabel(operationIndex);
73041             tryEnterOrLeaveBlock(operationIndex);
73042             if (lastOperationWasAbrupt) {
73043                 return;
73044             }
73045             lastOperationWasAbrupt = false;
73046             lastOperationWasCompletion = false;
73047             var opcode = operations[operationIndex];
73048             if (opcode === 0) {
73049                 return;
73050             }
73051             else if (opcode === 10) {
73052                 return writeEndfinally();
73053             }
73054             var args = operationArguments[operationIndex];
73055             if (opcode === 1) {
73056                 return writeStatement(args[0]);
73057             }
73058             var location = operationLocations[operationIndex];
73059             switch (opcode) {
73060                 case 2:
73061                     return writeAssign(args[0], args[1], location);
73062                 case 3:
73063                     return writeBreak(args[0], location);
73064                 case 4:
73065                     return writeBreakWhenTrue(args[0], args[1], location);
73066                 case 5:
73067                     return writeBreakWhenFalse(args[0], args[1], location);
73068                 case 6:
73069                     return writeYield(args[0], location);
73070                 case 7:
73071                     return writeYieldStar(args[0], location);
73072                 case 8:
73073                     return writeReturn(args[0], location);
73074                 case 9:
73075                     return writeThrow(args[0], location);
73076             }
73077         }
73078         function writeStatement(statement) {
73079             if (statement) {
73080                 if (!statements) {
73081                     statements = [statement];
73082                 }
73083                 else {
73084                     statements.push(statement);
73085                 }
73086             }
73087         }
73088         function writeAssign(left, right, operationLocation) {
73089             writeStatement(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(left, right)), operationLocation));
73090         }
73091         function writeThrow(expression, operationLocation) {
73092             lastOperationWasAbrupt = true;
73093             lastOperationWasCompletion = true;
73094             writeStatement(ts.setTextRange(ts.createThrow(expression), operationLocation));
73095         }
73096         function writeReturn(expression, operationLocation) {
73097             lastOperationWasAbrupt = true;
73098             lastOperationWasCompletion = true;
73099             writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression
73100                 ? [createInstruction(2), expression]
73101                 : [createInstruction(2)])), operationLocation), 384));
73102         }
73103         function writeBreak(label, operationLocation) {
73104             lastOperationWasAbrupt = true;
73105             writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([
73106                 createInstruction(3),
73107                 createLabel(label)
73108             ])), operationLocation), 384));
73109         }
73110         function writeBreakWhenTrue(label, condition, operationLocation) {
73111             writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([
73112                 createInstruction(3),
73113                 createLabel(label)
73114             ])), operationLocation), 384)), 1));
73115         }
73116         function writeBreakWhenFalse(label, condition, operationLocation) {
73117             writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([
73118                 createInstruction(3),
73119                 createLabel(label)
73120             ])), operationLocation), 384)), 1));
73121         }
73122         function writeYield(expression, operationLocation) {
73123             lastOperationWasAbrupt = true;
73124             writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression
73125                 ? [createInstruction(4), expression]
73126                 : [createInstruction(4)])), operationLocation), 384));
73127         }
73128         function writeYieldStar(expression, operationLocation) {
73129             lastOperationWasAbrupt = true;
73130             writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([
73131                 createInstruction(5),
73132                 expression
73133             ])), operationLocation), 384));
73134         }
73135         function writeEndfinally() {
73136             lastOperationWasAbrupt = true;
73137             writeStatement(ts.createReturn(ts.createArrayLiteral([
73138                 createInstruction(7)
73139             ])));
73140         }
73141     }
73142     ts.transformGenerators = transformGenerators;
73143     function createGeneratorHelper(context, body) {
73144         context.requestEmitHelper(ts.generatorHelper);
73145         return ts.createCall(ts.getUnscopedHelperName("__generator"), undefined, [ts.createThis(), body]);
73146     }
73147     ts.generatorHelper = {
73148         name: "typescript:generator",
73149         importName: "__generator",
73150         scoped: false,
73151         priority: 6,
73152         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            };"
73153     };
73154 })(ts || (ts = {}));
73155 var ts;
73156 (function (ts) {
73157     function transformModule(context) {
73158         function getTransformModuleDelegate(moduleKind) {
73159             switch (moduleKind) {
73160                 case ts.ModuleKind.AMD: return transformAMDModule;
73161                 case ts.ModuleKind.UMD: return transformUMDModule;
73162                 default: return transformCommonJSModule;
73163             }
73164         }
73165         var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
73166         var compilerOptions = context.getCompilerOptions();
73167         var resolver = context.getEmitResolver();
73168         var host = context.getEmitHost();
73169         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
73170         var moduleKind = ts.getEmitModuleKind(compilerOptions);
73171         var previousOnSubstituteNode = context.onSubstituteNode;
73172         var previousOnEmitNode = context.onEmitNode;
73173         context.onSubstituteNode = onSubstituteNode;
73174         context.onEmitNode = onEmitNode;
73175         context.enableSubstitution(75);
73176         context.enableSubstitution(209);
73177         context.enableSubstitution(207);
73178         context.enableSubstitution(208);
73179         context.enableSubstitution(282);
73180         context.enableEmitNotification(290);
73181         var moduleInfoMap = [];
73182         var deferredExports = [];
73183         var currentSourceFile;
73184         var currentModuleInfo;
73185         var noSubstitution;
73186         var needUMDDynamicImportHelper;
73187         return ts.chainBundle(transformSourceFile);
73188         function transformSourceFile(node) {
73189             if (node.isDeclarationFile ||
73190                 !(ts.isEffectiveExternalModule(node, compilerOptions) ||
73191                     node.transformFlags & 2097152 ||
73192                     (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && (compilerOptions.out || compilerOptions.outFile)))) {
73193                 return node;
73194             }
73195             currentSourceFile = node;
73196             currentModuleInfo = ts.collectExternalModuleInfo(node, resolver, compilerOptions);
73197             moduleInfoMap[ts.getOriginalNodeId(node)] = currentModuleInfo;
73198             var transformModule = getTransformModuleDelegate(moduleKind);
73199             var updated = transformModule(node);
73200             currentSourceFile = undefined;
73201             currentModuleInfo = undefined;
73202             needUMDDynamicImportHelper = false;
73203             return ts.aggregateTransformFlags(updated);
73204         }
73205         function shouldEmitUnderscoreUnderscoreESModule() {
73206             if (!currentModuleInfo.exportEquals && ts.isExternalModule(currentSourceFile)) {
73207                 return true;
73208             }
73209             return false;
73210         }
73211         function transformCommonJSModule(node) {
73212             startLexicalEnvironment();
73213             var statements = [];
73214             var ensureUseStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile));
73215             var statementOffset = ts.addPrologue(statements, node.statements, ensureUseStrict && !ts.isJsonSourceFile(node), sourceElementVisitor);
73216             if (shouldEmitUnderscoreUnderscoreESModule()) {
73217                 ts.append(statements, createUnderscoreUnderscoreESModule());
73218             }
73219             if (ts.length(currentModuleInfo.exportedNames)) {
73220                 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())));
73221             }
73222             ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement));
73223             ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset));
73224             addExportEqualsIfNeeded(statements, false);
73225             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
73226             var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements));
73227             ts.addEmitHelpers(updated, context.readEmitHelpers());
73228             return updated;
73229         }
73230         function transformAMDModule(node) {
73231             var define = ts.createIdentifier("define");
73232             var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions);
73233             var jsonSourceFile = ts.isJsonSourceFile(node) && node;
73234             var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames;
73235             var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([
73236                 ts.createExpressionStatement(ts.createCall(define, undefined, __spreadArrays((moduleName ? [moduleName] : []), [
73237                     ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : __spreadArrays([
73238                         ts.createLiteral("require"),
73239                         ts.createLiteral("exports")
73240                     ], aliasedModuleNames, unaliasedModuleNames)),
73241                     jsonSourceFile ?
73242                         jsonSourceFile.statements.length ? jsonSourceFile.statements[0].expression : ts.createObjectLiteral() :
73243                         ts.createFunctionExpression(undefined, undefined, undefined, undefined, __spreadArrays([
73244                             ts.createParameter(undefined, undefined, undefined, "require"),
73245                             ts.createParameter(undefined, undefined, undefined, "exports")
73246                         ], importAliasNames), undefined, transformAsynchronousModuleBody(node))
73247                 ])))
73248             ]), node.statements));
73249             ts.addEmitHelpers(updated, context.readEmitHelpers());
73250             return updated;
73251         }
73252         function transformUMDModule(node) {
73253             var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames;
73254             var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions);
73255             var umdHeader = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "factory")], undefined, ts.setTextRange(ts.createBlock([
73256                 ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([
73257                     ts.createVariableStatement(undefined, [
73258                         ts.createVariableDeclaration("v", undefined, ts.createCall(ts.createIdentifier("factory"), undefined, [
73259                             ts.createIdentifier("require"),
73260                             ts.createIdentifier("exports")
73261                         ]))
73262                     ]),
73263                     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)
73264                 ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([
73265                     ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), undefined, __spreadArrays((moduleName ? [moduleName] : []), [
73266                         ts.createArrayLiteral(__spreadArrays([
73267                             ts.createLiteral("require"),
73268                             ts.createLiteral("exports")
73269                         ], aliasedModuleNames, unaliasedModuleNames)),
73270                         ts.createIdentifier("factory")
73271                     ])))
73272                 ])))
73273             ], true), undefined));
73274             var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([
73275                 ts.createExpressionStatement(ts.createCall(umdHeader, undefined, [
73276                     ts.createFunctionExpression(undefined, undefined, undefined, undefined, __spreadArrays([
73277                         ts.createParameter(undefined, undefined, undefined, "require"),
73278                         ts.createParameter(undefined, undefined, undefined, "exports")
73279                     ], importAliasNames), undefined, transformAsynchronousModuleBody(node))
73280                 ]))
73281             ]), node.statements));
73282             ts.addEmitHelpers(updated, context.readEmitHelpers());
73283             return updated;
73284         }
73285         function collectAsynchronousDependencies(node, includeNonAmdDependencies) {
73286             var aliasedModuleNames = [];
73287             var unaliasedModuleNames = [];
73288             var importAliasNames = [];
73289             for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) {
73290                 var amdDependency = _a[_i];
73291                 if (amdDependency.name) {
73292                     aliasedModuleNames.push(ts.createLiteral(amdDependency.path));
73293                     importAliasNames.push(ts.createParameter(undefined, undefined, undefined, amdDependency.name));
73294                 }
73295                 else {
73296                     unaliasedModuleNames.push(ts.createLiteral(amdDependency.path));
73297                 }
73298             }
73299             for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) {
73300                 var importNode = _c[_b];
73301                 var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions);
73302                 var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile);
73303                 if (externalModuleName) {
73304                     if (includeNonAmdDependencies && importAliasName) {
73305                         ts.setEmitFlags(importAliasName, 4);
73306                         aliasedModuleNames.push(externalModuleName);
73307                         importAliasNames.push(ts.createParameter(undefined, undefined, undefined, importAliasName));
73308                     }
73309                     else {
73310                         unaliasedModuleNames.push(externalModuleName);
73311                     }
73312                 }
73313             }
73314             return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames };
73315         }
73316         function getAMDImportExpressionForImport(node) {
73317             if (ts.isImportEqualsDeclaration(node) || ts.isExportDeclaration(node) || !ts.getExternalModuleNameLiteral(node, currentSourceFile, host, resolver, compilerOptions)) {
73318                 return undefined;
73319             }
73320             var name = ts.getLocalNameForExternalImport(node, currentSourceFile);
73321             var expr = getHelperExpressionForImport(node, name);
73322             if (expr === name) {
73323                 return undefined;
73324             }
73325             return ts.createExpressionStatement(ts.createAssignment(name, expr));
73326         }
73327         function transformAsynchronousModuleBody(node) {
73328             startLexicalEnvironment();
73329             var statements = [];
73330             var statementOffset = ts.addPrologue(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor);
73331             if (shouldEmitUnderscoreUnderscoreESModule()) {
73332                 ts.append(statements, createUnderscoreUnderscoreESModule());
73333             }
73334             if (ts.length(currentModuleInfo.exportedNames)) {
73335                 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())));
73336             }
73337             ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement));
73338             if (moduleKind === ts.ModuleKind.AMD) {
73339                 ts.addRange(statements, ts.mapDefined(currentModuleInfo.externalImports, getAMDImportExpressionForImport));
73340             }
73341             ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset));
73342             addExportEqualsIfNeeded(statements, true);
73343             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
73344             var body = ts.createBlock(statements, true);
73345             if (needUMDDynamicImportHelper) {
73346                 ts.addEmitHelper(body, dynamicImportUMDHelper);
73347             }
73348             return body;
73349         }
73350         function addExportEqualsIfNeeded(statements, emitAsReturn) {
73351             if (currentModuleInfo.exportEquals) {
73352                 var expressionResult = ts.visitNode(currentModuleInfo.exportEquals.expression, moduleExpressionElementVisitor);
73353                 if (expressionResult) {
73354                     if (emitAsReturn) {
73355                         var statement = ts.createReturn(expressionResult);
73356                         ts.setTextRange(statement, currentModuleInfo.exportEquals);
73357                         ts.setEmitFlags(statement, 384 | 1536);
73358                         statements.push(statement);
73359                     }
73360                     else {
73361                         var statement = ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult));
73362                         ts.setTextRange(statement, currentModuleInfo.exportEquals);
73363                         ts.setEmitFlags(statement, 1536);
73364                         statements.push(statement);
73365                     }
73366                 }
73367             }
73368         }
73369         function sourceElementVisitor(node) {
73370             switch (node.kind) {
73371                 case 254:
73372                     return visitImportDeclaration(node);
73373                 case 253:
73374                     return visitImportEqualsDeclaration(node);
73375                 case 260:
73376                     return visitExportDeclaration(node);
73377                 case 259:
73378                     return visitExportAssignment(node);
73379                 case 225:
73380                     return visitVariableStatement(node);
73381                 case 244:
73382                     return visitFunctionDeclaration(node);
73383                 case 245:
73384                     return visitClassDeclaration(node);
73385                 case 328:
73386                     return visitMergeDeclarationMarker(node);
73387                 case 329:
73388                     return visitEndOfDeclarationMarker(node);
73389                 default:
73390                     return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
73391             }
73392         }
73393         function moduleExpressionElementVisitor(node) {
73394             if (!(node.transformFlags & 2097152) && !(node.transformFlags & 1024)) {
73395                 return node;
73396             }
73397             if (ts.isImportCall(node)) {
73398                 return visitImportCallExpression(node);
73399             }
73400             else if (ts.isDestructuringAssignment(node)) {
73401                 return visitDestructuringAssignment(node);
73402             }
73403             else {
73404                 return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
73405             }
73406         }
73407         function destructuringNeedsFlattening(node) {
73408             if (ts.isObjectLiteralExpression(node)) {
73409                 for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
73410                     var elem = _a[_i];
73411                     switch (elem.kind) {
73412                         case 281:
73413                             if (destructuringNeedsFlattening(elem.initializer)) {
73414                                 return true;
73415                             }
73416                             break;
73417                         case 282:
73418                             if (destructuringNeedsFlattening(elem.name)) {
73419                                 return true;
73420                             }
73421                             break;
73422                         case 283:
73423                             if (destructuringNeedsFlattening(elem.expression)) {
73424                                 return true;
73425                             }
73426                             break;
73427                         case 161:
73428                         case 163:
73429                         case 164:
73430                             return false;
73431                         default: ts.Debug.assertNever(elem, "Unhandled object member kind");
73432                     }
73433                 }
73434             }
73435             else if (ts.isArrayLiteralExpression(node)) {
73436                 for (var _b = 0, _c = node.elements; _b < _c.length; _b++) {
73437                     var elem = _c[_b];
73438                     if (ts.isSpreadElement(elem)) {
73439                         if (destructuringNeedsFlattening(elem.expression)) {
73440                             return true;
73441                         }
73442                     }
73443                     else if (destructuringNeedsFlattening(elem)) {
73444                         return true;
73445                     }
73446                 }
73447             }
73448             else if (ts.isIdentifier(node)) {
73449                 return ts.length(getExports(node)) > (ts.isExportName(node) ? 1 : 0);
73450             }
73451             return false;
73452         }
73453         function visitDestructuringAssignment(node) {
73454             if (destructuringNeedsFlattening(node.left)) {
73455                 return ts.flattenDestructuringAssignment(node, moduleExpressionElementVisitor, context, 0, false, createAllExportExpressions);
73456             }
73457             return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
73458         }
73459         function visitImportCallExpression(node) {
73460             var argument = ts.visitNode(ts.firstOrUndefined(node.arguments), moduleExpressionElementVisitor);
73461             var containsLexicalThis = !!(node.transformFlags & 4096);
73462             switch (compilerOptions.module) {
73463                 case ts.ModuleKind.AMD:
73464                     return createImportCallExpressionAMD(argument, containsLexicalThis);
73465                 case ts.ModuleKind.UMD:
73466                     return createImportCallExpressionUMD(argument, containsLexicalThis);
73467                 case ts.ModuleKind.CommonJS:
73468                 default:
73469                     return createImportCallExpressionCommonJS(argument, containsLexicalThis);
73470             }
73471         }
73472         function createImportCallExpressionUMD(arg, containsLexicalThis) {
73473             needUMDDynamicImportHelper = true;
73474             if (ts.isSimpleCopiableExpression(arg)) {
73475                 var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? ts.createLiteral(arg) : ts.setEmitFlags(ts.setTextRange(ts.getSynthesizedClone(arg), arg), 1536);
73476                 return ts.createConditional(ts.createIdentifier("__syncRequire"), createImportCallExpressionCommonJS(arg, containsLexicalThis), createImportCallExpressionAMD(argClone, containsLexicalThis));
73477             }
73478             else {
73479                 var temp = ts.createTempVariable(hoistVariableDeclaration);
73480                 return ts.createComma(ts.createAssignment(temp, arg), ts.createConditional(ts.createIdentifier("__syncRequire"), createImportCallExpressionCommonJS(temp, containsLexicalThis), createImportCallExpressionAMD(temp, containsLexicalThis)));
73481             }
73482         }
73483         function createImportCallExpressionAMD(arg, containsLexicalThis) {
73484             var resolve = ts.createUniqueName("resolve");
73485             var reject = ts.createUniqueName("reject");
73486             var parameters = [
73487                 ts.createParameter(undefined, undefined, undefined, resolve),
73488                 ts.createParameter(undefined, undefined, undefined, reject)
73489             ];
73490             var body = ts.createBlock([
73491                 ts.createExpressionStatement(ts.createCall(ts.createIdentifier("require"), undefined, [ts.createArrayLiteral([arg || ts.createOmittedExpression()]), resolve, reject]))
73492             ]);
73493             var func;
73494             if (languageVersion >= 2) {
73495                 func = ts.createArrowFunction(undefined, undefined, parameters, undefined, undefined, body);
73496             }
73497             else {
73498                 func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, parameters, undefined, body);
73499                 if (containsLexicalThis) {
73500                     ts.setEmitFlags(func, 8);
73501                 }
73502             }
73503             var promise = ts.createNew(ts.createIdentifier("Promise"), undefined, [func]);
73504             if (compilerOptions.esModuleInterop) {
73505                 context.requestEmitHelper(ts.importStarHelper);
73506                 return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), undefined, [ts.getUnscopedHelperName("__importStar")]);
73507             }
73508             return promise;
73509         }
73510         function createImportCallExpressionCommonJS(arg, containsLexicalThis) {
73511             var promiseResolveCall = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Promise"), "resolve"), undefined, []);
73512             var requireCall = ts.createCall(ts.createIdentifier("require"), undefined, arg ? [arg] : []);
73513             if (compilerOptions.esModuleInterop) {
73514                 context.requestEmitHelper(ts.importStarHelper);
73515                 requireCall = ts.createCall(ts.getUnscopedHelperName("__importStar"), undefined, [requireCall]);
73516             }
73517             var func;
73518             if (languageVersion >= 2) {
73519                 func = ts.createArrowFunction(undefined, undefined, [], undefined, undefined, requireCall);
73520             }
73521             else {
73522                 func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock([ts.createReturn(requireCall)]));
73523                 if (containsLexicalThis) {
73524                     ts.setEmitFlags(func, 8);
73525                 }
73526             }
73527             return ts.createCall(ts.createPropertyAccess(promiseResolveCall, "then"), undefined, [func]);
73528         }
73529         function getHelperExpressionForExport(node, innerExpr) {
73530             if (!compilerOptions.esModuleInterop || ts.getEmitFlags(node) & 67108864) {
73531                 return innerExpr;
73532             }
73533             if (ts.getExportNeedsImportStarHelper(node)) {
73534                 context.requestEmitHelper(ts.importStarHelper);
73535                 return ts.createCall(ts.getUnscopedHelperName("__importStar"), undefined, [innerExpr]);
73536             }
73537             return innerExpr;
73538         }
73539         function getHelperExpressionForImport(node, innerExpr) {
73540             if (!compilerOptions.esModuleInterop || ts.getEmitFlags(node) & 67108864) {
73541                 return innerExpr;
73542             }
73543             if (ts.getImportNeedsImportStarHelper(node)) {
73544                 context.requestEmitHelper(ts.importStarHelper);
73545                 return ts.createCall(ts.getUnscopedHelperName("__importStar"), undefined, [innerExpr]);
73546             }
73547             if (ts.getImportNeedsImportDefaultHelper(node)) {
73548                 context.requestEmitHelper(ts.importDefaultHelper);
73549                 return ts.createCall(ts.getUnscopedHelperName("__importDefault"), undefined, [innerExpr]);
73550             }
73551             return innerExpr;
73552         }
73553         function visitImportDeclaration(node) {
73554             var statements;
73555             var namespaceDeclaration = ts.getNamespaceDeclarationNode(node);
73556             if (moduleKind !== ts.ModuleKind.AMD) {
73557                 if (!node.importClause) {
73558                     return ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createRequireCall(node)), node), node);
73559                 }
73560                 else {
73561                     var variables = [];
73562                     if (namespaceDeclaration && !ts.isDefaultImport(node)) {
73563                         variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, getHelperExpressionForImport(node, createRequireCall(node))));
73564                     }
73565                     else {
73566                         variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), undefined, getHelperExpressionForImport(node, createRequireCall(node))));
73567                         if (namespaceDeclaration && ts.isDefaultImport(node)) {
73568                             variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node)));
73569                         }
73570                     }
73571                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(variables, languageVersion >= 2 ? 2 : 0)), node), node));
73572                 }
73573             }
73574             else if (namespaceDeclaration && ts.isDefaultImport(node)) {
73575                 statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
73576                     ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node)), node), node)
73577                 ], languageVersion >= 2 ? 2 : 0)));
73578             }
73579             if (hasAssociatedEndOfDeclarationMarker(node)) {
73580                 var id = ts.getOriginalNodeId(node);
73581                 deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node);
73582             }
73583             else {
73584                 statements = appendExportsOfImportDeclaration(statements, node);
73585             }
73586             return ts.singleOrMany(statements);
73587         }
73588         function createRequireCall(importNode) {
73589             var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions);
73590             var args = [];
73591             if (moduleName) {
73592                 args.push(moduleName);
73593             }
73594             return ts.createCall(ts.createIdentifier("require"), undefined, args);
73595         }
73596         function visitImportEqualsDeclaration(node) {
73597             ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer.");
73598             var statements;
73599             if (moduleKind !== ts.ModuleKind.AMD) {
73600                 if (ts.hasModifier(node, 1)) {
73601                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node), node));
73602                 }
73603                 else {
73604                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
73605                         ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), undefined, createRequireCall(node))
73606                     ], languageVersion >= 2 ? 2 : 0)), node), node));
73607                 }
73608             }
73609             else {
73610                 if (ts.hasModifier(node, 1)) {
73611                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node), node));
73612                 }
73613             }
73614             if (hasAssociatedEndOfDeclarationMarker(node)) {
73615                 var id = ts.getOriginalNodeId(node);
73616                 deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node);
73617             }
73618             else {
73619                 statements = appendExportsOfImportEqualsDeclaration(statements, node);
73620             }
73621             return ts.singleOrMany(statements);
73622         }
73623         function visitExportDeclaration(node) {
73624             if (!node.moduleSpecifier) {
73625                 return undefined;
73626             }
73627             var generatedName = ts.getGeneratedNameForNode(node);
73628             if (node.exportClause && ts.isNamedExports(node.exportClause)) {
73629                 var statements = [];
73630                 if (moduleKind !== ts.ModuleKind.AMD) {
73631                     statements.push(ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
73632                         ts.createVariableDeclaration(generatedName, undefined, createRequireCall(node))
73633                     ])), node), node));
73634                 }
73635                 for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) {
73636                     var specifier = _a[_i];
73637                     if (languageVersion === 0) {
73638                         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));
73639                     }
73640                     else {
73641                         var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name);
73642                         statements.push(ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(specifier), exportedValue, undefined, true)), specifier), specifier));
73643                     }
73644                 }
73645                 return ts.singleOrMany(statements);
73646             }
73647             else if (node.exportClause) {
73648                 var statements = [];
73649                 statements.push(ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getSynthesizedClone(node.exportClause.name), moduleKind !== ts.ModuleKind.AMD ?
73650                     getHelperExpressionForExport(node, createRequireCall(node)) :
73651                     ts.createIdentifier(ts.idText(node.exportClause.name)))), node), node));
73652                 return ts.singleOrMany(statements);
73653             }
73654             else {
73655                 return ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node), node);
73656             }
73657         }
73658         function visitExportAssignment(node) {
73659             if (node.isExportEquals) {
73660                 return undefined;
73661             }
73662             var statements;
73663             var original = node.original;
73664             if (original && hasAssociatedEndOfDeclarationMarker(original)) {
73665                 var id = ts.getOriginalNodeId(node);
73666                 deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), ts.visitNode(node.expression, moduleExpressionElementVisitor), node, true);
73667             }
73668             else {
73669                 statements = appendExportStatement(statements, ts.createIdentifier("default"), ts.visitNode(node.expression, moduleExpressionElementVisitor), node, true);
73670             }
73671             return ts.singleOrMany(statements);
73672         }
73673         function visitFunctionDeclaration(node) {
73674             var statements;
73675             if (ts.hasModifier(node, 1)) {
73676                 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));
73677             }
73678             else {
73679                 statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context));
73680             }
73681             if (hasAssociatedEndOfDeclarationMarker(node)) {
73682                 var id = ts.getOriginalNodeId(node);
73683                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
73684             }
73685             else {
73686                 statements = appendExportsOfHoistedDeclaration(statements, node);
73687             }
73688             return ts.singleOrMany(statements);
73689         }
73690         function visitClassDeclaration(node) {
73691             var statements;
73692             if (ts.hasModifier(node, 1)) {
73693                 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));
73694             }
73695             else {
73696                 statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context));
73697             }
73698             if (hasAssociatedEndOfDeclarationMarker(node)) {
73699                 var id = ts.getOriginalNodeId(node);
73700                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
73701             }
73702             else {
73703                 statements = appendExportsOfHoistedDeclaration(statements, node);
73704             }
73705             return ts.singleOrMany(statements);
73706         }
73707         function visitVariableStatement(node) {
73708             var statements;
73709             var variables;
73710             var expressions;
73711             if (ts.hasModifier(node, 1)) {
73712                 var modifiers = void 0;
73713                 for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
73714                     var variable = _a[_i];
73715                     if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) {
73716                         if (!modifiers) {
73717                             modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier);
73718                         }
73719                         variables = ts.append(variables, variable);
73720                     }
73721                     else if (variable.initializer) {
73722                         expressions = ts.append(expressions, transformInitializedVariable(variable));
73723                     }
73724                 }
73725                 if (variables) {
73726                     statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables)));
73727                 }
73728                 if (expressions) {
73729                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node), node));
73730                 }
73731             }
73732             else {
73733                 statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context));
73734             }
73735             if (hasAssociatedEndOfDeclarationMarker(node)) {
73736                 var id = ts.getOriginalNodeId(node);
73737                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node);
73738             }
73739             else {
73740                 statements = appendExportsOfVariableStatement(statements, node);
73741             }
73742             return ts.singleOrMany(statements);
73743         }
73744         function createAllExportExpressions(name, value, location) {
73745             var exportedNames = getExports(name);
73746             if (exportedNames) {
73747                 var expression = ts.isExportName(name) ? value : ts.createAssignment(name, value);
73748                 for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) {
73749                     var exportName = exportedNames_1[_i];
73750                     ts.setEmitFlags(expression, 4);
73751                     expression = createExportExpression(exportName, expression, location);
73752                 }
73753                 return expression;
73754             }
73755             return ts.createAssignment(name, value);
73756         }
73757         function transformInitializedVariable(node) {
73758             if (ts.isBindingPattern(node.name)) {
73759                 return ts.flattenDestructuringAssignment(ts.visitNode(node, moduleExpressionElementVisitor), undefined, context, 0, false, createAllExportExpressions);
73760             }
73761             else {
73762                 return ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name), node.name), node.initializer ? ts.visitNode(node.initializer, moduleExpressionElementVisitor) : ts.createVoidZero());
73763             }
73764         }
73765         function visitMergeDeclarationMarker(node) {
73766             if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 225) {
73767                 var id = ts.getOriginalNodeId(node);
73768                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original);
73769             }
73770             return node;
73771         }
73772         function hasAssociatedEndOfDeclarationMarker(node) {
73773             return (ts.getEmitFlags(node) & 4194304) !== 0;
73774         }
73775         function visitEndOfDeclarationMarker(node) {
73776             var id = ts.getOriginalNodeId(node);
73777             var statements = deferredExports[id];
73778             if (statements) {
73779                 delete deferredExports[id];
73780                 return ts.append(statements, node);
73781             }
73782             return node;
73783         }
73784         function appendExportsOfImportDeclaration(statements, decl) {
73785             if (currentModuleInfo.exportEquals) {
73786                 return statements;
73787             }
73788             var importClause = decl.importClause;
73789             if (!importClause) {
73790                 return statements;
73791             }
73792             if (importClause.name) {
73793                 statements = appendExportsOfDeclaration(statements, importClause);
73794             }
73795             var namedBindings = importClause.namedBindings;
73796             if (namedBindings) {
73797                 switch (namedBindings.kind) {
73798                     case 256:
73799                         statements = appendExportsOfDeclaration(statements, namedBindings);
73800                         break;
73801                     case 257:
73802                         for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) {
73803                             var importBinding = _a[_i];
73804                             statements = appendExportsOfDeclaration(statements, importBinding, true);
73805                         }
73806                         break;
73807                 }
73808             }
73809             return statements;
73810         }
73811         function appendExportsOfImportEqualsDeclaration(statements, decl) {
73812             if (currentModuleInfo.exportEquals) {
73813                 return statements;
73814             }
73815             return appendExportsOfDeclaration(statements, decl);
73816         }
73817         function appendExportsOfVariableStatement(statements, node) {
73818             if (currentModuleInfo.exportEquals) {
73819                 return statements;
73820             }
73821             for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
73822                 var decl = _a[_i];
73823                 statements = appendExportsOfBindingElement(statements, decl);
73824             }
73825             return statements;
73826         }
73827         function appendExportsOfBindingElement(statements, decl) {
73828             if (currentModuleInfo.exportEquals) {
73829                 return statements;
73830             }
73831             if (ts.isBindingPattern(decl.name)) {
73832                 for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) {
73833                     var element = _a[_i];
73834                     if (!ts.isOmittedExpression(element)) {
73835                         statements = appendExportsOfBindingElement(statements, element);
73836                     }
73837                 }
73838             }
73839             else if (!ts.isGeneratedIdentifier(decl.name)) {
73840                 statements = appendExportsOfDeclaration(statements, decl);
73841             }
73842             return statements;
73843         }
73844         function appendExportsOfHoistedDeclaration(statements, decl) {
73845             if (currentModuleInfo.exportEquals) {
73846                 return statements;
73847             }
73848             if (ts.hasModifier(decl, 1)) {
73849                 var exportName = ts.hasModifier(decl, 512) ? ts.createIdentifier("default") : ts.getDeclarationName(decl);
73850                 statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), decl);
73851             }
73852             if (decl.name) {
73853                 statements = appendExportsOfDeclaration(statements, decl);
73854             }
73855             return statements;
73856         }
73857         function appendExportsOfDeclaration(statements, decl, liveBinding) {
73858             var name = ts.getDeclarationName(decl);
73859             var exportSpecifiers = currentModuleInfo.exportSpecifiers.get(ts.idText(name));
73860             if (exportSpecifiers) {
73861                 for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) {
73862                     var exportSpecifier = exportSpecifiers_1[_i];
73863                     statements = appendExportStatement(statements, exportSpecifier.name, name, exportSpecifier.name, undefined, liveBinding);
73864                 }
73865             }
73866             return statements;
73867         }
73868         function appendExportStatement(statements, exportName, expression, location, allowComments, liveBinding) {
73869             statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding));
73870             return statements;
73871         }
73872         function createUnderscoreUnderscoreESModule() {
73873             var statement;
73874             if (languageVersion === 0) {
73875                 statement = ts.createExpressionStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true)));
73876             }
73877             else {
73878                 statement = ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [
73879                     ts.createIdentifier("exports"),
73880                     ts.createLiteral("__esModule"),
73881                     ts.createObjectLiteral([
73882                         ts.createPropertyAssignment("value", ts.createLiteral(true))
73883                     ])
73884                 ]));
73885             }
73886             ts.setEmitFlags(statement, 1048576);
73887             return statement;
73888         }
73889         function createExportStatement(name, value, location, allowComments, liveBinding) {
73890             var statement = ts.setTextRange(ts.createExpressionStatement(createExportExpression(name, value, undefined, liveBinding)), location);
73891             ts.startOnNewLine(statement);
73892             if (!allowComments) {
73893                 ts.setEmitFlags(statement, 1536);
73894             }
73895             return statement;
73896         }
73897         function createExportExpression(name, value, location, liveBinding) {
73898             return ts.setTextRange(liveBinding && languageVersion !== 0 ? ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [
73899                 ts.createIdentifier("exports"),
73900                 ts.createLiteral(name),
73901                 ts.createObjectLiteral([
73902                     ts.createPropertyAssignment("enumerable", ts.createLiteral(true)),
73903                     ts.createPropertyAssignment("get", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock([ts.createReturn(value)])))
73904                 ])
73905             ]) : ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value), location);
73906         }
73907         function modifierVisitor(node) {
73908             switch (node.kind) {
73909                 case 89:
73910                 case 84:
73911                     return undefined;
73912             }
73913             return node;
73914         }
73915         function onEmitNode(hint, node, emitCallback) {
73916             if (node.kind === 290) {
73917                 currentSourceFile = node;
73918                 currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)];
73919                 noSubstitution = [];
73920                 previousOnEmitNode(hint, node, emitCallback);
73921                 currentSourceFile = undefined;
73922                 currentModuleInfo = undefined;
73923                 noSubstitution = undefined;
73924             }
73925             else {
73926                 previousOnEmitNode(hint, node, emitCallback);
73927             }
73928         }
73929         function onSubstituteNode(hint, node) {
73930             node = previousOnSubstituteNode(hint, node);
73931             if (node.id && noSubstitution[node.id]) {
73932                 return node;
73933             }
73934             if (hint === 1) {
73935                 return substituteExpression(node);
73936             }
73937             else if (ts.isShorthandPropertyAssignment(node)) {
73938                 return substituteShorthandPropertyAssignment(node);
73939             }
73940             return node;
73941         }
73942         function substituteShorthandPropertyAssignment(node) {
73943             var name = node.name;
73944             var exportedOrImportedName = substituteExpressionIdentifier(name);
73945             if (exportedOrImportedName !== name) {
73946                 if (node.objectAssignmentInitializer) {
73947                     var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer);
73948                     return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node);
73949                 }
73950                 return ts.setTextRange(ts.createPropertyAssignment(name, exportedOrImportedName), node);
73951             }
73952             return node;
73953         }
73954         function substituteExpression(node) {
73955             switch (node.kind) {
73956                 case 75:
73957                     return substituteExpressionIdentifier(node);
73958                 case 209:
73959                     return substituteBinaryExpression(node);
73960                 case 208:
73961                 case 207:
73962                     return substituteUnaryExpression(node);
73963             }
73964             return node;
73965         }
73966         function substituteExpressionIdentifier(node) {
73967             if (ts.getEmitFlags(node) & 4096) {
73968                 var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile);
73969                 if (externalHelpersModuleName) {
73970                     return ts.createPropertyAccess(externalHelpersModuleName, node);
73971                 }
73972                 return node;
73973             }
73974             if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
73975                 var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node));
73976                 if (exportContainer && exportContainer.kind === 290) {
73977                     return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), node);
73978                 }
73979                 var importDeclaration = resolver.getReferencedImportDeclaration(node);
73980                 if (importDeclaration) {
73981                     if (ts.isImportClause(importDeclaration)) {
73982                         return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), node);
73983                     }
73984                     else if (ts.isImportSpecifier(importDeclaration)) {
73985                         var name = importDeclaration.propertyName || importDeclaration.name;
73986                         return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name)), node);
73987                     }
73988                 }
73989             }
73990             return node;
73991         }
73992         function substituteBinaryExpression(node) {
73993             if (ts.isAssignmentOperator(node.operatorToken.kind)
73994                 && ts.isIdentifier(node.left)
73995                 && !ts.isGeneratedIdentifier(node.left)
73996                 && !ts.isLocalName(node.left)
73997                 && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) {
73998                 var exportedNames = getExports(node.left);
73999                 if (exportedNames) {
74000                     var expression = node;
74001                     for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) {
74002                         var exportName = exportedNames_2[_i];
74003                         noSubstitution[ts.getNodeId(expression)] = true;
74004                         expression = createExportExpression(exportName, expression, node);
74005                     }
74006                     return expression;
74007                 }
74008             }
74009             return node;
74010         }
74011         function substituteUnaryExpression(node) {
74012             if ((node.operator === 45 || node.operator === 46)
74013                 && ts.isIdentifier(node.operand)
74014                 && !ts.isGeneratedIdentifier(node.operand)
74015                 && !ts.isLocalName(node.operand)
74016                 && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) {
74017                 var exportedNames = getExports(node.operand);
74018                 if (exportedNames) {
74019                     var expression = node.kind === 208
74020                         ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 45 ? 63 : 64), ts.createLiteral(1)), node)
74021                         : node;
74022                     for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) {
74023                         var exportName = exportedNames_3[_i];
74024                         noSubstitution[ts.getNodeId(expression)] = true;
74025                         expression = createExportExpression(exportName, expression);
74026                     }
74027                     return expression;
74028                 }
74029             }
74030             return node;
74031         }
74032         function getExports(name) {
74033             if (!ts.isGeneratedIdentifier(name)) {
74034                 var valueDeclaration = resolver.getReferencedImportDeclaration(name)
74035                     || resolver.getReferencedValueDeclaration(name);
74036                 if (valueDeclaration) {
74037                     return currentModuleInfo
74038                         && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)];
74039                 }
74040             }
74041         }
74042     }
74043     ts.transformModule = transformModule;
74044     ts.createBindingHelper = {
74045         name: "typescript:commonjscreatebinding",
74046         importName: "__createBinding",
74047         scoped: false,
74048         priority: 1,
74049         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}));"
74050     };
74051     function createCreateBindingHelper(context, module, inputName, outputName) {
74052         context.requestEmitHelper(ts.createBindingHelper);
74053         return ts.createCall(ts.getUnscopedHelperName("__createBinding"), undefined, __spreadArrays([ts.createIdentifier("exports"), module, inputName], (outputName ? [outputName] : [])));
74054     }
74055     ts.setModuleDefaultHelper = {
74056         name: "typescript:commonjscreatevalue",
74057         importName: "__setModuleDefault",
74058         scoped: false,
74059         priority: 1,
74060         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});"
74061     };
74062     var exportStarHelper = {
74063         name: "typescript:export-star",
74064         importName: "__exportStar",
74065         scoped: false,
74066         dependencies: [ts.createBindingHelper],
74067         priority: 2,
74068         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            };"
74069     };
74070     function createExportStarHelper(context, module) {
74071         context.requestEmitHelper(exportStarHelper);
74072         return ts.createCall(ts.getUnscopedHelperName("__exportStar"), undefined, [module, ts.createIdentifier("exports")]);
74073     }
74074     var dynamicImportUMDHelper = {
74075         name: "typescript:dynamicimport-sync-require",
74076         scoped: true,
74077         text: "\n            var __syncRequire = typeof module === \"object\" && typeof module.exports === \"object\";"
74078     };
74079     ts.importStarHelper = {
74080         name: "typescript:commonjsimportstar",
74081         importName: "__importStar",
74082         scoped: false,
74083         dependencies: [ts.createBindingHelper, ts.setModuleDefaultHelper],
74084         priority: 2,
74085         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};"
74086     };
74087     ts.importDefaultHelper = {
74088         name: "typescript:commonjsimportdefault",
74089         importName: "__importDefault",
74090         scoped: false,
74091         text: "\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};"
74092     };
74093 })(ts || (ts = {}));
74094 var ts;
74095 (function (ts) {
74096     function transformSystemModule(context) {
74097         var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
74098         var compilerOptions = context.getCompilerOptions();
74099         var resolver = context.getEmitResolver();
74100         var host = context.getEmitHost();
74101         var previousOnSubstituteNode = context.onSubstituteNode;
74102         var previousOnEmitNode = context.onEmitNode;
74103         context.onSubstituteNode = onSubstituteNode;
74104         context.onEmitNode = onEmitNode;
74105         context.enableSubstitution(75);
74106         context.enableSubstitution(282);
74107         context.enableSubstitution(209);
74108         context.enableSubstitution(207);
74109         context.enableSubstitution(208);
74110         context.enableSubstitution(219);
74111         context.enableEmitNotification(290);
74112         var moduleInfoMap = [];
74113         var deferredExports = [];
74114         var exportFunctionsMap = [];
74115         var noSubstitutionMap = [];
74116         var contextObjectMap = [];
74117         var currentSourceFile;
74118         var moduleInfo;
74119         var exportFunction;
74120         var contextObject;
74121         var hoistedStatements;
74122         var enclosingBlockScopedContainer;
74123         var noSubstitution;
74124         return ts.chainBundle(transformSourceFile);
74125         function transformSourceFile(node) {
74126             if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 2097152)) {
74127                 return node;
74128             }
74129             var id = ts.getOriginalNodeId(node);
74130             currentSourceFile = node;
74131             enclosingBlockScopedContainer = node;
74132             moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(node, resolver, compilerOptions);
74133             exportFunction = ts.createUniqueName("exports");
74134             exportFunctionsMap[id] = exportFunction;
74135             contextObject = contextObjectMap[id] = ts.createUniqueName("context");
74136             var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports);
74137             var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups);
74138             var moduleBodyFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [
74139                 ts.createParameter(undefined, undefined, undefined, exportFunction),
74140                 ts.createParameter(undefined, undefined, undefined, contextObject)
74141             ], undefined, moduleBodyBlock);
74142             var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions);
74143             var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; }));
74144             var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([
74145                 ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName
74146                     ? [moduleName, dependencies, moduleBodyFunction]
74147                     : [dependencies, moduleBodyFunction]))
74148             ]), node.statements)), 1024);
74149             if (!(compilerOptions.outFile || compilerOptions.out)) {
74150                 ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; });
74151             }
74152             if (noSubstitution) {
74153                 noSubstitutionMap[id] = noSubstitution;
74154                 noSubstitution = undefined;
74155             }
74156             currentSourceFile = undefined;
74157             moduleInfo = undefined;
74158             exportFunction = undefined;
74159             contextObject = undefined;
74160             hoistedStatements = undefined;
74161             enclosingBlockScopedContainer = undefined;
74162             return ts.aggregateTransformFlags(updated);
74163         }
74164         function collectDependencyGroups(externalImports) {
74165             var groupIndices = ts.createMap();
74166             var dependencyGroups = [];
74167             for (var _i = 0, externalImports_1 = externalImports; _i < externalImports_1.length; _i++) {
74168                 var externalImport = externalImports_1[_i];
74169                 var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions);
74170                 if (externalModuleName) {
74171                     var text = externalModuleName.text;
74172                     var groupIndex = groupIndices.get(text);
74173                     if (groupIndex !== undefined) {
74174                         dependencyGroups[groupIndex].externalImports.push(externalImport);
74175                     }
74176                     else {
74177                         groupIndices.set(text, dependencyGroups.length);
74178                         dependencyGroups.push({
74179                             name: externalModuleName,
74180                             externalImports: [externalImport]
74181                         });
74182                     }
74183                 }
74184             }
74185             return dependencyGroups;
74186         }
74187         function createSystemModuleBody(node, dependencyGroups) {
74188             var statements = [];
74189             startLexicalEnvironment();
74190             var ensureUseStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile));
74191             var statementOffset = ts.addPrologue(statements, node.statements, ensureUseStrict, sourceElementVisitor);
74192             statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
74193                 ts.createVariableDeclaration("__moduleName", undefined, ts.createLogicalAnd(contextObject, ts.createPropertyAccess(contextObject, "id")))
74194             ])));
74195             ts.visitNode(moduleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement);
74196             var executeStatements = ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset);
74197             ts.addRange(statements, hoistedStatements);
74198             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
74199             var exportStarFunction = addExportStarIfNeeded(statements);
74200             var modifiers = node.transformFlags & 524288 ?
74201                 ts.createModifiersFromModifierFlags(256) :
74202                 undefined;
74203             var moduleObject = ts.createObjectLiteral([
74204                 ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)),
74205                 ts.createPropertyAssignment("execute", ts.createFunctionExpression(modifiers, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, true)))
74206             ]);
74207             moduleObject.multiLine = true;
74208             statements.push(ts.createReturn(moduleObject));
74209             return ts.createBlock(statements, true);
74210         }
74211         function addExportStarIfNeeded(statements) {
74212             if (!moduleInfo.hasExportStarsToExportValues) {
74213                 return;
74214             }
74215             if (!moduleInfo.exportedNames && moduleInfo.exportSpecifiers.size === 0) {
74216                 var hasExportDeclarationWithExportClause = false;
74217                 for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) {
74218                     var externalImport = _a[_i];
74219                     if (externalImport.kind === 260 && externalImport.exportClause) {
74220                         hasExportDeclarationWithExportClause = true;
74221                         break;
74222                     }
74223                 }
74224                 if (!hasExportDeclarationWithExportClause) {
74225                     var exportStarFunction_1 = createExportStarFunction(undefined);
74226                     statements.push(exportStarFunction_1);
74227                     return exportStarFunction_1.name;
74228                 }
74229             }
74230             var exportedNames = [];
74231             if (moduleInfo.exportedNames) {
74232                 for (var _b = 0, _c = moduleInfo.exportedNames; _b < _c.length; _b++) {
74233                     var exportedLocalName = _c[_b];
74234                     if (exportedLocalName.escapedText === "default") {
74235                         continue;
74236                     }
74237                     exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createTrue()));
74238                 }
74239             }
74240             for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) {
74241                 var externalImport = _e[_d];
74242                 if (externalImport.kind !== 260) {
74243                     continue;
74244                 }
74245                 if (!externalImport.exportClause) {
74246                     continue;
74247                 }
74248                 if (ts.isNamedExports(externalImport.exportClause)) {
74249                     for (var _f = 0, _g = externalImport.exportClause.elements; _f < _g.length; _f++) {
74250                         var element = _g[_f];
74251                         exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(ts.idText(element.name || element.propertyName)), ts.createTrue()));
74252                     }
74253                 }
74254                 else {
74255                     exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(ts.idText(externalImport.exportClause.name)), ts.createTrue()));
74256                 }
74257             }
74258             var exportedNamesStorageRef = ts.createUniqueName("exportedNames");
74259             statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
74260                 ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, true))
74261             ])));
74262             var exportStarFunction = createExportStarFunction(exportedNamesStorageRef);
74263             statements.push(exportStarFunction);
74264             return exportStarFunction.name;
74265         }
74266         function createExportStarFunction(localNames) {
74267             var exportStarFunction = ts.createUniqueName("exportStar");
74268             var m = ts.createIdentifier("m");
74269             var n = ts.createIdentifier("n");
74270             var exports = ts.createIdentifier("exports");
74271             var condition = ts.createStrictInequality(n, ts.createLiteral("default"));
74272             if (localNames) {
74273                 condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createCall(ts.createPropertyAccess(localNames, "hasOwnProperty"), undefined, [n])));
74274             }
74275             return ts.createFunctionDeclaration(undefined, undefined, undefined, exportStarFunction, undefined, [ts.createParameter(undefined, undefined, undefined, m)], undefined, ts.createBlock([
74276                 ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
74277                     ts.createVariableDeclaration(exports, undefined, ts.createObjectLiteral([]))
74278                 ])),
74279                 ts.createForIn(ts.createVariableDeclarationList([
74280                     ts.createVariableDeclaration(n, undefined)
74281                 ]), m, ts.createBlock([
74282                     ts.setEmitFlags(ts.createIf(condition, ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1)
74283                 ])),
74284                 ts.createExpressionStatement(ts.createCall(exportFunction, undefined, [exports]))
74285             ], true));
74286         }
74287         function createSettersArray(exportStarFunction, dependencyGroups) {
74288             var setters = [];
74289             for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) {
74290                 var group_2 = dependencyGroups_1[_i];
74291                 var localName = ts.forEach(group_2.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); });
74292                 var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName("");
74293                 var statements = [];
74294                 for (var _a = 0, _b = group_2.externalImports; _a < _b.length; _a++) {
74295                     var entry = _b[_a];
74296                     var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile);
74297                     switch (entry.kind) {
74298                         case 254:
74299                             if (!entry.importClause) {
74300                                 break;
74301                             }
74302                         case 253:
74303                             ts.Debug.assert(importVariableName !== undefined);
74304                             statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName)));
74305                             break;
74306                         case 260:
74307                             ts.Debug.assert(importVariableName !== undefined);
74308                             if (entry.exportClause) {
74309                                 if (ts.isNamedExports(entry.exportClause)) {
74310                                     var properties = [];
74311                                     for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) {
74312                                         var e = _d[_c];
74313                                         properties.push(ts.createPropertyAssignment(ts.createLiteral(ts.idText(e.name)), ts.createElementAccess(parameterName, ts.createLiteral(ts.idText(e.propertyName || e.name)))));
74314                                     }
74315                                     statements.push(ts.createExpressionStatement(ts.createCall(exportFunction, undefined, [ts.createObjectLiteral(properties, true)])));
74316                                 }
74317                                 else {
74318                                     statements.push(ts.createExpressionStatement(ts.createCall(exportFunction, undefined, [
74319                                         ts.createLiteral(ts.idText(entry.exportClause.name)),
74320                                         parameterName
74321                                     ])));
74322                                 }
74323                             }
74324                             else {
74325                                 statements.push(ts.createExpressionStatement(ts.createCall(exportStarFunction, undefined, [parameterName])));
74326                             }
74327                             break;
74328                     }
74329                 }
74330                 setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, ts.createBlock(statements, true)));
74331             }
74332             return ts.createArrayLiteral(setters, true);
74333         }
74334         function sourceElementVisitor(node) {
74335             switch (node.kind) {
74336                 case 254:
74337                     return visitImportDeclaration(node);
74338                 case 253:
74339                     return visitImportEqualsDeclaration(node);
74340                 case 260:
74341                     return visitExportDeclaration(node);
74342                 case 259:
74343                     return visitExportAssignment(node);
74344                 default:
74345                     return nestedElementVisitor(node);
74346             }
74347         }
74348         function visitImportDeclaration(node) {
74349             var statements;
74350             if (node.importClause) {
74351                 hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile));
74352             }
74353             if (hasAssociatedEndOfDeclarationMarker(node)) {
74354                 var id = ts.getOriginalNodeId(node);
74355                 deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node);
74356             }
74357             else {
74358                 statements = appendExportsOfImportDeclaration(statements, node);
74359             }
74360             return ts.singleOrMany(statements);
74361         }
74362         function visitExportDeclaration(node) {
74363             ts.Debug.assertIsDefined(node);
74364             return undefined;
74365         }
74366         function visitImportEqualsDeclaration(node) {
74367             ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer.");
74368             var statements;
74369             hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile));
74370             if (hasAssociatedEndOfDeclarationMarker(node)) {
74371                 var id = ts.getOriginalNodeId(node);
74372                 deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node);
74373             }
74374             else {
74375                 statements = appendExportsOfImportEqualsDeclaration(statements, node);
74376             }
74377             return ts.singleOrMany(statements);
74378         }
74379         function visitExportAssignment(node) {
74380             if (node.isExportEquals) {
74381                 return undefined;
74382             }
74383             var expression = ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression);
74384             var original = node.original;
74385             if (original && hasAssociatedEndOfDeclarationMarker(original)) {
74386                 var id = ts.getOriginalNodeId(node);
74387                 deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), expression, true);
74388             }
74389             else {
74390                 return createExportStatement(ts.createIdentifier("default"), expression, true);
74391             }
74392         }
74393         function visitFunctionDeclaration(node) {
74394             if (ts.hasModifier(node, 1)) {
74395                 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)));
74396             }
74397             else {
74398                 hoistedStatements = ts.append(hoistedStatements, ts.visitEachChild(node, destructuringAndImportCallVisitor, context));
74399             }
74400             if (hasAssociatedEndOfDeclarationMarker(node)) {
74401                 var id = ts.getOriginalNodeId(node);
74402                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
74403             }
74404             else {
74405                 hoistedStatements = appendExportsOfHoistedDeclaration(hoistedStatements, node);
74406             }
74407             return undefined;
74408         }
74409         function visitClassDeclaration(node) {
74410             var statements;
74411             var name = ts.getLocalName(node);
74412             hoistVariableDeclaration(name);
74413             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));
74414             if (hasAssociatedEndOfDeclarationMarker(node)) {
74415                 var id = ts.getOriginalNodeId(node);
74416                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
74417             }
74418             else {
74419                 statements = appendExportsOfHoistedDeclaration(statements, node);
74420             }
74421             return ts.singleOrMany(statements);
74422         }
74423         function visitVariableStatement(node) {
74424             if (!shouldHoistVariableDeclarationList(node.declarationList)) {
74425                 return ts.visitNode(node, destructuringAndImportCallVisitor, ts.isStatement);
74426             }
74427             var expressions;
74428             var isExportedDeclaration = ts.hasModifier(node, 1);
74429             var isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node);
74430             for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
74431                 var variable = _a[_i];
74432                 if (variable.initializer) {
74433                     expressions = ts.append(expressions, transformInitializedVariable(variable, isExportedDeclaration && !isMarkedDeclaration));
74434                 }
74435                 else {
74436                     hoistBindingElement(variable);
74437                 }
74438             }
74439             var statements;
74440             if (expressions) {
74441                 statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node));
74442             }
74443             if (isMarkedDeclaration) {
74444                 var id = ts.getOriginalNodeId(node);
74445                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node, isExportedDeclaration);
74446             }
74447             else {
74448                 statements = appendExportsOfVariableStatement(statements, node, false);
74449             }
74450             return ts.singleOrMany(statements);
74451         }
74452         function hoistBindingElement(node) {
74453             if (ts.isBindingPattern(node.name)) {
74454                 for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) {
74455                     var element = _a[_i];
74456                     if (!ts.isOmittedExpression(element)) {
74457                         hoistBindingElement(element);
74458                     }
74459                 }
74460             }
74461             else {
74462                 hoistVariableDeclaration(ts.getSynthesizedClone(node.name));
74463             }
74464         }
74465         function shouldHoistVariableDeclarationList(node) {
74466             return (ts.getEmitFlags(node) & 2097152) === 0
74467                 && (enclosingBlockScopedContainer.kind === 290
74468                     || (ts.getOriginalNode(node).flags & 3) === 0);
74469         }
74470         function transformInitializedVariable(node, isExportedDeclaration) {
74471             var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment;
74472             return ts.isBindingPattern(node.name)
74473                 ? ts.flattenDestructuringAssignment(node, destructuringAndImportCallVisitor, context, 0, false, createAssignment)
74474                 : node.initializer ? createAssignment(node.name, ts.visitNode(node.initializer, destructuringAndImportCallVisitor, ts.isExpression)) : node.name;
74475         }
74476         function createExportedVariableAssignment(name, value, location) {
74477             return createVariableAssignment(name, value, location, true);
74478         }
74479         function createNonExportedVariableAssignment(name, value, location) {
74480             return createVariableAssignment(name, value, location, false);
74481         }
74482         function createVariableAssignment(name, value, location, isExportedDeclaration) {
74483             hoistVariableDeclaration(ts.getSynthesizedClone(name));
74484             return isExportedDeclaration
74485                 ? createExportExpression(name, preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)))
74486                 : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location));
74487         }
74488         function visitMergeDeclarationMarker(node) {
74489             if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 225) {
74490                 var id = ts.getOriginalNodeId(node);
74491                 var isExportedDeclaration = ts.hasModifier(node.original, 1);
74492                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration);
74493             }
74494             return node;
74495         }
74496         function hasAssociatedEndOfDeclarationMarker(node) {
74497             return (ts.getEmitFlags(node) & 4194304) !== 0;
74498         }
74499         function visitEndOfDeclarationMarker(node) {
74500             var id = ts.getOriginalNodeId(node);
74501             var statements = deferredExports[id];
74502             if (statements) {
74503                 delete deferredExports[id];
74504                 return ts.append(statements, node);
74505             }
74506             else {
74507                 var original = ts.getOriginalNode(node);
74508                 if (ts.isModuleOrEnumDeclaration(original)) {
74509                     return ts.append(appendExportsOfDeclaration(statements, original), node);
74510                 }
74511             }
74512             return node;
74513         }
74514         function appendExportsOfImportDeclaration(statements, decl) {
74515             if (moduleInfo.exportEquals) {
74516                 return statements;
74517             }
74518             var importClause = decl.importClause;
74519             if (!importClause) {
74520                 return statements;
74521             }
74522             if (importClause.name) {
74523                 statements = appendExportsOfDeclaration(statements, importClause);
74524             }
74525             var namedBindings = importClause.namedBindings;
74526             if (namedBindings) {
74527                 switch (namedBindings.kind) {
74528                     case 256:
74529                         statements = appendExportsOfDeclaration(statements, namedBindings);
74530                         break;
74531                     case 257:
74532                         for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) {
74533                             var importBinding = _a[_i];
74534                             statements = appendExportsOfDeclaration(statements, importBinding);
74535                         }
74536                         break;
74537                 }
74538             }
74539             return statements;
74540         }
74541         function appendExportsOfImportEqualsDeclaration(statements, decl) {
74542             if (moduleInfo.exportEquals) {
74543                 return statements;
74544             }
74545             return appendExportsOfDeclaration(statements, decl);
74546         }
74547         function appendExportsOfVariableStatement(statements, node, exportSelf) {
74548             if (moduleInfo.exportEquals) {
74549                 return statements;
74550             }
74551             for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
74552                 var decl = _a[_i];
74553                 if (decl.initializer || exportSelf) {
74554                     statements = appendExportsOfBindingElement(statements, decl, exportSelf);
74555                 }
74556             }
74557             return statements;
74558         }
74559         function appendExportsOfBindingElement(statements, decl, exportSelf) {
74560             if (moduleInfo.exportEquals) {
74561                 return statements;
74562             }
74563             if (ts.isBindingPattern(decl.name)) {
74564                 for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) {
74565                     var element = _a[_i];
74566                     if (!ts.isOmittedExpression(element)) {
74567                         statements = appendExportsOfBindingElement(statements, element, exportSelf);
74568                     }
74569                 }
74570             }
74571             else if (!ts.isGeneratedIdentifier(decl.name)) {
74572                 var excludeName = void 0;
74573                 if (exportSelf) {
74574                     statements = appendExportStatement(statements, decl.name, ts.getLocalName(decl));
74575                     excludeName = ts.idText(decl.name);
74576                 }
74577                 statements = appendExportsOfDeclaration(statements, decl, excludeName);
74578             }
74579             return statements;
74580         }
74581         function appendExportsOfHoistedDeclaration(statements, decl) {
74582             if (moduleInfo.exportEquals) {
74583                 return statements;
74584             }
74585             var excludeName;
74586             if (ts.hasModifier(decl, 1)) {
74587                 var exportName = ts.hasModifier(decl, 512) ? ts.createLiteral("default") : decl.name;
74588                 statements = appendExportStatement(statements, exportName, ts.getLocalName(decl));
74589                 excludeName = ts.getTextOfIdentifierOrLiteral(exportName);
74590             }
74591             if (decl.name) {
74592                 statements = appendExportsOfDeclaration(statements, decl, excludeName);
74593             }
74594             return statements;
74595         }
74596         function appendExportsOfDeclaration(statements, decl, excludeName) {
74597             if (moduleInfo.exportEquals) {
74598                 return statements;
74599             }
74600             var name = ts.getDeclarationName(decl);
74601             var exportSpecifiers = moduleInfo.exportSpecifiers.get(ts.idText(name));
74602             if (exportSpecifiers) {
74603                 for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) {
74604                     var exportSpecifier = exportSpecifiers_2[_i];
74605                     if (exportSpecifier.name.escapedText !== excludeName) {
74606                         statements = appendExportStatement(statements, exportSpecifier.name, name);
74607                     }
74608                 }
74609             }
74610             return statements;
74611         }
74612         function appendExportStatement(statements, exportName, expression, allowComments) {
74613             statements = ts.append(statements, createExportStatement(exportName, expression, allowComments));
74614             return statements;
74615         }
74616         function createExportStatement(name, value, allowComments) {
74617             var statement = ts.createExpressionStatement(createExportExpression(name, value));
74618             ts.startOnNewLine(statement);
74619             if (!allowComments) {
74620                 ts.setEmitFlags(statement, 1536);
74621             }
74622             return statement;
74623         }
74624         function createExportExpression(name, value) {
74625             var exportName = ts.isIdentifier(name) ? ts.createLiteral(name) : name;
74626             ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536);
74627             return ts.setCommentRange(ts.createCall(exportFunction, undefined, [exportName, value]), value);
74628         }
74629         function nestedElementVisitor(node) {
74630             switch (node.kind) {
74631                 case 225:
74632                     return visitVariableStatement(node);
74633                 case 244:
74634                     return visitFunctionDeclaration(node);
74635                 case 245:
74636                     return visitClassDeclaration(node);
74637                 case 230:
74638                     return visitForStatement(node);
74639                 case 231:
74640                     return visitForInStatement(node);
74641                 case 232:
74642                     return visitForOfStatement(node);
74643                 case 228:
74644                     return visitDoStatement(node);
74645                 case 229:
74646                     return visitWhileStatement(node);
74647                 case 238:
74648                     return visitLabeledStatement(node);
74649                 case 236:
74650                     return visitWithStatement(node);
74651                 case 237:
74652                     return visitSwitchStatement(node);
74653                 case 251:
74654                     return visitCaseBlock(node);
74655                 case 277:
74656                     return visitCaseClause(node);
74657                 case 278:
74658                     return visitDefaultClause(node);
74659                 case 240:
74660                     return visitTryStatement(node);
74661                 case 280:
74662                     return visitCatchClause(node);
74663                 case 223:
74664                     return visitBlock(node);
74665                 case 328:
74666                     return visitMergeDeclarationMarker(node);
74667                 case 329:
74668                     return visitEndOfDeclarationMarker(node);
74669                 default:
74670                     return destructuringAndImportCallVisitor(node);
74671             }
74672         }
74673         function visitForStatement(node) {
74674             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74675             enclosingBlockScopedContainer = node;
74676             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));
74677             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74678             return node;
74679         }
74680         function visitForInStatement(node) {
74681             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74682             enclosingBlockScopedContainer = node;
74683             node = ts.updateForIn(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock));
74684             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74685             return node;
74686         }
74687         function visitForOfStatement(node) {
74688             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74689             enclosingBlockScopedContainer = node;
74690             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));
74691             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74692             return node;
74693         }
74694         function shouldHoistForInitializer(node) {
74695             return ts.isVariableDeclarationList(node)
74696                 && shouldHoistVariableDeclarationList(node);
74697         }
74698         function visitForInitializer(node) {
74699             if (shouldHoistForInitializer(node)) {
74700                 var expressions = void 0;
74701                 for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) {
74702                     var variable = _a[_i];
74703                     expressions = ts.append(expressions, transformInitializedVariable(variable, false));
74704                     if (!variable.initializer) {
74705                         hoistBindingElement(variable);
74706                     }
74707                 }
74708                 return expressions ? ts.inlineExpressions(expressions) : ts.createOmittedExpression();
74709             }
74710             else {
74711                 return ts.visitEachChild(node, nestedElementVisitor, context);
74712             }
74713         }
74714         function visitDoStatement(node) {
74715             return ts.updateDo(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression));
74716         }
74717         function visitWhileStatement(node) {
74718             return ts.updateWhile(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock));
74719         }
74720         function visitLabeledStatement(node) {
74721             return ts.updateLabel(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock));
74722         }
74723         function visitWithStatement(node) {
74724             return ts.updateWith(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock));
74725         }
74726         function visitSwitchStatement(node) {
74727             return ts.updateSwitch(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.caseBlock, nestedElementVisitor, ts.isCaseBlock));
74728         }
74729         function visitCaseBlock(node) {
74730             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74731             enclosingBlockScopedContainer = node;
74732             node = ts.updateCaseBlock(node, ts.visitNodes(node.clauses, nestedElementVisitor, ts.isCaseOrDefaultClause));
74733             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74734             return node;
74735         }
74736         function visitCaseClause(node) {
74737             return ts.updateCaseClause(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNodes(node.statements, nestedElementVisitor, ts.isStatement));
74738         }
74739         function visitDefaultClause(node) {
74740             return ts.visitEachChild(node, nestedElementVisitor, context);
74741         }
74742         function visitTryStatement(node) {
74743             return ts.visitEachChild(node, nestedElementVisitor, context);
74744         }
74745         function visitCatchClause(node) {
74746             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74747             enclosingBlockScopedContainer = node;
74748             node = ts.updateCatchClause(node, node.variableDeclaration, ts.visitNode(node.block, nestedElementVisitor, ts.isBlock));
74749             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74750             return node;
74751         }
74752         function visitBlock(node) {
74753             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74754             enclosingBlockScopedContainer = node;
74755             node = ts.visitEachChild(node, nestedElementVisitor, context);
74756             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74757             return node;
74758         }
74759         function destructuringAndImportCallVisitor(node) {
74760             if (ts.isDestructuringAssignment(node)) {
74761                 return visitDestructuringAssignment(node);
74762             }
74763             else if (ts.isImportCall(node)) {
74764                 return visitImportCallExpression(node);
74765             }
74766             else if ((node.transformFlags & 1024) || (node.transformFlags & 2097152)) {
74767                 return ts.visitEachChild(node, destructuringAndImportCallVisitor, context);
74768             }
74769             else {
74770                 return node;
74771             }
74772         }
74773         function visitImportCallExpression(node) {
74774             return ts.createCall(ts.createPropertyAccess(contextObject, ts.createIdentifier("import")), undefined, ts.some(node.arguments) ? [ts.visitNode(node.arguments[0], destructuringAndImportCallVisitor)] : []);
74775         }
74776         function visitDestructuringAssignment(node) {
74777             if (hasExportedReferenceInDestructuringTarget(node.left)) {
74778                 return ts.flattenDestructuringAssignment(node, destructuringAndImportCallVisitor, context, 0, true);
74779             }
74780             return ts.visitEachChild(node, destructuringAndImportCallVisitor, context);
74781         }
74782         function hasExportedReferenceInDestructuringTarget(node) {
74783             if (ts.isAssignmentExpression(node, true)) {
74784                 return hasExportedReferenceInDestructuringTarget(node.left);
74785             }
74786             else if (ts.isSpreadElement(node)) {
74787                 return hasExportedReferenceInDestructuringTarget(node.expression);
74788             }
74789             else if (ts.isObjectLiteralExpression(node)) {
74790                 return ts.some(node.properties, hasExportedReferenceInDestructuringTarget);
74791             }
74792             else if (ts.isArrayLiteralExpression(node)) {
74793                 return ts.some(node.elements, hasExportedReferenceInDestructuringTarget);
74794             }
74795             else if (ts.isShorthandPropertyAssignment(node)) {
74796                 return hasExportedReferenceInDestructuringTarget(node.name);
74797             }
74798             else if (ts.isPropertyAssignment(node)) {
74799                 return hasExportedReferenceInDestructuringTarget(node.initializer);
74800             }
74801             else if (ts.isIdentifier(node)) {
74802                 var container = resolver.getReferencedExportContainer(node);
74803                 return container !== undefined && container.kind === 290;
74804             }
74805             else {
74806                 return false;
74807             }
74808         }
74809         function modifierVisitor(node) {
74810             switch (node.kind) {
74811                 case 89:
74812                 case 84:
74813                     return undefined;
74814             }
74815             return node;
74816         }
74817         function onEmitNode(hint, node, emitCallback) {
74818             if (node.kind === 290) {
74819                 var id = ts.getOriginalNodeId(node);
74820                 currentSourceFile = node;
74821                 moduleInfo = moduleInfoMap[id];
74822                 exportFunction = exportFunctionsMap[id];
74823                 noSubstitution = noSubstitutionMap[id];
74824                 contextObject = contextObjectMap[id];
74825                 if (noSubstitution) {
74826                     delete noSubstitutionMap[id];
74827                 }
74828                 previousOnEmitNode(hint, node, emitCallback);
74829                 currentSourceFile = undefined;
74830                 moduleInfo = undefined;
74831                 exportFunction = undefined;
74832                 contextObject = undefined;
74833                 noSubstitution = undefined;
74834             }
74835             else {
74836                 previousOnEmitNode(hint, node, emitCallback);
74837             }
74838         }
74839         function onSubstituteNode(hint, node) {
74840             node = previousOnSubstituteNode(hint, node);
74841             if (isSubstitutionPrevented(node)) {
74842                 return node;
74843             }
74844             if (hint === 1) {
74845                 return substituteExpression(node);
74846             }
74847             else if (hint === 4) {
74848                 return substituteUnspecified(node);
74849             }
74850             return node;
74851         }
74852         function substituteUnspecified(node) {
74853             switch (node.kind) {
74854                 case 282:
74855                     return substituteShorthandPropertyAssignment(node);
74856             }
74857             return node;
74858         }
74859         function substituteShorthandPropertyAssignment(node) {
74860             var name = node.name;
74861             if (!ts.isGeneratedIdentifier(name) && !ts.isLocalName(name)) {
74862                 var importDeclaration = resolver.getReferencedImportDeclaration(name);
74863                 if (importDeclaration) {
74864                     if (ts.isImportClause(importDeclaration)) {
74865                         return ts.setTextRange(ts.createPropertyAssignment(ts.getSynthesizedClone(name), ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"))), node);
74866                     }
74867                     else if (ts.isImportSpecifier(importDeclaration)) {
74868                         return ts.setTextRange(ts.createPropertyAssignment(ts.getSynthesizedClone(name), ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name))), node);
74869                     }
74870                 }
74871             }
74872             return node;
74873         }
74874         function substituteExpression(node) {
74875             switch (node.kind) {
74876                 case 75:
74877                     return substituteExpressionIdentifier(node);
74878                 case 209:
74879                     return substituteBinaryExpression(node);
74880                 case 207:
74881                 case 208:
74882                     return substituteUnaryExpression(node);
74883                 case 219:
74884                     return substituteMetaProperty(node);
74885             }
74886             return node;
74887         }
74888         function substituteExpressionIdentifier(node) {
74889             if (ts.getEmitFlags(node) & 4096) {
74890                 var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile);
74891                 if (externalHelpersModuleName) {
74892                     return ts.createPropertyAccess(externalHelpersModuleName, node);
74893                 }
74894                 return node;
74895             }
74896             if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
74897                 var importDeclaration = resolver.getReferencedImportDeclaration(node);
74898                 if (importDeclaration) {
74899                     if (ts.isImportClause(importDeclaration)) {
74900                         return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), node);
74901                     }
74902                     else if (ts.isImportSpecifier(importDeclaration)) {
74903                         return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name)), node);
74904                     }
74905                 }
74906             }
74907             return node;
74908         }
74909         function substituteBinaryExpression(node) {
74910             if (ts.isAssignmentOperator(node.operatorToken.kind)
74911                 && ts.isIdentifier(node.left)
74912                 && !ts.isGeneratedIdentifier(node.left)
74913                 && !ts.isLocalName(node.left)
74914                 && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) {
74915                 var exportedNames = getExports(node.left);
74916                 if (exportedNames) {
74917                     var expression = node;
74918                     for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) {
74919                         var exportName = exportedNames_4[_i];
74920                         expression = createExportExpression(exportName, preventSubstitution(expression));
74921                     }
74922                     return expression;
74923                 }
74924             }
74925             return node;
74926         }
74927         function substituteUnaryExpression(node) {
74928             if ((node.operator === 45 || node.operator === 46)
74929                 && ts.isIdentifier(node.operand)
74930                 && !ts.isGeneratedIdentifier(node.operand)
74931                 && !ts.isLocalName(node.operand)
74932                 && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) {
74933                 var exportedNames = getExports(node.operand);
74934                 if (exportedNames) {
74935                     var expression = node.kind === 208
74936                         ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node)
74937                         : node;
74938                     for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) {
74939                         var exportName = exportedNames_5[_i];
74940                         expression = createExportExpression(exportName, preventSubstitution(expression));
74941                     }
74942                     if (node.kind === 208) {
74943                         expression = node.operator === 45
74944                             ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1))
74945                             : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1));
74946                     }
74947                     return expression;
74948                 }
74949             }
74950             return node;
74951         }
74952         function substituteMetaProperty(node) {
74953             if (ts.isImportMeta(node)) {
74954                 return ts.createPropertyAccess(contextObject, ts.createIdentifier("meta"));
74955             }
74956             return node;
74957         }
74958         function getExports(name) {
74959             var exportedNames;
74960             if (!ts.isGeneratedIdentifier(name)) {
74961                 var valueDeclaration = resolver.getReferencedImportDeclaration(name)
74962                     || resolver.getReferencedValueDeclaration(name);
74963                 if (valueDeclaration) {
74964                     var exportContainer = resolver.getReferencedExportContainer(name, false);
74965                     if (exportContainer && exportContainer.kind === 290) {
74966                         exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration));
74967                     }
74968                     exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]);
74969                 }
74970             }
74971             return exportedNames;
74972         }
74973         function preventSubstitution(node) {
74974             if (noSubstitution === undefined)
74975                 noSubstitution = [];
74976             noSubstitution[ts.getNodeId(node)] = true;
74977             return node;
74978         }
74979         function isSubstitutionPrevented(node) {
74980             return noSubstitution && node.id && noSubstitution[node.id];
74981         }
74982     }
74983     ts.transformSystemModule = transformSystemModule;
74984 })(ts || (ts = {}));
74985 var ts;
74986 (function (ts) {
74987     function transformECMAScriptModule(context) {
74988         var compilerOptions = context.getCompilerOptions();
74989         var previousOnEmitNode = context.onEmitNode;
74990         var previousOnSubstituteNode = context.onSubstituteNode;
74991         context.onEmitNode = onEmitNode;
74992         context.onSubstituteNode = onSubstituteNode;
74993         context.enableEmitNotification(290);
74994         context.enableSubstitution(75);
74995         var helperNameSubstitutions;
74996         return ts.chainBundle(transformSourceFile);
74997         function transformSourceFile(node) {
74998             if (node.isDeclarationFile) {
74999                 return node;
75000             }
75001             if (ts.isExternalModule(node) || compilerOptions.isolatedModules) {
75002                 var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(node, compilerOptions);
75003                 if (externalHelpersImportDeclaration) {
75004                     var statements = [];
75005                     var statementOffset = ts.addPrologue(statements, node.statements);
75006                     ts.append(statements, externalHelpersImportDeclaration);
75007                     ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset));
75008                     return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements));
75009                 }
75010                 else {
75011                     return ts.visitEachChild(node, visitor, context);
75012                 }
75013             }
75014             return node;
75015         }
75016         function visitor(node) {
75017             switch (node.kind) {
75018                 case 253:
75019                     return undefined;
75020                 case 259:
75021                     return visitExportAssignment(node);
75022                 case 260:
75023                     var exportDecl = node;
75024                     return visitExportDeclaration(exportDecl);
75025             }
75026             return node;
75027         }
75028         function visitExportAssignment(node) {
75029             return node.isExportEquals ? undefined : node;
75030         }
75031         function visitExportDeclaration(node) {
75032             if (compilerOptions.module !== undefined && compilerOptions.module > ts.ModuleKind.ES2015) {
75033                 return node;
75034             }
75035             if (!node.exportClause || !ts.isNamespaceExport(node.exportClause) || !node.moduleSpecifier) {
75036                 return node;
75037             }
75038             var oldIdentifier = node.exportClause.name;
75039             var synthName = ts.getGeneratedNameForNode(oldIdentifier);
75040             var importDecl = ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(synthName)), node.moduleSpecifier);
75041             ts.setOriginalNode(importDecl, node.exportClause);
75042             var exportDecl = ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([ts.createExportSpecifier(synthName, oldIdentifier)]));
75043             ts.setOriginalNode(exportDecl, node);
75044             return [importDecl, exportDecl];
75045         }
75046         function onEmitNode(hint, node, emitCallback) {
75047             if (ts.isSourceFile(node)) {
75048                 if ((ts.isExternalModule(node) || compilerOptions.isolatedModules) && compilerOptions.importHelpers) {
75049                     helperNameSubstitutions = ts.createMap();
75050                 }
75051                 previousOnEmitNode(hint, node, emitCallback);
75052                 helperNameSubstitutions = undefined;
75053             }
75054             else {
75055                 previousOnEmitNode(hint, node, emitCallback);
75056             }
75057         }
75058         function onSubstituteNode(hint, node) {
75059             node = previousOnSubstituteNode(hint, node);
75060             if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096) {
75061                 return substituteHelperName(node);
75062             }
75063             return node;
75064         }
75065         function substituteHelperName(node) {
75066             var name = ts.idText(node);
75067             var substitution = helperNameSubstitutions.get(name);
75068             if (!substitution) {
75069                 helperNameSubstitutions.set(name, substitution = ts.createFileLevelUniqueName(name));
75070             }
75071             return substitution;
75072         }
75073     }
75074     ts.transformECMAScriptModule = transformECMAScriptModule;
75075 })(ts || (ts = {}));
75076 var ts;
75077 (function (ts) {
75078     function canProduceDiagnostics(node) {
75079         return ts.isVariableDeclaration(node) ||
75080             ts.isPropertyDeclaration(node) ||
75081             ts.isPropertySignature(node) ||
75082             ts.isBindingElement(node) ||
75083             ts.isSetAccessor(node) ||
75084             ts.isGetAccessor(node) ||
75085             ts.isConstructSignatureDeclaration(node) ||
75086             ts.isCallSignatureDeclaration(node) ||
75087             ts.isMethodDeclaration(node) ||
75088             ts.isMethodSignature(node) ||
75089             ts.isFunctionDeclaration(node) ||
75090             ts.isParameter(node) ||
75091             ts.isTypeParameterDeclaration(node) ||
75092             ts.isExpressionWithTypeArguments(node) ||
75093             ts.isImportEqualsDeclaration(node) ||
75094             ts.isTypeAliasDeclaration(node) ||
75095             ts.isConstructorDeclaration(node) ||
75096             ts.isIndexSignatureDeclaration(node) ||
75097             ts.isPropertyAccessExpression(node);
75098     }
75099     ts.canProduceDiagnostics = canProduceDiagnostics;
75100     function createGetSymbolAccessibilityDiagnosticForNodeName(node) {
75101         if (ts.isSetAccessor(node) || ts.isGetAccessor(node)) {
75102             return getAccessorNameVisibilityError;
75103         }
75104         else if (ts.isMethodSignature(node) || ts.isMethodDeclaration(node)) {
75105             return getMethodNameVisibilityError;
75106         }
75107         else {
75108             return createGetSymbolAccessibilityDiagnosticForNode(node);
75109         }
75110         function getAccessorNameVisibilityError(symbolAccessibilityResult) {
75111             var diagnosticMessage = getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult);
75112             return diagnosticMessage !== undefined ? {
75113                 diagnosticMessage: diagnosticMessage,
75114                 errorNode: node,
75115                 typeName: node.name
75116             } : undefined;
75117         }
75118         function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult) {
75119             if (ts.hasModifier(node, 32)) {
75120                 return symbolAccessibilityResult.errorModuleName ?
75121                     symbolAccessibilityResult.accessibility === 2 ?
75122                         ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75123                         ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75124                     ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
75125             }
75126             else if (node.parent.kind === 245) {
75127                 return symbolAccessibilityResult.errorModuleName ?
75128                     symbolAccessibilityResult.accessibility === 2 ?
75129                         ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75130                         ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75131                     ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
75132             }
75133             else {
75134                 return symbolAccessibilityResult.errorModuleName ?
75135                     ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75136                     ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1;
75137             }
75138         }
75139         function getMethodNameVisibilityError(symbolAccessibilityResult) {
75140             var diagnosticMessage = getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult);
75141             return diagnosticMessage !== undefined ? {
75142                 diagnosticMessage: diagnosticMessage,
75143                 errorNode: node,
75144                 typeName: node.name
75145             } : undefined;
75146         }
75147         function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult) {
75148             if (ts.hasModifier(node, 32)) {
75149                 return symbolAccessibilityResult.errorModuleName ?
75150                     symbolAccessibilityResult.accessibility === 2 ?
75151                         ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75152                         ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75153                     ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1;
75154             }
75155             else if (node.parent.kind === 245) {
75156                 return symbolAccessibilityResult.errorModuleName ?
75157                     symbolAccessibilityResult.accessibility === 2 ?
75158                         ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75159                         ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75160                     ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_private_name_1;
75161             }
75162             else {
75163                 return symbolAccessibilityResult.errorModuleName ?
75164                     ts.Diagnostics.Method_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75165                     ts.Diagnostics.Method_0_of_exported_interface_has_or_is_using_private_name_1;
75166             }
75167         }
75168     }
75169     ts.createGetSymbolAccessibilityDiagnosticForNodeName = createGetSymbolAccessibilityDiagnosticForNodeName;
75170     function createGetSymbolAccessibilityDiagnosticForNode(node) {
75171         if (ts.isVariableDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertySignature(node) || ts.isPropertyAccessExpression(node) || ts.isBindingElement(node) || ts.isConstructorDeclaration(node)) {
75172             return getVariableDeclarationTypeVisibilityError;
75173         }
75174         else if (ts.isSetAccessor(node) || ts.isGetAccessor(node)) {
75175             return getAccessorDeclarationTypeVisibilityError;
75176         }
75177         else if (ts.isConstructSignatureDeclaration(node) || ts.isCallSignatureDeclaration(node) || ts.isMethodDeclaration(node) || ts.isMethodSignature(node) || ts.isFunctionDeclaration(node) || ts.isIndexSignatureDeclaration(node)) {
75178             return getReturnTypeVisibilityError;
75179         }
75180         else if (ts.isParameter(node)) {
75181             if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasModifier(node.parent, 8)) {
75182                 return getVariableDeclarationTypeVisibilityError;
75183             }
75184             return getParameterDeclarationTypeVisibilityError;
75185         }
75186         else if (ts.isTypeParameterDeclaration(node)) {
75187             return getTypeParameterConstraintVisibilityError;
75188         }
75189         else if (ts.isExpressionWithTypeArguments(node)) {
75190             return getHeritageClauseVisibilityError;
75191         }
75192         else if (ts.isImportEqualsDeclaration(node)) {
75193             return getImportEntityNameVisibilityError;
75194         }
75195         else if (ts.isTypeAliasDeclaration(node)) {
75196             return getTypeAliasDeclarationVisibilityError;
75197         }
75198         else {
75199             return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]);
75200         }
75201         function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) {
75202             if (node.kind === 242 || node.kind === 191) {
75203                 return symbolAccessibilityResult.errorModuleName ?
75204                     symbolAccessibilityResult.accessibility === 2 ?
75205                         ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75206                         ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 :
75207                     ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1;
75208             }
75209             else if (node.kind === 159 || node.kind === 194 || node.kind === 158 ||
75210                 (node.kind === 156 && ts.hasModifier(node.parent, 8))) {
75211                 if (ts.hasModifier(node, 32)) {
75212                     return symbolAccessibilityResult.errorModuleName ?
75213                         symbolAccessibilityResult.accessibility === 2 ?
75214                             ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75215                             ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75216                         ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
75217                 }
75218                 else if (node.parent.kind === 245 || node.kind === 156) {
75219                     return symbolAccessibilityResult.errorModuleName ?
75220                         symbolAccessibilityResult.accessibility === 2 ?
75221                             ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75222                             ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75223                         ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
75224                 }
75225                 else {
75226                     return symbolAccessibilityResult.errorModuleName ?
75227                         ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75228                         ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1;
75229                 }
75230             }
75231         }
75232         function getVariableDeclarationTypeVisibilityError(symbolAccessibilityResult) {
75233             var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult);
75234             return diagnosticMessage !== undefined ? {
75235                 diagnosticMessage: diagnosticMessage,
75236                 errorNode: node,
75237                 typeName: node.name
75238             } : undefined;
75239         }
75240         function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) {
75241             var diagnosticMessage;
75242             if (node.kind === 164) {
75243                 if (ts.hasModifier(node, 32)) {
75244                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75245                         ts.Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75246                         ts.Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_private_name_1;
75247                 }
75248                 else {
75249                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75250                         ts.Diagnostics.Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75251                         ts.Diagnostics.Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_private_name_1;
75252                 }
75253             }
75254             else {
75255                 if (ts.hasModifier(node, 32)) {
75256                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75257                         symbolAccessibilityResult.accessibility === 2 ?
75258                             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 :
75259                             ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75260                         ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1;
75261                 }
75262                 else {
75263                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75264                         symbolAccessibilityResult.accessibility === 2 ?
75265                             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 :
75266                             ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75267                         ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1;
75268                 }
75269             }
75270             return {
75271                 diagnosticMessage: diagnosticMessage,
75272                 errorNode: node.name,
75273                 typeName: node.name
75274             };
75275         }
75276         function getReturnTypeVisibilityError(symbolAccessibilityResult) {
75277             var diagnosticMessage;
75278             switch (node.kind) {
75279                 case 166:
75280                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75281                         ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
75282                         ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0;
75283                     break;
75284                 case 165:
75285                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75286                         ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
75287                         ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0;
75288                     break;
75289                 case 167:
75290                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75291                         ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
75292                         ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0;
75293                     break;
75294                 case 161:
75295                 case 160:
75296                     if (ts.hasModifier(node, 32)) {
75297                         diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75298                             symbolAccessibilityResult.accessibility === 2 ?
75299                                 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 :
75300                                 ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
75301                             ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0;
75302                     }
75303                     else if (node.parent.kind === 245) {
75304                         diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75305                             symbolAccessibilityResult.accessibility === 2 ?
75306                                 ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
75307                                 ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
75308                             ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0;
75309                     }
75310                     else {
75311                         diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75312                             ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
75313                             ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0;
75314                     }
75315                     break;
75316                 case 244:
75317                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75318                         symbolAccessibilityResult.accessibility === 2 ?
75319                             ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
75320                             ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 :
75321                         ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0;
75322                     break;
75323                 default:
75324                     return ts.Debug.fail("This is unknown kind for signature: " + node.kind);
75325             }
75326             return {
75327                 diagnosticMessage: diagnosticMessage,
75328                 errorNode: node.name || node
75329             };
75330         }
75331         function getParameterDeclarationTypeVisibilityError(symbolAccessibilityResult) {
75332             var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult);
75333             return diagnosticMessage !== undefined ? {
75334                 diagnosticMessage: diagnosticMessage,
75335                 errorNode: node,
75336                 typeName: node.name
75337             } : undefined;
75338         }
75339         function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) {
75340             switch (node.parent.kind) {
75341                 case 162:
75342                     return symbolAccessibilityResult.errorModuleName ?
75343                         symbolAccessibilityResult.accessibility === 2 ?
75344                             ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75345                             ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75346                         ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1;
75347                 case 166:
75348                 case 171:
75349                     return symbolAccessibilityResult.errorModuleName ?
75350                         ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75351                         ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
75352                 case 165:
75353                     return symbolAccessibilityResult.errorModuleName ?
75354                         ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75355                         ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
75356                 case 167:
75357                     return symbolAccessibilityResult.errorModuleName ?
75358                         ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75359                         ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1;
75360                 case 161:
75361                 case 160:
75362                     if (ts.hasModifier(node.parent, 32)) {
75363                         return symbolAccessibilityResult.errorModuleName ?
75364                             symbolAccessibilityResult.accessibility === 2 ?
75365                                 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 :
75366                                 ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75367                             ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
75368                     }
75369                     else if (node.parent.parent.kind === 245) {
75370                         return symbolAccessibilityResult.errorModuleName ?
75371                             symbolAccessibilityResult.accessibility === 2 ?
75372                                 ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75373                                 ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75374                             ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
75375                     }
75376                     else {
75377                         return symbolAccessibilityResult.errorModuleName ?
75378                             ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75379                             ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
75380                     }
75381                 case 244:
75382                 case 170:
75383                     return symbolAccessibilityResult.errorModuleName ?
75384                         symbolAccessibilityResult.accessibility === 2 ?
75385                             ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75386                             ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 :
75387                         ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1;
75388                 case 164:
75389                 case 163:
75390                     return symbolAccessibilityResult.errorModuleName ?
75391                         symbolAccessibilityResult.accessibility === 2 ?
75392                             ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75393                             ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 :
75394                         ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1;
75395                 default:
75396                     return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]);
75397             }
75398         }
75399         function getTypeParameterConstraintVisibilityError() {
75400             var diagnosticMessage;
75401             switch (node.parent.kind) {
75402                 case 245:
75403                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1;
75404                     break;
75405                 case 246:
75406                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1;
75407                     break;
75408                 case 186:
75409                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1;
75410                     break;
75411                 case 171:
75412                 case 166:
75413                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
75414                     break;
75415                 case 165:
75416                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
75417                     break;
75418                 case 161:
75419                 case 160:
75420                     if (ts.hasModifier(node.parent, 32)) {
75421                         diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
75422                     }
75423                     else if (node.parent.parent.kind === 245) {
75424                         diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
75425                     }
75426                     else {
75427                         diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
75428                     }
75429                     break;
75430                 case 170:
75431                 case 244:
75432                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1;
75433                     break;
75434                 case 247:
75435                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1;
75436                     break;
75437                 default:
75438                     return ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind);
75439             }
75440             return {
75441                 diagnosticMessage: diagnosticMessage,
75442                 errorNode: node,
75443                 typeName: node.name
75444             };
75445         }
75446         function getHeritageClauseVisibilityError() {
75447             var diagnosticMessage;
75448             if (node.parent.parent.kind === 245) {
75449                 diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 113 ?
75450                     ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 :
75451                     ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1;
75452             }
75453             else {
75454                 diagnosticMessage = ts.Diagnostics.extends_clause_of_exported_interface_0_has_or_is_using_private_name_1;
75455             }
75456             return {
75457                 diagnosticMessage: diagnosticMessage,
75458                 errorNode: node,
75459                 typeName: ts.getNameOfDeclaration(node.parent.parent)
75460             };
75461         }
75462         function getImportEntityNameVisibilityError() {
75463             return {
75464                 diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1,
75465                 errorNode: node,
75466                 typeName: node.name
75467             };
75468         }
75469         function getTypeAliasDeclarationVisibilityError() {
75470             return {
75471                 diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1,
75472                 errorNode: node.type,
75473                 typeName: node.name
75474             };
75475         }
75476     }
75477     ts.createGetSymbolAccessibilityDiagnosticForNode = createGetSymbolAccessibilityDiagnosticForNode;
75478 })(ts || (ts = {}));
75479 var ts;
75480 (function (ts) {
75481     function getDeclarationDiagnostics(host, resolver, file) {
75482         if (file && ts.isJsonSourceFile(file)) {
75483             return [];
75484         }
75485         var compilerOptions = host.getCompilerOptions();
75486         var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJson), [transformDeclarations], false);
75487         return result.diagnostics;
75488     }
75489     ts.getDeclarationDiagnostics = getDeclarationDiagnostics;
75490     function hasInternalAnnotation(range, currentSourceFile) {
75491         var comment = currentSourceFile.text.substring(range.pos, range.end);
75492         return ts.stringContains(comment, "@internal");
75493     }
75494     function isInternalDeclaration(node, currentSourceFile) {
75495         var parseTreeNode = ts.getParseTreeNode(node);
75496         if (parseTreeNode && parseTreeNode.kind === 156) {
75497             var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode);
75498             var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined;
75499             var text = currentSourceFile.text;
75500             var commentRanges = previousSibling
75501                 ? ts.concatenate(ts.getTrailingCommentRanges(text, ts.skipTrivia(text, previousSibling.end + 1, false, true)), ts.getLeadingCommentRanges(text, node.pos))
75502                 : ts.getTrailingCommentRanges(text, ts.skipTrivia(text, node.pos, false, true));
75503             return commentRanges && commentRanges.length && hasInternalAnnotation(ts.last(commentRanges), currentSourceFile);
75504         }
75505         var leadingCommentRanges = parseTreeNode && ts.getLeadingCommentRangesOfNode(parseTreeNode, currentSourceFile);
75506         return !!ts.forEach(leadingCommentRanges, function (range) {
75507             return hasInternalAnnotation(range, currentSourceFile);
75508         });
75509     }
75510     ts.isInternalDeclaration = isInternalDeclaration;
75511     var declarationEmitNodeBuilderFlags = 1024 |
75512         2048 |
75513         4096 |
75514         8 |
75515         524288 |
75516         4 |
75517         1;
75518     function transformDeclarations(context) {
75519         var throwDiagnostic = function () { return ts.Debug.fail("Diagnostic emitted without context"); };
75520         var getSymbolAccessibilityDiagnostic = throwDiagnostic;
75521         var needsDeclare = true;
75522         var isBundledEmit = false;
75523         var resultHasExternalModuleIndicator = false;
75524         var needsScopeFixMarker = false;
75525         var resultHasScopeMarker = false;
75526         var enclosingDeclaration;
75527         var necessaryTypeReferences;
75528         var lateMarkedStatements;
75529         var lateStatementReplacementMap;
75530         var suppressNewDiagnosticContexts;
75531         var exportedModulesFromDeclarationEmit;
75532         var host = context.getEmitHost();
75533         var symbolTracker = {
75534             trackSymbol: trackSymbol,
75535             reportInaccessibleThisError: reportInaccessibleThisError,
75536             reportInaccessibleUniqueSymbolError: reportInaccessibleUniqueSymbolError,
75537             reportPrivateInBaseOfClassExpression: reportPrivateInBaseOfClassExpression,
75538             reportLikelyUnsafeImportRequiredError: reportLikelyUnsafeImportRequiredError,
75539             moduleResolverHost: host,
75540             trackReferencedAmbientModule: trackReferencedAmbientModule,
75541             trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode,
75542             reportNonlocalAugmentation: reportNonlocalAugmentation
75543         };
75544         var errorNameNode;
75545         var currentSourceFile;
75546         var refs;
75547         var libs;
75548         var emittedImports;
75549         var resolver = context.getEmitResolver();
75550         var options = context.getCompilerOptions();
75551         var noResolve = options.noResolve, stripInternal = options.stripInternal;
75552         return transformRoot;
75553         function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) {
75554             if (!typeReferenceDirectives) {
75555                 return;
75556             }
75557             necessaryTypeReferences = necessaryTypeReferences || ts.createMap();
75558             for (var _i = 0, typeReferenceDirectives_2 = typeReferenceDirectives; _i < typeReferenceDirectives_2.length; _i++) {
75559                 var ref = typeReferenceDirectives_2[_i];
75560                 necessaryTypeReferences.set(ref, true);
75561             }
75562         }
75563         function trackReferencedAmbientModule(node, symbol) {
75564             var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863);
75565             if (ts.length(directives)) {
75566                 return recordTypeReferenceDirectivesIfNecessary(directives);
75567             }
75568             var container = ts.getSourceFileOfNode(node);
75569             refs.set("" + ts.getOriginalNodeId(container), container);
75570         }
75571         function handleSymbolAccessibilityError(symbolAccessibilityResult) {
75572             if (symbolAccessibilityResult.accessibility === 0) {
75573                 if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) {
75574                     if (!lateMarkedStatements) {
75575                         lateMarkedStatements = symbolAccessibilityResult.aliasesToMakeVisible;
75576                     }
75577                     else {
75578                         for (var _i = 0, _a = symbolAccessibilityResult.aliasesToMakeVisible; _i < _a.length; _i++) {
75579                             var ref = _a[_i];
75580                             ts.pushIfUnique(lateMarkedStatements, ref);
75581                         }
75582                     }
75583                 }
75584             }
75585             else {
75586                 var errorInfo = getSymbolAccessibilityDiagnostic(symbolAccessibilityResult);
75587                 if (errorInfo) {
75588                     if (errorInfo.typeName) {
75589                         context.addDiagnostic(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getTextOfNode(errorInfo.typeName), symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName));
75590                     }
75591                     else {
75592                         context.addDiagnostic(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName));
75593                     }
75594                 }
75595             }
75596         }
75597         function trackExternalModuleSymbolOfImportTypeNode(symbol) {
75598             if (!isBundledEmit) {
75599                 (exportedModulesFromDeclarationEmit || (exportedModulesFromDeclarationEmit = [])).push(symbol);
75600             }
75601         }
75602         function trackSymbol(symbol, enclosingDeclaration, meaning) {
75603             if (symbol.flags & 262144)
75604                 return;
75605             handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, true));
75606             recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning));
75607         }
75608         function reportPrivateInBaseOfClassExpression(propertyName) {
75609             if (errorNameNode) {
75610                 context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName));
75611             }
75612         }
75613         function reportInaccessibleUniqueSymbolError() {
75614             if (errorNameNode) {
75615                 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"));
75616             }
75617         }
75618         function reportInaccessibleThisError() {
75619             if (errorNameNode) {
75620                 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"));
75621             }
75622         }
75623         function reportLikelyUnsafeImportRequiredError(specifier) {
75624             if (errorNameNode) {
75625                 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));
75626             }
75627         }
75628         function reportNonlocalAugmentation(containingFile, parentSymbol, symbol) {
75629             var primaryDeclaration = ts.find(parentSymbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile; });
75630             var augmentingDeclarations = ts.filter(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== containingFile; });
75631             for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) {
75632                 var augmentations = augmentingDeclarations_1[_i];
75633                 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)));
75634             }
75635         }
75636         function transformDeclarationsForJS(sourceFile, bundled) {
75637             var oldDiag = getSymbolAccessibilityDiagnostic;
75638             getSymbolAccessibilityDiagnostic = function (s) { return ({
75639                 diagnosticMessage: s.errorModuleName
75640                     ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit
75641                     : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit,
75642                 errorNode: s.errorNode || sourceFile
75643             }); };
75644             var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled);
75645             getSymbolAccessibilityDiagnostic = oldDiag;
75646             return result;
75647         }
75648         function transformRoot(node) {
75649             if (node.kind === 290 && node.isDeclarationFile) {
75650                 return node;
75651             }
75652             if (node.kind === 291) {
75653                 isBundledEmit = true;
75654                 refs = ts.createMap();
75655                 libs = ts.createMap();
75656                 var hasNoDefaultLib_1 = false;
75657                 var bundle = ts.createBundle(ts.map(node.sourceFiles, function (sourceFile) {
75658                     if (sourceFile.isDeclarationFile)
75659                         return undefined;
75660                     hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib;
75661                     currentSourceFile = sourceFile;
75662                     enclosingDeclaration = sourceFile;
75663                     lateMarkedStatements = undefined;
75664                     suppressNewDiagnosticContexts = false;
75665                     lateStatementReplacementMap = ts.createMap();
75666                     getSymbolAccessibilityDiagnostic = throwDiagnostic;
75667                     needsScopeFixMarker = false;
75668                     resultHasScopeMarker = false;
75669                     collectReferences(sourceFile, refs);
75670                     collectLibs(sourceFile, libs);
75671                     if (ts.isExternalOrCommonJsModule(sourceFile) || ts.isJsonSourceFile(sourceFile)) {
75672                         resultHasExternalModuleIndicator = false;
75673                         needsDeclare = false;
75674                         var statements = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile, true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements);
75675                         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, []);
75676                         return newFile;
75677                     }
75678                     needsDeclare = true;
75679                     var updated = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements);
75680                     return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), true, [], [], false, []);
75681                 }), ts.mapDefined(node.prepends, function (prepend) {
75682                     if (prepend.kind === 293) {
75683                         var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal);
75684                         hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib;
75685                         collectReferences(sourceFile, refs);
75686                         recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives);
75687                         collectLibs(sourceFile, libs);
75688                         return sourceFile;
75689                     }
75690                     return prepend;
75691                 }));
75692                 bundle.syntheticFileReferences = [];
75693                 bundle.syntheticTypeReferences = getFileReferencesForUsedTypeReferences();
75694                 bundle.syntheticLibReferences = getLibReferences();
75695                 bundle.hasNoDefaultLib = hasNoDefaultLib_1;
75696                 var outputFilePath_1 = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, true).declarationFilePath));
75697                 var referenceVisitor_1 = mapReferencesIntoArray(bundle.syntheticFileReferences, outputFilePath_1);
75698                 refs.forEach(referenceVisitor_1);
75699                 return bundle;
75700             }
75701             needsDeclare = true;
75702             needsScopeFixMarker = false;
75703             resultHasScopeMarker = false;
75704             enclosingDeclaration = node;
75705             currentSourceFile = node;
75706             getSymbolAccessibilityDiagnostic = throwDiagnostic;
75707             isBundledEmit = false;
75708             resultHasExternalModuleIndicator = false;
75709             suppressNewDiagnosticContexts = false;
75710             lateMarkedStatements = undefined;
75711             lateStatementReplacementMap = ts.createMap();
75712             necessaryTypeReferences = undefined;
75713             refs = collectReferences(currentSourceFile, ts.createMap());
75714             libs = collectLibs(currentSourceFile, ts.createMap());
75715             var references = [];
75716             var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, true).declarationFilePath));
75717             var referenceVisitor = mapReferencesIntoArray(references, outputFilePath);
75718             var combinedStatements;
75719             if (ts.isSourceFileJS(currentSourceFile)) {
75720                 combinedStatements = ts.createNodeArray(transformDeclarationsForJS(node));
75721                 refs.forEach(referenceVisitor);
75722                 emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax);
75723             }
75724             else {
75725                 var statements = ts.visitNodes(node.statements, visitDeclarationStatements);
75726                 combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements);
75727                 refs.forEach(referenceVisitor);
75728                 emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax);
75729                 if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) {
75730                     combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [ts.createEmptyExports()])), combinedStatements);
75731                 }
75732             }
75733             var updated = ts.updateSourceFileNode(node, combinedStatements, true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences());
75734             updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit;
75735             return updated;
75736             function getLibReferences() {
75737                 return ts.map(ts.arrayFrom(libs.keys()), function (lib) { return ({ fileName: lib, pos: -1, end: -1 }); });
75738             }
75739             function getFileReferencesForUsedTypeReferences() {
75740                 return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()), getFileReferenceForTypeName) : [];
75741             }
75742             function getFileReferenceForTypeName(typeName) {
75743                 if (emittedImports) {
75744                     for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
75745                         var importStatement = emittedImports_1[_i];
75746                         if (ts.isImportEqualsDeclaration(importStatement) && ts.isExternalModuleReference(importStatement.moduleReference)) {
75747                             var expr = importStatement.moduleReference.expression;
75748                             if (ts.isStringLiteralLike(expr) && expr.text === typeName) {
75749                                 return undefined;
75750                             }
75751                         }
75752                         else if (ts.isImportDeclaration(importStatement) && ts.isStringLiteral(importStatement.moduleSpecifier) && importStatement.moduleSpecifier.text === typeName) {
75753                             return undefined;
75754                         }
75755                     }
75756                 }
75757                 return { fileName: typeName, pos: -1, end: -1 };
75758             }
75759             function mapReferencesIntoArray(references, outputFilePath) {
75760                 return function (file) {
75761                     var declFileName;
75762                     if (file.isDeclarationFile) {
75763                         declFileName = file.fileName;
75764                     }
75765                     else {
75766                         if (isBundledEmit && ts.contains(node.sourceFiles, file))
75767                             return;
75768                         var paths = ts.getOutputPathsFor(file, host, true);
75769                         declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName;
75770                     }
75771                     if (declFileName) {
75772                         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);
75773                         if (!ts.pathIsRelative(specifier)) {
75774                             recordTypeReferenceDirectivesIfNecessary([specifier]);
75775                             return;
75776                         }
75777                         var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false);
75778                         if (ts.startsWith(fileName, "./") && ts.hasExtension(fileName)) {
75779                             fileName = fileName.substring(2);
75780                         }
75781                         if (ts.startsWith(fileName, "node_modules/") || ts.pathContainsNodeModules(fileName)) {
75782                             return;
75783                         }
75784                         references.push({ pos: -1, end: -1, fileName: fileName });
75785                     }
75786                 };
75787             }
75788         }
75789         function collectReferences(sourceFile, ret) {
75790             if (noResolve || (!ts.isUnparsedSource(sourceFile) && ts.isSourceFileJS(sourceFile)))
75791                 return ret;
75792             ts.forEach(sourceFile.referencedFiles, function (f) {
75793                 var elem = host.getSourceFileFromReference(sourceFile, f);
75794                 if (elem) {
75795                     ret.set("" + ts.getOriginalNodeId(elem), elem);
75796                 }
75797             });
75798             return ret;
75799         }
75800         function collectLibs(sourceFile, ret) {
75801             ts.forEach(sourceFile.libReferenceDirectives, function (ref) {
75802                 var lib = host.getLibFileFromReference(ref);
75803                 if (lib) {
75804                     ret.set(ts.toFileNameLowerCase(ref.fileName), true);
75805                 }
75806             });
75807             return ret;
75808         }
75809         function filterBindingPatternInitializers(name) {
75810             if (name.kind === 75) {
75811                 return name;
75812             }
75813             else {
75814                 if (name.kind === 190) {
75815                     return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement));
75816                 }
75817                 else {
75818                     return ts.updateObjectBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement));
75819                 }
75820             }
75821             function visitBindingElement(elem) {
75822                 if (elem.kind === 215) {
75823                     return elem;
75824                 }
75825                 return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
75826             }
75827         }
75828         function ensureParameter(p, modifierMask, type) {
75829             var oldDiag;
75830             if (!suppressNewDiagnosticContexts) {
75831                 oldDiag = getSymbolAccessibilityDiagnostic;
75832                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p);
75833             }
75834             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));
75835             if (!suppressNewDiagnosticContexts) {
75836                 getSymbolAccessibilityDiagnostic = oldDiag;
75837             }
75838             return newParam;
75839         }
75840         function shouldPrintWithInitializer(node) {
75841             return canHaveLiteralInitializer(node) && resolver.isLiteralConstDeclaration(ts.getParseTreeNode(node));
75842         }
75843         function ensureNoInitializer(node) {
75844             if (shouldPrintWithInitializer(node)) {
75845                 return resolver.createLiteralConstValue(ts.getParseTreeNode(node), symbolTracker);
75846             }
75847             return undefined;
75848         }
75849         function ensureType(node, type, ignorePrivate) {
75850             if (!ignorePrivate && ts.hasModifier(node, 8)) {
75851                 return;
75852             }
75853             if (shouldPrintWithInitializer(node)) {
75854                 return;
75855             }
75856             var shouldUseResolverType = node.kind === 156 &&
75857                 (resolver.isRequiredInitializedParameter(node) ||
75858                     resolver.isOptionalUninitializedParameterProperty(node));
75859             if (type && !shouldUseResolverType) {
75860                 return ts.visitNode(type, visitDeclarationSubtree);
75861             }
75862             if (!ts.getParseTreeNode(node)) {
75863                 return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(125);
75864             }
75865             if (node.kind === 164) {
75866                 return ts.createKeywordTypeNode(125);
75867             }
75868             errorNameNode = node.name;
75869             var oldDiag;
75870             if (!suppressNewDiagnosticContexts) {
75871                 oldDiag = getSymbolAccessibilityDiagnostic;
75872                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node);
75873             }
75874             if (node.kind === 242 || node.kind === 191) {
75875                 return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker));
75876             }
75877             if (node.kind === 156
75878                 || node.kind === 159
75879                 || node.kind === 158) {
75880                 if (!node.initializer)
75881                     return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType));
75882                 return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker));
75883             }
75884             return cleanup(resolver.createReturnTypeOfSignatureDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker));
75885             function cleanup(returnValue) {
75886                 errorNameNode = undefined;
75887                 if (!suppressNewDiagnosticContexts) {
75888                     getSymbolAccessibilityDiagnostic = oldDiag;
75889                 }
75890                 return returnValue || ts.createKeywordTypeNode(125);
75891             }
75892         }
75893         function isDeclarationAndNotVisible(node) {
75894             node = ts.getParseTreeNode(node);
75895             switch (node.kind) {
75896                 case 244:
75897                 case 249:
75898                 case 246:
75899                 case 245:
75900                 case 247:
75901                 case 248:
75902                     return !resolver.isDeclarationVisible(node);
75903                 case 242:
75904                     return !getBindingNameVisible(node);
75905                 case 253:
75906                 case 254:
75907                 case 260:
75908                 case 259:
75909                     return false;
75910             }
75911             return false;
75912         }
75913         function getBindingNameVisible(elem) {
75914             if (ts.isOmittedExpression(elem)) {
75915                 return false;
75916             }
75917             if (ts.isBindingPattern(elem.name)) {
75918                 return ts.some(elem.name.elements, getBindingNameVisible);
75919             }
75920             else {
75921                 return resolver.isDeclarationVisible(elem);
75922             }
75923         }
75924         function updateParamsList(node, params, modifierMask) {
75925             if (ts.hasModifier(node, 8)) {
75926                 return undefined;
75927             }
75928             var newParams = ts.map(params, function (p) { return ensureParameter(p, modifierMask); });
75929             if (!newParams) {
75930                 return undefined;
75931             }
75932             return ts.createNodeArray(newParams, params.hasTrailingComma);
75933         }
75934         function updateAccessorParamsList(input, isPrivate) {
75935             var newParams;
75936             if (!isPrivate) {
75937                 var thisParameter = ts.getThisParameter(input);
75938                 if (thisParameter) {
75939                     newParams = [ensureParameter(thisParameter)];
75940                 }
75941             }
75942             if (ts.isSetAccessorDeclaration(input)) {
75943                 var newValueParameter = void 0;
75944                 if (!isPrivate) {
75945                     var valueParameter = ts.getSetAccessorValueParameter(input);
75946                     if (valueParameter) {
75947                         var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input));
75948                         newValueParameter = ensureParameter(valueParameter, undefined, accessorType);
75949                     }
75950                 }
75951                 if (!newValueParameter) {
75952                     newValueParameter = ts.createParameter(undefined, undefined, undefined, "value");
75953                 }
75954                 newParams = ts.append(newParams, newValueParameter);
75955             }
75956             return ts.createNodeArray(newParams || ts.emptyArray);
75957         }
75958         function ensureTypeParams(node, params) {
75959             return ts.hasModifier(node, 8) ? undefined : ts.visitNodes(params, visitDeclarationSubtree);
75960         }
75961         function isEnclosingDeclaration(node) {
75962             return ts.isSourceFile(node)
75963                 || ts.isTypeAliasDeclaration(node)
75964                 || ts.isModuleDeclaration(node)
75965                 || ts.isClassDeclaration(node)
75966                 || ts.isInterfaceDeclaration(node)
75967                 || ts.isFunctionLike(node)
75968                 || ts.isIndexSignatureDeclaration(node)
75969                 || ts.isMappedTypeNode(node);
75970         }
75971         function checkEntityNameVisibility(entityName, enclosingDeclaration) {
75972             var visibilityResult = resolver.isEntityNameVisible(entityName, enclosingDeclaration);
75973             handleSymbolAccessibilityError(visibilityResult);
75974             recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName));
75975         }
75976         function preserveJsDoc(updated, original) {
75977             if (ts.hasJSDocNodes(updated) && ts.hasJSDocNodes(original)) {
75978                 updated.jsDoc = original.jsDoc;
75979             }
75980             return ts.setCommentRange(updated, ts.getCommentRange(original));
75981         }
75982         function rewriteModuleSpecifier(parent, input) {
75983             if (!input)
75984                 return undefined;
75985             resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 249 && parent.kind !== 188);
75986             if (ts.isStringLiteralLike(input)) {
75987                 if (isBundledEmit) {
75988                     var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent);
75989                     if (newName) {
75990                         return ts.createLiteral(newName);
75991                     }
75992                 }
75993                 else {
75994                     var symbol = resolver.getSymbolOfExternalModuleSpecifier(input);
75995                     if (symbol) {
75996                         (exportedModulesFromDeclarationEmit || (exportedModulesFromDeclarationEmit = [])).push(symbol);
75997                     }
75998                 }
75999             }
76000             return input;
76001         }
76002         function transformImportEqualsDeclaration(decl) {
76003             if (!resolver.isDeclarationVisible(decl))
76004                 return;
76005             if (decl.moduleReference.kind === 265) {
76006                 var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl);
76007                 return ts.updateImportEqualsDeclaration(decl, undefined, decl.modifiers, decl.name, ts.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier)));
76008             }
76009             else {
76010                 var oldDiag = getSymbolAccessibilityDiagnostic;
76011                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(decl);
76012                 checkEntityNameVisibility(decl.moduleReference, enclosingDeclaration);
76013                 getSymbolAccessibilityDiagnostic = oldDiag;
76014                 return decl;
76015             }
76016         }
76017         function transformImportDeclaration(decl) {
76018             if (!decl.importClause) {
76019                 return ts.updateImportDeclaration(decl, undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier));
76020             }
76021             var visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined;
76022             if (!decl.importClause.namedBindings) {
76023                 return visibleDefaultBinding && ts.updateImportDeclaration(decl, undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, undefined, decl.importClause.isTypeOnly), rewriteModuleSpecifier(decl, decl.moduleSpecifier));
76024             }
76025             if (decl.importClause.namedBindings.kind === 256) {
76026                 var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : undefined;
76027                 return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings, decl.importClause.isTypeOnly), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined;
76028             }
76029             var bindingList = ts.mapDefined(decl.importClause.namedBindings.elements, function (b) { return resolver.isDeclarationVisible(b) ? b : undefined; });
76030             if ((bindingList && bindingList.length) || visibleDefaultBinding) {
76031                 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));
76032             }
76033             if (resolver.isImportRequiredByAugmentation(decl)) {
76034                 return ts.updateImportDeclaration(decl, undefined, decl.modifiers, undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier));
76035             }
76036         }
76037         function transformAndReplaceLatePaintedStatements(statements) {
76038             while (ts.length(lateMarkedStatements)) {
76039                 var i = lateMarkedStatements.shift();
76040                 if (!ts.isLateVisibilityPaintedStatement(i)) {
76041                     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));
76042                 }
76043                 var priorNeedsDeclare = needsDeclare;
76044                 needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit);
76045                 var result = transformTopLevelDeclaration(i);
76046                 needsDeclare = priorNeedsDeclare;
76047                 lateStatementReplacementMap.set("" + ts.getOriginalNodeId(i), result);
76048             }
76049             return ts.visitNodes(statements, visitLateVisibilityMarkedStatements);
76050             function visitLateVisibilityMarkedStatements(statement) {
76051                 if (ts.isLateVisibilityPaintedStatement(statement)) {
76052                     var key = "" + ts.getOriginalNodeId(statement);
76053                     if (lateStatementReplacementMap.has(key)) {
76054                         var result = lateStatementReplacementMap.get(key);
76055                         lateStatementReplacementMap.delete(key);
76056                         if (result) {
76057                             if (ts.isArray(result) ? ts.some(result, ts.needsScopeMarker) : ts.needsScopeMarker(result)) {
76058                                 needsScopeFixMarker = true;
76059                             }
76060                             if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, ts.isExternalModuleIndicator) : ts.isExternalModuleIndicator(result))) {
76061                                 resultHasExternalModuleIndicator = true;
76062                             }
76063                         }
76064                         return result;
76065                     }
76066                 }
76067                 return statement;
76068             }
76069         }
76070         function visitDeclarationSubtree(input) {
76071             if (shouldStripInternal(input))
76072                 return;
76073             if (ts.isDeclaration(input)) {
76074                 if (isDeclarationAndNotVisible(input))
76075                     return;
76076                 if (ts.hasDynamicName(input) && !resolver.isLateBound(ts.getParseTreeNode(input))) {
76077                     return;
76078                 }
76079             }
76080             if (ts.isFunctionLike(input) && resolver.isImplementationOfOverload(input))
76081                 return;
76082             if (ts.isSemicolonClassElement(input))
76083                 return;
76084             var previousEnclosingDeclaration;
76085             if (isEnclosingDeclaration(input)) {
76086                 previousEnclosingDeclaration = enclosingDeclaration;
76087                 enclosingDeclaration = input;
76088             }
76089             var oldDiag = getSymbolAccessibilityDiagnostic;
76090             var canProduceDiagnostic = ts.canProduceDiagnostics(input);
76091             var oldWithinObjectLiteralType = suppressNewDiagnosticContexts;
76092             var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 173 || input.kind === 186) && input.parent.kind !== 247);
76093             if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) {
76094                 if (ts.hasModifier(input, 8)) {
76095                     if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input)
76096                         return;
76097                     return cleanup(ts.createProperty(undefined, ensureModifiers(input), input.name, undefined, undefined, undefined));
76098                 }
76099             }
76100             if (canProduceDiagnostic && !suppressNewDiagnosticContexts) {
76101                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input);
76102             }
76103             if (ts.isTypeQueryNode(input)) {
76104                 checkEntityNameVisibility(input.exprName, enclosingDeclaration);
76105             }
76106             if (shouldEnterSuppressNewDiagnosticsContextContext) {
76107                 suppressNewDiagnosticContexts = true;
76108             }
76109             if (isProcessedComponent(input)) {
76110                 switch (input.kind) {
76111                     case 216: {
76112                         if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) {
76113                             checkEntityNameVisibility(input.expression, enclosingDeclaration);
76114                         }
76115                         var node = ts.visitEachChild(input, visitDeclarationSubtree, context);
76116                         return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression));
76117                     }
76118                     case 169: {
76119                         checkEntityNameVisibility(input.typeName, enclosingDeclaration);
76120                         var node = ts.visitEachChild(input, visitDeclarationSubtree, context);
76121                         return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments)));
76122                     }
76123                     case 166:
76124                         return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)));
76125                     case 162: {
76126                         var ctor = ts.createSignatureDeclaration(162, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters, 0), undefined);
76127                         ctor.modifiers = ts.createNodeArray(ensureModifiers(input));
76128                         return cleanup(ctor);
76129                     }
76130                     case 161: {
76131                         if (ts.isPrivateIdentifier(input.name)) {
76132                             return cleanup(undefined);
76133                         }
76134                         var sig = ts.createSignatureDeclaration(160, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type));
76135                         sig.name = input.name;
76136                         sig.modifiers = ts.createNodeArray(ensureModifiers(input));
76137                         sig.questionToken = input.questionToken;
76138                         return cleanup(sig);
76139                     }
76140                     case 163: {
76141                         if (ts.isPrivateIdentifier(input.name)) {
76142                             return cleanup(undefined);
76143                         }
76144                         var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input));
76145                         return cleanup(ts.updateGetAccessor(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8)), ensureType(input, accessorType), undefined));
76146                     }
76147                     case 164: {
76148                         if (ts.isPrivateIdentifier(input.name)) {
76149                             return cleanup(undefined);
76150                         }
76151                         return cleanup(ts.updateSetAccessor(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8)), undefined));
76152                     }
76153                     case 159:
76154                         if (ts.isPrivateIdentifier(input.name)) {
76155                             return cleanup(undefined);
76156                         }
76157                         return cleanup(ts.updateProperty(input, undefined, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input)));
76158                     case 158:
76159                         if (ts.isPrivateIdentifier(input.name)) {
76160                             return cleanup(undefined);
76161                         }
76162                         return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input)));
76163                     case 160: {
76164                         if (ts.isPrivateIdentifier(input.name)) {
76165                             return cleanup(undefined);
76166                         }
76167                         return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken));
76168                     }
76169                     case 165: {
76170                         return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)));
76171                     }
76172                     case 167: {
76173                         return cleanup(ts.updateIndexSignature(input, undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(125)));
76174                     }
76175                     case 242: {
76176                         if (ts.isBindingPattern(input.name)) {
76177                             return recreateBindingPattern(input.name);
76178                         }
76179                         shouldEnterSuppressNewDiagnosticsContextContext = true;
76180                         suppressNewDiagnosticContexts = true;
76181                         return cleanup(ts.updateTypeScriptVariableDeclaration(input, input.name, undefined, ensureType(input, input.type), ensureNoInitializer(input)));
76182                     }
76183                     case 155: {
76184                         if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) {
76185                             return cleanup(ts.updateTypeParameterDeclaration(input, input.name, undefined, undefined));
76186                         }
76187                         return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context));
76188                     }
76189                     case 180: {
76190                         var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree);
76191                         var extendsType = ts.visitNode(input.extendsType, visitDeclarationSubtree);
76192                         var oldEnclosingDecl = enclosingDeclaration;
76193                         enclosingDeclaration = input.trueType;
76194                         var trueType = ts.visitNode(input.trueType, visitDeclarationSubtree);
76195                         enclosingDeclaration = oldEnclosingDecl;
76196                         var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree);
76197                         return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType));
76198                     }
76199                     case 170: {
76200                         return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree)));
76201                     }
76202                     case 171: {
76203                         return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree)));
76204                     }
76205                     case 188: {
76206                         if (!ts.isLiteralImportTypeNode(input))
76207                             return cleanup(input);
76208                         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));
76209                     }
76210                     default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.SyntaxKind[input.kind]);
76211                 }
76212             }
76213             return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context));
76214             function cleanup(returnValue) {
76215                 if (returnValue && canProduceDiagnostic && ts.hasDynamicName(input)) {
76216                     checkName(input);
76217                 }
76218                 if (isEnclosingDeclaration(input)) {
76219                     enclosingDeclaration = previousEnclosingDeclaration;
76220                 }
76221                 if (canProduceDiagnostic && !suppressNewDiagnosticContexts) {
76222                     getSymbolAccessibilityDiagnostic = oldDiag;
76223                 }
76224                 if (shouldEnterSuppressNewDiagnosticsContextContext) {
76225                     suppressNewDiagnosticContexts = oldWithinObjectLiteralType;
76226                 }
76227                 if (returnValue === input) {
76228                     return returnValue;
76229                 }
76230                 return returnValue && ts.setOriginalNode(preserveJsDoc(returnValue, input), input);
76231             }
76232         }
76233         function isPrivateMethodTypeParameter(node) {
76234             return node.parent.kind === 161 && ts.hasModifier(node.parent, 8);
76235         }
76236         function visitDeclarationStatements(input) {
76237             if (!isPreservedDeclarationStatement(input)) {
76238                 return;
76239             }
76240             if (shouldStripInternal(input))
76241                 return;
76242             switch (input.kind) {
76243                 case 260: {
76244                     if (ts.isSourceFile(input.parent)) {
76245                         resultHasExternalModuleIndicator = true;
76246                     }
76247                     resultHasScopeMarker = true;
76248                     return ts.updateExportDeclaration(input, undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier), input.isTypeOnly);
76249                 }
76250                 case 259: {
76251                     if (ts.isSourceFile(input.parent)) {
76252                         resultHasExternalModuleIndicator = true;
76253                     }
76254                     resultHasScopeMarker = true;
76255                     if (input.expression.kind === 75) {
76256                         return input;
76257                     }
76258                     else {
76259                         var newId = ts.createOptimisticUniqueName("_default");
76260                         getSymbolAccessibilityDiagnostic = function () { return ({
76261                             diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0,
76262                             errorNode: input
76263                         }); };
76264                         var varDecl = ts.createVariableDeclaration(newId, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), undefined);
76265                         var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(130)] : [], ts.createVariableDeclarationList([varDecl], 2));
76266                         return [statement, ts.updateExportAssignment(input, input.decorators, input.modifiers, newId)];
76267                     }
76268                 }
76269             }
76270             var result = transformTopLevelDeclaration(input);
76271             lateStatementReplacementMap.set("" + ts.getOriginalNodeId(input), result);
76272             return input;
76273         }
76274         function stripExportModifiers(statement) {
76275             if (ts.isImportEqualsDeclaration(statement) || ts.hasModifier(statement, 512)) {
76276                 return statement;
76277             }
76278             var clone = ts.getMutableClone(statement);
76279             var modifiers = ts.createModifiersFromModifierFlags(ts.getModifierFlags(statement) & (3071 ^ 1));
76280             clone.modifiers = modifiers.length ? ts.createNodeArray(modifiers) : undefined;
76281             return clone;
76282         }
76283         function transformTopLevelDeclaration(input) {
76284             if (shouldStripInternal(input))
76285                 return;
76286             switch (input.kind) {
76287                 case 253: {
76288                     return transformImportEqualsDeclaration(input);
76289                 }
76290                 case 254: {
76291                     return transformImportDeclaration(input);
76292                 }
76293             }
76294             if (ts.isDeclaration(input) && isDeclarationAndNotVisible(input))
76295                 return;
76296             if (ts.isFunctionLike(input) && resolver.isImplementationOfOverload(input))
76297                 return;
76298             var previousEnclosingDeclaration;
76299             if (isEnclosingDeclaration(input)) {
76300                 previousEnclosingDeclaration = enclosingDeclaration;
76301                 enclosingDeclaration = input;
76302             }
76303             var canProdiceDiagnostic = ts.canProduceDiagnostics(input);
76304             var oldDiag = getSymbolAccessibilityDiagnostic;
76305             if (canProdiceDiagnostic) {
76306                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input);
76307             }
76308             var previousNeedsDeclare = needsDeclare;
76309             switch (input.kind) {
76310                 case 247:
76311                     return cleanup(ts.updateTypeAliasDeclaration(input, undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode)));
76312                 case 246: {
76313                     return cleanup(ts.updateInterfaceDeclaration(input, undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree)));
76314                 }
76315                 case 244: {
76316                     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));
76317                     if (clean && resolver.isExpandoFunctionDeclaration(input)) {
76318                         var props = resolver.getPropertiesOfContainerFunction(input);
76319                         var fakespace_1 = ts.createModuleDeclaration(undefined, undefined, clean.name || ts.createIdentifier("_default"), ts.createModuleBlock([]), 16);
76320                         fakespace_1.flags ^= 8;
76321                         fakespace_1.parent = enclosingDeclaration;
76322                         fakespace_1.locals = ts.createSymbolTable(props);
76323                         fakespace_1.symbol = props[0].parent;
76324                         var declarations = ts.mapDefined(props, function (p) {
76325                             if (!ts.isPropertyAccessExpression(p.valueDeclaration)) {
76326                                 return undefined;
76327                             }
76328                             getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration);
76329                             var type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace_1, declarationEmitNodeBuilderFlags, symbolTracker);
76330                             getSymbolAccessibilityDiagnostic = oldDiag;
76331                             var varDecl = ts.createVariableDeclaration(ts.unescapeLeadingUnderscores(p.escapedName), type, undefined);
76332                             return ts.createVariableStatement(undefined, ts.createVariableDeclarationList([varDecl]));
76333                         });
76334                         var namespaceDecl = ts.createModuleDeclaration(undefined, ensureModifiers(input), input.name, ts.createModuleBlock(declarations), 16);
76335                         if (!ts.hasModifier(clean, 512)) {
76336                             return [clean, namespaceDecl];
76337                         }
76338                         var modifiers = ts.createModifiersFromModifierFlags((ts.getModifierFlags(clean) & ~513) | 2);
76339                         var cleanDeclaration = ts.updateFunctionDeclaration(clean, undefined, modifiers, undefined, clean.name, clean.typeParameters, clean.parameters, clean.type, undefined);
76340                         var namespaceDeclaration = ts.updateModuleDeclaration(namespaceDecl, undefined, modifiers, namespaceDecl.name, namespaceDecl.body);
76341                         var exportDefaultDeclaration = ts.createExportAssignment(undefined, undefined, false, namespaceDecl.name);
76342                         if (ts.isSourceFile(input.parent)) {
76343                             resultHasExternalModuleIndicator = true;
76344                         }
76345                         resultHasScopeMarker = true;
76346                         return [cleanDeclaration, namespaceDeclaration, exportDefaultDeclaration];
76347                     }
76348                     else {
76349                         return clean;
76350                     }
76351                 }
76352                 case 249: {
76353                     needsDeclare = false;
76354                     var inner = input.body;
76355                     if (inner && inner.kind === 250) {
76356                         var oldNeedsScopeFix = needsScopeFixMarker;
76357                         var oldHasScopeFix = resultHasScopeMarker;
76358                         resultHasScopeMarker = false;
76359                         needsScopeFixMarker = false;
76360                         var statements = ts.visitNodes(inner.statements, visitDeclarationStatements);
76361                         var lateStatements = transformAndReplaceLatePaintedStatements(statements);
76362                         if (input.flags & 8388608) {
76363                             needsScopeFixMarker = false;
76364                         }
76365                         if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) {
76366                             if (needsScopeFixMarker) {
76367                                 lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [ts.createEmptyExports()]));
76368                             }
76369                             else {
76370                                 lateStatements = ts.visitNodes(lateStatements, stripExportModifiers);
76371                             }
76372                         }
76373                         var body = ts.updateModuleBlock(inner, lateStatements);
76374                         needsDeclare = previousNeedsDeclare;
76375                         needsScopeFixMarker = oldNeedsScopeFix;
76376                         resultHasScopeMarker = oldHasScopeFix;
76377                         var mods = ensureModifiers(input);
76378                         return cleanup(ts.updateModuleDeclaration(input, undefined, mods, ts.isExternalModuleAugmentation(input) ? rewriteModuleSpecifier(input, input.name) : input.name, body));
76379                     }
76380                     else {
76381                         needsDeclare = previousNeedsDeclare;
76382                         var mods = ensureModifiers(input);
76383                         needsDeclare = false;
76384                         ts.visitNode(inner, visitDeclarationStatements);
76385                         var id = "" + ts.getOriginalNodeId(inner);
76386                         var body = lateStatementReplacementMap.get(id);
76387                         lateStatementReplacementMap.delete(id);
76388                         return cleanup(ts.updateModuleDeclaration(input, undefined, mods, input.name, body));
76389                     }
76390                 }
76391                 case 245: {
76392                     var modifiers = ts.createNodeArray(ensureModifiers(input));
76393                     var typeParameters = ensureTypeParams(input, input.typeParameters);
76394                     var ctor = ts.getFirstConstructorWithBody(input);
76395                     var parameterProperties = void 0;
76396                     if (ctor) {
76397                         var oldDiag_1 = getSymbolAccessibilityDiagnostic;
76398                         parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) {
76399                             if (!ts.hasModifier(param, 92) || shouldStripInternal(param))
76400                                 return;
76401                             getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param);
76402                             if (param.name.kind === 75) {
76403                                 return preserveJsDoc(ts.createProperty(undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param);
76404                             }
76405                             else {
76406                                 return walkBindingPattern(param.name);
76407                             }
76408                             function walkBindingPattern(pattern) {
76409                                 var elems;
76410                                 for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
76411                                     var elem = _a[_i];
76412                                     if (ts.isOmittedExpression(elem))
76413                                         continue;
76414                                     if (ts.isBindingPattern(elem.name)) {
76415                                         elems = ts.concatenate(elems, walkBindingPattern(elem.name));
76416                                     }
76417                                     elems = elems || [];
76418                                     elems.push(ts.createProperty(undefined, ensureModifiers(param), elem.name, undefined, ensureType(elem, undefined), undefined));
76419                                 }
76420                                 return elems;
76421                             }
76422                         }));
76423                         getSymbolAccessibilityDiagnostic = oldDiag_1;
76424                     }
76425                     var hasPrivateIdentifier = ts.some(input.members, function (member) { return !!member.name && ts.isPrivateIdentifier(member.name); });
76426                     var privateIdentifier = hasPrivateIdentifier ? [
76427                         ts.createProperty(undefined, undefined, ts.createPrivateIdentifier("#private"), undefined, undefined, undefined)
76428                     ] : undefined;
76429                     var memberNodes = ts.concatenate(ts.concatenate(privateIdentifier, parameterProperties), ts.visitNodes(input.members, visitDeclarationSubtree));
76430                     var members = ts.createNodeArray(memberNodes);
76431                     var extendsClause_1 = ts.getEffectiveBaseTypeNode(input);
76432                     if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 100) {
76433                         var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default";
76434                         var newId_1 = ts.createOptimisticUniqueName(oldId + "_base");
76435                         getSymbolAccessibilityDiagnostic = function () { return ({
76436                             diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1,
76437                             errorNode: extendsClause_1,
76438                             typeName: input.name
76439                         }); };
76440                         var varDecl = ts.createVariableDeclaration(newId_1, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), undefined);
76441                         var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(130)] : [], ts.createVariableDeclarationList([varDecl], 2));
76442                         var heritageClauses = ts.createNodeArray(ts.map(input.heritageClauses, function (clause) {
76443                             if (clause.token === 90) {
76444                                 var oldDiag_2 = getSymbolAccessibilityDiagnostic;
76445                                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]);
76446                                 var newClause = ts.updateHeritageClause(clause, ts.map(clause.types, function (t) { return ts.updateExpressionWithTypeArguments(t, ts.visitNodes(t.typeArguments, visitDeclarationSubtree), newId_1); }));
76447                                 getSymbolAccessibilityDiagnostic = oldDiag_2;
76448                                 return newClause;
76449                             }
76450                             return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 100; })), visitDeclarationSubtree));
76451                         }));
76452                         return [statement, cleanup(ts.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members))];
76453                     }
76454                     else {
76455                         var heritageClauses = transformHeritageClauses(input.heritageClauses);
76456                         return cleanup(ts.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members));
76457                     }
76458                 }
76459                 case 225: {
76460                     return cleanup(transformVariableStatement(input));
76461                 }
76462                 case 248: {
76463                     return cleanup(ts.updateEnumDeclaration(input, undefined, ts.createNodeArray(ensureModifiers(input)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) {
76464                         if (shouldStripInternal(m))
76465                             return;
76466                         var constValue = resolver.getConstantValue(m);
76467                         return preserveJsDoc(ts.updateEnumMember(m, m.name, constValue !== undefined ? ts.createLiteral(constValue) : undefined), m);
76468                     }))));
76469                 }
76470             }
76471             return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.SyntaxKind[input.kind]);
76472             function cleanup(node) {
76473                 if (isEnclosingDeclaration(input)) {
76474                     enclosingDeclaration = previousEnclosingDeclaration;
76475                 }
76476                 if (canProdiceDiagnostic) {
76477                     getSymbolAccessibilityDiagnostic = oldDiag;
76478                 }
76479                 if (input.kind === 249) {
76480                     needsDeclare = previousNeedsDeclare;
76481                 }
76482                 if (node === input) {
76483                     return node;
76484                 }
76485                 return node && ts.setOriginalNode(preserveJsDoc(node, input), input);
76486             }
76487         }
76488         function transformVariableStatement(input) {
76489             if (!ts.forEach(input.declarationList.declarations, getBindingNameVisible))
76490                 return;
76491             var nodes = ts.visitNodes(input.declarationList.declarations, visitDeclarationSubtree);
76492             if (!ts.length(nodes))
76493                 return;
76494             return ts.updateVariableStatement(input, ts.createNodeArray(ensureModifiers(input)), ts.updateVariableDeclarationList(input.declarationList, nodes));
76495         }
76496         function recreateBindingPattern(d) {
76497             return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); }));
76498         }
76499         function recreateBindingElement(e) {
76500             if (e.kind === 215) {
76501                 return;
76502             }
76503             if (e.name) {
76504                 if (!getBindingNameVisible(e))
76505                     return;
76506                 if (ts.isBindingPattern(e.name)) {
76507                     return recreateBindingPattern(e.name);
76508                 }
76509                 else {
76510                     return ts.createVariableDeclaration(e.name, ensureType(e, undefined), undefined);
76511                 }
76512             }
76513         }
76514         function checkName(node) {
76515             var oldDiag;
76516             if (!suppressNewDiagnosticContexts) {
76517                 oldDiag = getSymbolAccessibilityDiagnostic;
76518                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNodeName(node);
76519             }
76520             errorNameNode = node.name;
76521             ts.Debug.assert(resolver.isLateBound(ts.getParseTreeNode(node)));
76522             var decl = node;
76523             var entityName = decl.name.expression;
76524             checkEntityNameVisibility(entityName, enclosingDeclaration);
76525             if (!suppressNewDiagnosticContexts) {
76526                 getSymbolAccessibilityDiagnostic = oldDiag;
76527             }
76528             errorNameNode = undefined;
76529         }
76530         function shouldStripInternal(node) {
76531             return !!stripInternal && !!node && isInternalDeclaration(node, currentSourceFile);
76532         }
76533         function isScopeMarker(node) {
76534             return ts.isExportAssignment(node) || ts.isExportDeclaration(node);
76535         }
76536         function hasScopeMarker(statements) {
76537             return ts.some(statements, isScopeMarker);
76538         }
76539         function ensureModifiers(node) {
76540             var currentFlags = ts.getModifierFlags(node);
76541             var newFlags = ensureModifierFlags(node);
76542             if (currentFlags === newFlags) {
76543                 return node.modifiers;
76544             }
76545             return ts.createModifiersFromModifierFlags(newFlags);
76546         }
76547         function ensureModifierFlags(node) {
76548             var mask = 3071 ^ (4 | 256);
76549             var additions = (needsDeclare && !isAlwaysType(node)) ? 2 : 0;
76550             var parentIsFile = node.parent.kind === 290;
76551             if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) {
76552                 mask ^= 2;
76553                 additions = 0;
76554             }
76555             return maskModifierFlags(node, mask, additions);
76556         }
76557         function getTypeAnnotationFromAllAccessorDeclarations(node, accessors) {
76558             var accessorType = getTypeAnnotationFromAccessor(node);
76559             if (!accessorType && node !== accessors.firstAccessor) {
76560                 accessorType = getTypeAnnotationFromAccessor(accessors.firstAccessor);
76561                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.firstAccessor);
76562             }
76563             if (!accessorType && accessors.secondAccessor && node !== accessors.secondAccessor) {
76564                 accessorType = getTypeAnnotationFromAccessor(accessors.secondAccessor);
76565                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.secondAccessor);
76566             }
76567             return accessorType;
76568         }
76569         function transformHeritageClauses(nodes) {
76570             return ts.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) {
76571                 return ts.isEntityNameExpression(t.expression) || (clause.token === 90 && t.expression.kind === 100);
76572             })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; }));
76573         }
76574     }
76575     ts.transformDeclarations = transformDeclarations;
76576     function isAlwaysType(node) {
76577         if (node.kind === 246) {
76578             return true;
76579         }
76580         return false;
76581     }
76582     function maskModifiers(node, modifierMask, modifierAdditions) {
76583         return ts.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions));
76584     }
76585     function maskModifierFlags(node, modifierMask, modifierAdditions) {
76586         if (modifierMask === void 0) { modifierMask = 3071 ^ 4; }
76587         if (modifierAdditions === void 0) { modifierAdditions = 0; }
76588         var flags = (ts.getModifierFlags(node) & modifierMask) | modifierAdditions;
76589         if (flags & 512 && !(flags & 1)) {
76590             flags ^= 1;
76591         }
76592         if (flags & 512 && flags & 2) {
76593             flags ^= 2;
76594         }
76595         return flags;
76596     }
76597     function getTypeAnnotationFromAccessor(accessor) {
76598         if (accessor) {
76599             return accessor.kind === 163
76600                 ? accessor.type
76601                 : accessor.parameters.length > 0
76602                     ? accessor.parameters[0].type
76603                     : undefined;
76604         }
76605     }
76606     function canHaveLiteralInitializer(node) {
76607         switch (node.kind) {
76608             case 159:
76609             case 158:
76610                 return !ts.hasModifier(node, 8);
76611             case 156:
76612             case 242:
76613                 return true;
76614         }
76615         return false;
76616     }
76617     function isPreservedDeclarationStatement(node) {
76618         switch (node.kind) {
76619             case 244:
76620             case 249:
76621             case 253:
76622             case 246:
76623             case 245:
76624             case 247:
76625             case 248:
76626             case 225:
76627             case 254:
76628             case 260:
76629             case 259:
76630                 return true;
76631         }
76632         return false;
76633     }
76634     function isProcessedComponent(node) {
76635         switch (node.kind) {
76636             case 166:
76637             case 162:
76638             case 161:
76639             case 163:
76640             case 164:
76641             case 159:
76642             case 158:
76643             case 160:
76644             case 165:
76645             case 167:
76646             case 242:
76647             case 155:
76648             case 216:
76649             case 169:
76650             case 180:
76651             case 170:
76652             case 171:
76653             case 188:
76654                 return true;
76655         }
76656         return false;
76657     }
76658 })(ts || (ts = {}));
76659 var ts;
76660 (function (ts) {
76661     function getModuleTransformer(moduleKind) {
76662         switch (moduleKind) {
76663             case ts.ModuleKind.ESNext:
76664             case ts.ModuleKind.ES2020:
76665             case ts.ModuleKind.ES2015:
76666                 return ts.transformECMAScriptModule;
76667             case ts.ModuleKind.System:
76668                 return ts.transformSystemModule;
76669             default:
76670                 return ts.transformModule;
76671         }
76672     }
76673     ts.noTransformers = { scriptTransformers: ts.emptyArray, declarationTransformers: ts.emptyArray };
76674     function getTransformers(compilerOptions, customTransformers, emitOnlyDtsFiles) {
76675         return {
76676             scriptTransformers: getScriptTransformers(compilerOptions, customTransformers, emitOnlyDtsFiles),
76677             declarationTransformers: getDeclarationTransformers(customTransformers),
76678         };
76679     }
76680     ts.getTransformers = getTransformers;
76681     function getScriptTransformers(compilerOptions, customTransformers, emitOnlyDtsFiles) {
76682         if (emitOnlyDtsFiles)
76683             return ts.emptyArray;
76684         var jsx = compilerOptions.jsx;
76685         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
76686         var moduleKind = ts.getEmitModuleKind(compilerOptions);
76687         var transformers = [];
76688         ts.addRange(transformers, customTransformers && ts.map(customTransformers.before, wrapScriptTransformerFactory));
76689         transformers.push(ts.transformTypeScript);
76690         transformers.push(ts.transformClassFields);
76691         if (jsx === 2) {
76692             transformers.push(ts.transformJsx);
76693         }
76694         if (languageVersion < 99) {
76695             transformers.push(ts.transformESNext);
76696         }
76697         if (languageVersion < 7) {
76698             transformers.push(ts.transformES2020);
76699         }
76700         if (languageVersion < 6) {
76701             transformers.push(ts.transformES2019);
76702         }
76703         if (languageVersion < 5) {
76704             transformers.push(ts.transformES2018);
76705         }
76706         if (languageVersion < 4) {
76707             transformers.push(ts.transformES2017);
76708         }
76709         if (languageVersion < 3) {
76710             transformers.push(ts.transformES2016);
76711         }
76712         if (languageVersion < 2) {
76713             transformers.push(ts.transformES2015);
76714             transformers.push(ts.transformGenerators);
76715         }
76716         transformers.push(getModuleTransformer(moduleKind));
76717         if (languageVersion < 1) {
76718             transformers.push(ts.transformES5);
76719         }
76720         ts.addRange(transformers, customTransformers && ts.map(customTransformers.after, wrapScriptTransformerFactory));
76721         return transformers;
76722     }
76723     function getDeclarationTransformers(customTransformers) {
76724         var transformers = [];
76725         transformers.push(ts.transformDeclarations);
76726         ts.addRange(transformers, customTransformers && ts.map(customTransformers.afterDeclarations, wrapDeclarationTransformerFactory));
76727         return transformers;
76728     }
76729     function wrapCustomTransformer(transformer) {
76730         return function (node) { return ts.isBundle(node) ? transformer.transformBundle(node) : transformer.transformSourceFile(node); };
76731     }
76732     function wrapCustomTransformerFactory(transformer, handleDefault) {
76733         return function (context) {
76734             var customTransformer = transformer(context);
76735             return typeof customTransformer === "function"
76736                 ? handleDefault(customTransformer)
76737                 : wrapCustomTransformer(customTransformer);
76738         };
76739     }
76740     function wrapScriptTransformerFactory(transformer) {
76741         return wrapCustomTransformerFactory(transformer, ts.chainBundle);
76742     }
76743     function wrapDeclarationTransformerFactory(transformer) {
76744         return wrapCustomTransformerFactory(transformer, ts.identity);
76745     }
76746     function noEmitSubstitution(_hint, node) {
76747         return node;
76748     }
76749     ts.noEmitSubstitution = noEmitSubstitution;
76750     function noEmitNotification(hint, node, callback) {
76751         callback(hint, node);
76752     }
76753     ts.noEmitNotification = noEmitNotification;
76754     function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) {
76755         var enabledSyntaxKindFeatures = new Array(331);
76756         var lexicalEnvironmentVariableDeclarations;
76757         var lexicalEnvironmentFunctionDeclarations;
76758         var lexicalEnvironmentStatements;
76759         var lexicalEnvironmentFlags = 0;
76760         var lexicalEnvironmentVariableDeclarationsStack = [];
76761         var lexicalEnvironmentFunctionDeclarationsStack = [];
76762         var lexicalEnvironmentStatementsStack = [];
76763         var lexicalEnvironmentFlagsStack = [];
76764         var lexicalEnvironmentStackOffset = 0;
76765         var lexicalEnvironmentSuspended = false;
76766         var emitHelpers;
76767         var onSubstituteNode = noEmitSubstitution;
76768         var onEmitNode = noEmitNotification;
76769         var state = 0;
76770         var diagnostics = [];
76771         var context = {
76772             getCompilerOptions: function () { return options; },
76773             getEmitResolver: function () { return resolver; },
76774             getEmitHost: function () { return host; },
76775             startLexicalEnvironment: startLexicalEnvironment,
76776             suspendLexicalEnvironment: suspendLexicalEnvironment,
76777             resumeLexicalEnvironment: resumeLexicalEnvironment,
76778             endLexicalEnvironment: endLexicalEnvironment,
76779             setLexicalEnvironmentFlags: setLexicalEnvironmentFlags,
76780             getLexicalEnvironmentFlags: getLexicalEnvironmentFlags,
76781             hoistVariableDeclaration: hoistVariableDeclaration,
76782             hoistFunctionDeclaration: hoistFunctionDeclaration,
76783             addInitializationStatement: addInitializationStatement,
76784             requestEmitHelper: requestEmitHelper,
76785             readEmitHelpers: readEmitHelpers,
76786             enableSubstitution: enableSubstitution,
76787             enableEmitNotification: enableEmitNotification,
76788             isSubstitutionEnabled: isSubstitutionEnabled,
76789             isEmitNotificationEnabled: isEmitNotificationEnabled,
76790             get onSubstituteNode() { return onSubstituteNode; },
76791             set onSubstituteNode(value) {
76792                 ts.Debug.assert(state < 1, "Cannot modify transformation hooks after initialization has completed.");
76793                 ts.Debug.assert(value !== undefined, "Value must not be 'undefined'");
76794                 onSubstituteNode = value;
76795             },
76796             get onEmitNode() { return onEmitNode; },
76797             set onEmitNode(value) {
76798                 ts.Debug.assert(state < 1, "Cannot modify transformation hooks after initialization has completed.");
76799                 ts.Debug.assert(value !== undefined, "Value must not be 'undefined'");
76800                 onEmitNode = value;
76801             },
76802             addDiagnostic: function (diag) {
76803                 diagnostics.push(diag);
76804             }
76805         };
76806         for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) {
76807             var node = nodes_4[_i];
76808             ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node)));
76809         }
76810         ts.performance.mark("beforeTransform");
76811         var transformersWithContext = transformers.map(function (t) { return t(context); });
76812         var transformation = function (node) {
76813             for (var _i = 0, transformersWithContext_1 = transformersWithContext; _i < transformersWithContext_1.length; _i++) {
76814                 var transform = transformersWithContext_1[_i];
76815                 node = transform(node);
76816             }
76817             return node;
76818         };
76819         state = 1;
76820         var transformed = ts.map(nodes, allowDtsFiles ? transformation : transformRoot);
76821         state = 2;
76822         ts.performance.mark("afterTransform");
76823         ts.performance.measure("transformTime", "beforeTransform", "afterTransform");
76824         return {
76825             transformed: transformed,
76826             substituteNode: substituteNode,
76827             emitNodeWithNotification: emitNodeWithNotification,
76828             isEmitNotificationEnabled: isEmitNotificationEnabled,
76829             dispose: dispose,
76830             diagnostics: diagnostics
76831         };
76832         function transformRoot(node) {
76833             return node && (!ts.isSourceFile(node) || !node.isDeclarationFile) ? transformation(node) : node;
76834         }
76835         function enableSubstitution(kind) {
76836             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
76837             enabledSyntaxKindFeatures[kind] |= 1;
76838         }
76839         function isSubstitutionEnabled(node) {
76840             return (enabledSyntaxKindFeatures[node.kind] & 1) !== 0
76841                 && (ts.getEmitFlags(node) & 4) === 0;
76842         }
76843         function substituteNode(hint, node) {
76844             ts.Debug.assert(state < 3, "Cannot substitute a node after the result is disposed.");
76845             return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node;
76846         }
76847         function enableEmitNotification(kind) {
76848             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
76849             enabledSyntaxKindFeatures[kind] |= 2;
76850         }
76851         function isEmitNotificationEnabled(node) {
76852             return (enabledSyntaxKindFeatures[node.kind] & 2) !== 0
76853                 || (ts.getEmitFlags(node) & 2) !== 0;
76854         }
76855         function emitNodeWithNotification(hint, node, emitCallback) {
76856             ts.Debug.assert(state < 3, "Cannot invoke TransformationResult callbacks after the result is disposed.");
76857             if (node) {
76858                 if (isEmitNotificationEnabled(node)) {
76859                     onEmitNode(hint, node, emitCallback);
76860                 }
76861                 else {
76862                     emitCallback(hint, node);
76863                 }
76864             }
76865         }
76866         function hoistVariableDeclaration(name) {
76867             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76868             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76869             var decl = ts.setEmitFlags(ts.createVariableDeclaration(name), 64);
76870             if (!lexicalEnvironmentVariableDeclarations) {
76871                 lexicalEnvironmentVariableDeclarations = [decl];
76872             }
76873             else {
76874                 lexicalEnvironmentVariableDeclarations.push(decl);
76875             }
76876             if (lexicalEnvironmentFlags & 1) {
76877                 lexicalEnvironmentFlags |= 2;
76878             }
76879         }
76880         function hoistFunctionDeclaration(func) {
76881             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76882             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76883             ts.setEmitFlags(func, 1048576);
76884             if (!lexicalEnvironmentFunctionDeclarations) {
76885                 lexicalEnvironmentFunctionDeclarations = [func];
76886             }
76887             else {
76888                 lexicalEnvironmentFunctionDeclarations.push(func);
76889             }
76890         }
76891         function addInitializationStatement(node) {
76892             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76893             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76894             ts.setEmitFlags(node, 1048576);
76895             if (!lexicalEnvironmentStatements) {
76896                 lexicalEnvironmentStatements = [node];
76897             }
76898             else {
76899                 lexicalEnvironmentStatements.push(node);
76900             }
76901         }
76902         function startLexicalEnvironment() {
76903             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76904             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76905             ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended.");
76906             lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentVariableDeclarations;
76907             lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFunctionDeclarations;
76908             lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentStatements;
76909             lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFlags;
76910             lexicalEnvironmentStackOffset++;
76911             lexicalEnvironmentVariableDeclarations = undefined;
76912             lexicalEnvironmentFunctionDeclarations = undefined;
76913             lexicalEnvironmentStatements = undefined;
76914             lexicalEnvironmentFlags = 0;
76915         }
76916         function suspendLexicalEnvironment() {
76917             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76918             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76919             ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended.");
76920             lexicalEnvironmentSuspended = true;
76921         }
76922         function resumeLexicalEnvironment() {
76923             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76924             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76925             ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended.");
76926             lexicalEnvironmentSuspended = false;
76927         }
76928         function endLexicalEnvironment() {
76929             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76930             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76931             ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended.");
76932             var statements;
76933             if (lexicalEnvironmentVariableDeclarations ||
76934                 lexicalEnvironmentFunctionDeclarations ||
76935                 lexicalEnvironmentStatements) {
76936                 if (lexicalEnvironmentFunctionDeclarations) {
76937                     statements = __spreadArrays(lexicalEnvironmentFunctionDeclarations);
76938                 }
76939                 if (lexicalEnvironmentVariableDeclarations) {
76940                     var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList(lexicalEnvironmentVariableDeclarations));
76941                     ts.setEmitFlags(statement, 1048576);
76942                     if (!statements) {
76943                         statements = [statement];
76944                     }
76945                     else {
76946                         statements.push(statement);
76947                     }
76948                 }
76949                 if (lexicalEnvironmentStatements) {
76950                     if (!statements) {
76951                         statements = __spreadArrays(lexicalEnvironmentStatements);
76952                     }
76953                     else {
76954                         statements = __spreadArrays(statements, lexicalEnvironmentStatements);
76955                     }
76956                 }
76957             }
76958             lexicalEnvironmentStackOffset--;
76959             lexicalEnvironmentVariableDeclarations = lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset];
76960             lexicalEnvironmentFunctionDeclarations = lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset];
76961             lexicalEnvironmentStatements = lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset];
76962             lexicalEnvironmentFlags = lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset];
76963             if (lexicalEnvironmentStackOffset === 0) {
76964                 lexicalEnvironmentVariableDeclarationsStack = [];
76965                 lexicalEnvironmentFunctionDeclarationsStack = [];
76966                 lexicalEnvironmentStatementsStack = [];
76967                 lexicalEnvironmentFlagsStack = [];
76968             }
76969             return statements;
76970         }
76971         function setLexicalEnvironmentFlags(flags, value) {
76972             lexicalEnvironmentFlags = value ?
76973                 lexicalEnvironmentFlags | flags :
76974                 lexicalEnvironmentFlags & ~flags;
76975         }
76976         function getLexicalEnvironmentFlags() {
76977             return lexicalEnvironmentFlags;
76978         }
76979         function requestEmitHelper(helper) {
76980             ts.Debug.assert(state > 0, "Cannot modify the transformation context during initialization.");
76981             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
76982             ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper.");
76983             if (helper.dependencies) {
76984                 for (var _i = 0, _a = helper.dependencies; _i < _a.length; _i++) {
76985                     var h = _a[_i];
76986                     requestEmitHelper(h);
76987                 }
76988             }
76989             emitHelpers = ts.append(emitHelpers, helper);
76990         }
76991         function readEmitHelpers() {
76992             ts.Debug.assert(state > 0, "Cannot modify the transformation context during initialization.");
76993             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
76994             var helpers = emitHelpers;
76995             emitHelpers = undefined;
76996             return helpers;
76997         }
76998         function dispose() {
76999             if (state < 3) {
77000                 for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) {
77001                     var node = nodes_5[_i];
77002                     ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node)));
77003                 }
77004                 lexicalEnvironmentVariableDeclarations = undefined;
77005                 lexicalEnvironmentVariableDeclarationsStack = undefined;
77006                 lexicalEnvironmentFunctionDeclarations = undefined;
77007                 lexicalEnvironmentFunctionDeclarationsStack = undefined;
77008                 onSubstituteNode = undefined;
77009                 onEmitNode = undefined;
77010                 emitHelpers = undefined;
77011                 state = 3;
77012             }
77013         }
77014     }
77015     ts.transformNodes = transformNodes;
77016 })(ts || (ts = {}));
77017 var ts;
77018 (function (ts) {
77019     var brackets = createBracketsMap();
77020     var syntheticParent = { pos: -1, end: -1 };
77021     function isBuildInfoFile(file) {
77022         return ts.fileExtensionIs(file, ".tsbuildinfo");
77023     }
77024     ts.isBuildInfoFile = isBuildInfoFile;
77025     function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) {
77026         if (forceDtsEmit === void 0) { forceDtsEmit = false; }
77027         var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile, forceDtsEmit);
77028         var options = host.getCompilerOptions();
77029         if (options.outFile || options.out) {
77030             var prepends = host.getPrependNodes();
77031             if (sourceFiles.length || prepends.length) {
77032                 var bundle = ts.createBundle(sourceFiles, prepends);
77033                 var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle);
77034                 if (result) {
77035                     return result;
77036                 }
77037             }
77038         }
77039         else {
77040             if (!onlyBuildInfo) {
77041                 for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) {
77042                     var sourceFile = sourceFiles_1[_a];
77043                     var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile);
77044                     if (result) {
77045                         return result;
77046                     }
77047                 }
77048             }
77049             if (includeBuildInfo) {
77050                 var buildInfoPath = getTsBuildInfoEmitOutputFilePath(host.getCompilerOptions());
77051                 if (buildInfoPath)
77052                     return action({ buildInfoPath: buildInfoPath }, undefined);
77053             }
77054         }
77055     }
77056     ts.forEachEmittedFile = forEachEmittedFile;
77057     function getTsBuildInfoEmitOutputFilePath(options) {
77058         var configFile = options.configFilePath;
77059         if (!ts.isIncrementalCompilation(options))
77060             return undefined;
77061         if (options.tsBuildInfoFile)
77062             return options.tsBuildInfoFile;
77063         var outPath = options.outFile || options.out;
77064         var buildInfoExtensionLess;
77065         if (outPath) {
77066             buildInfoExtensionLess = ts.removeFileExtension(outPath);
77067         }
77068         else {
77069             if (!configFile)
77070                 return undefined;
77071             var configFileExtensionLess = ts.removeFileExtension(configFile);
77072             buildInfoExtensionLess = options.outDir ?
77073                 options.rootDir ?
77074                     ts.resolvePath(options.outDir, ts.getRelativePathFromDirectory(options.rootDir, configFileExtensionLess, true)) :
77075                     ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) :
77076                 configFileExtensionLess;
77077         }
77078         return buildInfoExtensionLess + ".tsbuildinfo";
77079     }
77080     ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath;
77081     function getOutputPathsForBundle(options, forceDtsPaths) {
77082         var outPath = options.outFile || options.out;
77083         var jsFilePath = options.emitDeclarationOnly ? undefined : outPath;
77084         var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options);
77085         var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" : undefined;
77086         var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined;
77087         var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options);
77088         return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath };
77089     }
77090     ts.getOutputPathsForBundle = getOutputPathsForBundle;
77091     function getOutputPathsFor(sourceFile, host, forceDtsPaths) {
77092         var options = host.getCompilerOptions();
77093         if (sourceFile.kind === 291) {
77094             return getOutputPathsForBundle(options, forceDtsPaths);
77095         }
77096         else {
77097             var ownOutputFilePath = ts.getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options));
77098             var isJsonFile = ts.isJsonSourceFile(sourceFile);
77099             var isJsonEmittedToSameLocation = isJsonFile &&
77100                 ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0;
77101             var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath;
77102             var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options);
77103             var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined;
77104             var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined;
77105             return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined };
77106         }
77107     }
77108     ts.getOutputPathsFor = getOutputPathsFor;
77109     function getSourceMapFilePath(jsFilePath, options) {
77110         return (options.sourceMap && !options.inlineSourceMap) ? jsFilePath + ".map" : undefined;
77111     }
77112     function getOutputExtension(sourceFile, options) {
77113         if (ts.isJsonSourceFile(sourceFile)) {
77114             return ".json";
77115         }
77116         if (options.jsx === 1) {
77117             if (ts.isSourceFileJS(sourceFile)) {
77118                 if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) {
77119                     return ".jsx";
77120                 }
77121             }
77122             else if (sourceFile.languageVariant === 1) {
77123                 return ".jsx";
77124             }
77125         }
77126         return ".js";
77127     }
77128     ts.getOutputExtension = getOutputExtension;
77129     function rootDirOfOptions(configFile) {
77130         return configFile.options.rootDir || ts.getDirectoryPath(ts.Debug.checkDefined(configFile.options.configFilePath));
77131     }
77132     function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir) {
77133         return outputDir ?
77134             ts.resolvePath(outputDir, ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase)) :
77135             inputFileName;
77136     }
77137     function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) {
77138         ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts") && !ts.fileExtensionIs(inputFileName, ".json"));
77139         return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts");
77140     }
77141     ts.getOutputDeclarationFileName = getOutputDeclarationFileName;
77142     function getOutputJSFileName(inputFileName, configFile, ignoreCase) {
77143         if (configFile.options.emitDeclarationOnly)
77144             return undefined;
77145         var isJsonFile = ts.fileExtensionIs(inputFileName, ".json");
77146         var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ?
77147             ".json" :
77148             ts.fileExtensionIs(inputFileName, ".tsx") && configFile.options.jsx === 1 ?
77149                 ".jsx" :
77150                 ".js");
77151         return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 ?
77152             outputFileName :
77153             undefined;
77154     }
77155     function createAddOutput() {
77156         var outputs;
77157         return { addOutput: addOutput, getOutputs: getOutputs };
77158         function addOutput(path) {
77159             if (path) {
77160                 (outputs || (outputs = [])).push(path);
77161             }
77162         }
77163         function getOutputs() {
77164             return outputs || ts.emptyArray;
77165         }
77166     }
77167     function getSingleOutputFileNames(configFile, addOutput) {
77168         var _a = getOutputPathsForBundle(configFile.options, false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
77169         addOutput(jsFilePath);
77170         addOutput(sourceMapFilePath);
77171         addOutput(declarationFilePath);
77172         addOutput(declarationMapPath);
77173         addOutput(buildInfoPath);
77174     }
77175     function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput) {
77176         if (ts.fileExtensionIs(inputFileName, ".d.ts"))
77177             return;
77178         var js = getOutputJSFileName(inputFileName, configFile, ignoreCase);
77179         addOutput(js);
77180         if (ts.fileExtensionIs(inputFileName, ".json"))
77181             return;
77182         if (js && configFile.options.sourceMap) {
77183             addOutput(js + ".map");
77184         }
77185         if (ts.getEmitDeclarations(configFile.options)) {
77186             var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase);
77187             addOutput(dts);
77188             if (configFile.options.declarationMap) {
77189                 addOutput(dts + ".map");
77190             }
77191         }
77192     }
77193     function getAllProjectOutputs(configFile, ignoreCase) {
77194         var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs;
77195         if (configFile.options.outFile || configFile.options.out) {
77196             getSingleOutputFileNames(configFile, addOutput);
77197         }
77198         else {
77199             for (var _b = 0, _c = configFile.fileNames; _b < _c.length; _b++) {
77200                 var inputFileName = _c[_b];
77201                 getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput);
77202             }
77203             addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options));
77204         }
77205         return getOutputs();
77206     }
77207     ts.getAllProjectOutputs = getAllProjectOutputs;
77208     function getOutputFileNames(commandLine, inputFileName, ignoreCase) {
77209         inputFileName = ts.normalizePath(inputFileName);
77210         ts.Debug.assert(ts.contains(commandLine.fileNames, inputFileName), "Expected fileName to be present in command line");
77211         var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs;
77212         if (commandLine.options.outFile || commandLine.options.out) {
77213             getSingleOutputFileNames(commandLine, addOutput);
77214         }
77215         else {
77216             getOwnOutputFileNames(commandLine, inputFileName, ignoreCase, addOutput);
77217         }
77218         return getOutputs();
77219     }
77220     ts.getOutputFileNames = getOutputFileNames;
77221     function getFirstProjectOutput(configFile, ignoreCase) {
77222         if (configFile.options.outFile || configFile.options.out) {
77223             var jsFilePath = getOutputPathsForBundle(configFile.options, false).jsFilePath;
77224             return ts.Debug.checkDefined(jsFilePath, "project " + configFile.options.configFilePath + " expected to have at least one output");
77225         }
77226         for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) {
77227             var inputFileName = _b[_a];
77228             if (ts.fileExtensionIs(inputFileName, ".d.ts"))
77229                 continue;
77230             var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase);
77231             if (jsFilePath)
77232                 return jsFilePath;
77233             if (ts.fileExtensionIs(inputFileName, ".json"))
77234                 continue;
77235             if (ts.getEmitDeclarations(configFile.options)) {
77236                 return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase);
77237             }
77238         }
77239         var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options);
77240         if (buildInfoPath)
77241             return buildInfoPath;
77242         return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output");
77243     }
77244     ts.getFirstProjectOutput = getFirstProjectOutput;
77245     function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) {
77246         var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers;
77247         var compilerOptions = host.getCompilerOptions();
77248         var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined;
77249         var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined;
77250         var emitterDiagnostics = ts.createDiagnosticCollection();
77251         var newLine = ts.getNewLineCharacter(compilerOptions, function () { return host.getNewLine(); });
77252         var writer = ts.createTextWriter(newLine);
77253         var _b = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _b.enter, exit = _b.exit;
77254         var bundleBuildInfo;
77255         var emitSkipped = false;
77256         var exportedModulesFromDeclarationEmit;
77257         enter();
77258         forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit), forceDtsEmit, onlyBuildInfo, !targetSourceFile);
77259         exit();
77260         return {
77261             emitSkipped: emitSkipped,
77262             diagnostics: emitterDiagnostics.getDiagnostics(),
77263             emittedFiles: emittedFilesList,
77264             sourceMaps: sourceMapDataList,
77265             exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit
77266         };
77267         function emitSourceFileOrBundle(_a, sourceFileOrBundle) {
77268             var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
77269             var buildInfoDirectory;
77270             if (buildInfoPath && sourceFileOrBundle && ts.isBundle(sourceFileOrBundle)) {
77271                 buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
77272                 bundleBuildInfo = {
77273                     commonSourceDirectory: relativeToBuildInfo(host.getCommonSourceDirectory()),
77274                     sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); })
77275                 };
77276             }
77277             emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo);
77278             emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo);
77279             emitBuildInfo(bundleBuildInfo, buildInfoPath);
77280             if (!emitSkipped && emittedFilesList) {
77281                 if (!emitOnlyDtsFiles) {
77282                     if (jsFilePath) {
77283                         emittedFilesList.push(jsFilePath);
77284                     }
77285                     if (sourceMapFilePath) {
77286                         emittedFilesList.push(sourceMapFilePath);
77287                     }
77288                     if (buildInfoPath) {
77289                         emittedFilesList.push(buildInfoPath);
77290                     }
77291                 }
77292                 if (declarationFilePath) {
77293                     emittedFilesList.push(declarationFilePath);
77294                 }
77295                 if (declarationMapPath) {
77296                     emittedFilesList.push(declarationMapPath);
77297                 }
77298             }
77299             function relativeToBuildInfo(path) {
77300                 return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, host.getCanonicalFileName));
77301             }
77302         }
77303         function emitBuildInfo(bundle, buildInfoPath) {
77304             if (!buildInfoPath || targetSourceFile || emitSkipped)
77305                 return;
77306             var program = host.getProgramBuildInfo();
77307             if (host.isEmitBlocked(buildInfoPath) || compilerOptions.noEmit) {
77308                 emitSkipped = true;
77309                 return;
77310             }
77311             var version = ts.version;
77312             ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText({ bundle: bundle, program: program, version: version }), false);
77313         }
77314         function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo) {
77315             if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) {
77316                 return;
77317             }
77318             if ((jsFilePath && host.isEmitBlocked(jsFilePath)) || compilerOptions.noEmit) {
77319                 emitSkipped = true;
77320                 return;
77321             }
77322             var transform = ts.transformNodes(resolver, host, compilerOptions, [sourceFileOrBundle], scriptTransformers, false);
77323             var printerOptions = {
77324                 removeComments: compilerOptions.removeComments,
77325                 newLine: compilerOptions.newLine,
77326                 noEmitHelpers: compilerOptions.noEmitHelpers,
77327                 module: compilerOptions.module,
77328                 target: compilerOptions.target,
77329                 sourceMap: compilerOptions.sourceMap,
77330                 inlineSourceMap: compilerOptions.inlineSourceMap,
77331                 inlineSources: compilerOptions.inlineSources,
77332                 extendedDiagnostics: compilerOptions.extendedDiagnostics,
77333                 writeBundleFileInfo: !!bundleBuildInfo,
77334                 relativeToBuildInfo: relativeToBuildInfo
77335             };
77336             var printer = createPrinter(printerOptions, {
77337                 hasGlobalName: resolver.hasGlobalName,
77338                 onEmitNode: transform.emitNodeWithNotification,
77339                 isEmitNotificationEnabled: transform.isEmitNotificationEnabled,
77340                 substituteNode: transform.substituteNode,
77341             });
77342             ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform");
77343             printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions);
77344             transform.dispose();
77345             if (bundleBuildInfo)
77346                 bundleBuildInfo.js = printer.bundleFileInfo;
77347         }
77348         function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo) {
77349             if (!sourceFileOrBundle)
77350                 return;
77351             if (!declarationFilePath) {
77352                 if (emitOnlyDtsFiles || compilerOptions.emitDeclarationOnly)
77353                     emitSkipped = true;
77354                 return;
77355             }
77356             var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles;
77357             var filesForEmit = forceDtsEmit ? sourceFiles : ts.filter(sourceFiles, ts.isSourceFileNotJson);
77358             var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(filesForEmit, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : filesForEmit;
77359             if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) {
77360                 filesForEmit.forEach(collectLinkedAliases);
77361             }
77362             var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, false);
77363             if (ts.length(declarationTransform.diagnostics)) {
77364                 for (var _a = 0, _b = declarationTransform.diagnostics; _a < _b.length; _a++) {
77365                     var diagnostic = _b[_a];
77366                     emitterDiagnostics.add(diagnostic);
77367                 }
77368             }
77369             var printerOptions = {
77370                 removeComments: compilerOptions.removeComments,
77371                 newLine: compilerOptions.newLine,
77372                 noEmitHelpers: true,
77373                 module: compilerOptions.module,
77374                 target: compilerOptions.target,
77375                 sourceMap: compilerOptions.sourceMap,
77376                 inlineSourceMap: compilerOptions.inlineSourceMap,
77377                 extendedDiagnostics: compilerOptions.extendedDiagnostics,
77378                 onlyPrintJsDocStyle: true,
77379                 writeBundleFileInfo: !!bundleBuildInfo,
77380                 recordInternalSection: !!bundleBuildInfo,
77381                 relativeToBuildInfo: relativeToBuildInfo
77382             };
77383             var declarationPrinter = createPrinter(printerOptions, {
77384                 hasGlobalName: resolver.hasGlobalName,
77385                 onEmitNode: declarationTransform.emitNodeWithNotification,
77386                 isEmitNotificationEnabled: declarationTransform.isEmitNotificationEnabled,
77387                 substituteNode: declarationTransform.substituteNode,
77388             });
77389             var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit;
77390             emitSkipped = emitSkipped || declBlocked;
77391             if (!declBlocked || forceDtsEmit) {
77392                 ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform");
77393                 printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, {
77394                     sourceMap: compilerOptions.declarationMap,
77395                     sourceRoot: compilerOptions.sourceRoot,
77396                     mapRoot: compilerOptions.mapRoot,
77397                     extendedDiagnostics: compilerOptions.extendedDiagnostics,
77398                 });
77399                 if (forceDtsEmit && declarationTransform.transformed[0].kind === 290) {
77400                     var sourceFile = declarationTransform.transformed[0];
77401                     exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit;
77402                 }
77403             }
77404             declarationTransform.dispose();
77405             if (bundleBuildInfo)
77406                 bundleBuildInfo.dts = declarationPrinter.bundleFileInfo;
77407         }
77408         function collectLinkedAliases(node) {
77409             if (ts.isExportAssignment(node)) {
77410                 if (node.expression.kind === 75) {
77411                     resolver.collectLinkedAliases(node.expression, true);
77412                 }
77413                 return;
77414             }
77415             else if (ts.isExportSpecifier(node)) {
77416                 resolver.collectLinkedAliases(node.propertyName || node.name, true);
77417                 return;
77418             }
77419             ts.forEachChild(node, collectLinkedAliases);
77420         }
77421         function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) {
77422             var bundle = sourceFileOrBundle.kind === 291 ? sourceFileOrBundle : undefined;
77423             var sourceFile = sourceFileOrBundle.kind === 290 ? sourceFileOrBundle : undefined;
77424             var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile];
77425             var sourceMapGenerator;
77426             if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) {
77427                 sourceMapGenerator = ts.createSourceMapGenerator(host, ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)), getSourceRoot(mapOptions), getSourceMapDirectory(mapOptions, jsFilePath, sourceFile), mapOptions);
77428             }
77429             if (bundle) {
77430                 printer.writeBundle(bundle, writer, sourceMapGenerator);
77431             }
77432             else {
77433                 printer.writeFile(sourceFile, writer, sourceMapGenerator);
77434             }
77435             if (sourceMapGenerator) {
77436                 if (sourceMapDataList) {
77437                     sourceMapDataList.push({
77438                         inputSourceFileNames: sourceMapGenerator.getSources(),
77439                         sourceMap: sourceMapGenerator.toJSON()
77440                     });
77441                 }
77442                 var sourceMappingURL = getSourceMappingURL(mapOptions, sourceMapGenerator, jsFilePath, sourceMapFilePath, sourceFile);
77443                 if (sourceMappingURL) {
77444                     if (!writer.isAtStartOfLine())
77445                         writer.rawWrite(newLine);
77446                     writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL);
77447                 }
77448                 if (sourceMapFilePath) {
77449                     var sourceMap = sourceMapGenerator.toString();
77450                     ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, false, sourceFiles);
77451                 }
77452             }
77453             else {
77454                 writer.writeLine();
77455             }
77456             ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles);
77457             writer.clear();
77458         }
77459         function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) {
77460             return (mapOptions.sourceMap || mapOptions.inlineSourceMap)
77461                 && (sourceFileOrBundle.kind !== 290 || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json"));
77462         }
77463         function getSourceRoot(mapOptions) {
77464             var sourceRoot = ts.normalizeSlashes(mapOptions.sourceRoot || "");
77465             return sourceRoot ? ts.ensureTrailingDirectorySeparator(sourceRoot) : sourceRoot;
77466         }
77467         function getSourceMapDirectory(mapOptions, filePath, sourceFile) {
77468             if (mapOptions.sourceRoot)
77469                 return host.getCommonSourceDirectory();
77470             if (mapOptions.mapRoot) {
77471                 var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot);
77472                 if (sourceFile) {
77473                     sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir));
77474                 }
77475                 if (ts.getRootLength(sourceMapDir) === 0) {
77476                     sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir);
77477                 }
77478                 return sourceMapDir;
77479             }
77480             return ts.getDirectoryPath(ts.normalizePath(filePath));
77481         }
77482         function getSourceMappingURL(mapOptions, sourceMapGenerator, filePath, sourceMapFilePath, sourceFile) {
77483             if (mapOptions.inlineSourceMap) {
77484                 var sourceMapText = sourceMapGenerator.toString();
77485                 var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText);
77486                 return "data:application/json;base64," + base64SourceMapText;
77487             }
77488             var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.checkDefined(sourceMapFilePath)));
77489             if (mapOptions.mapRoot) {
77490                 var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot);
77491                 if (sourceFile) {
77492                     sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir));
77493                 }
77494                 if (ts.getRootLength(sourceMapDir) === 0) {
77495                     sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir);
77496                     return ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(filePath)), ts.combinePaths(sourceMapDir, sourceMapFile), host.getCurrentDirectory(), host.getCanonicalFileName, true);
77497                 }
77498                 else {
77499                     return ts.combinePaths(sourceMapDir, sourceMapFile);
77500                 }
77501             }
77502             return sourceMapFile;
77503         }
77504     }
77505     ts.emitFiles = emitFiles;
77506     function getBuildInfoText(buildInfo) {
77507         return JSON.stringify(buildInfo, undefined, 2);
77508     }
77509     ts.getBuildInfoText = getBuildInfoText;
77510     function getBuildInfo(buildInfoText) {
77511         return JSON.parse(buildInfoText);
77512     }
77513     ts.getBuildInfo = getBuildInfo;
77514     ts.notImplementedResolver = {
77515         hasGlobalName: ts.notImplemented,
77516         getReferencedExportContainer: ts.notImplemented,
77517         getReferencedImportDeclaration: ts.notImplemented,
77518         getReferencedDeclarationWithCollidingName: ts.notImplemented,
77519         isDeclarationWithCollidingName: ts.notImplemented,
77520         isValueAliasDeclaration: ts.notImplemented,
77521         isReferencedAliasDeclaration: ts.notImplemented,
77522         isTopLevelValueImportEqualsWithEntityName: ts.notImplemented,
77523         getNodeCheckFlags: ts.notImplemented,
77524         isDeclarationVisible: ts.notImplemented,
77525         isLateBound: function (_node) { return false; },
77526         collectLinkedAliases: ts.notImplemented,
77527         isImplementationOfOverload: ts.notImplemented,
77528         isRequiredInitializedParameter: ts.notImplemented,
77529         isOptionalUninitializedParameterProperty: ts.notImplemented,
77530         isExpandoFunctionDeclaration: ts.notImplemented,
77531         getPropertiesOfContainerFunction: ts.notImplemented,
77532         createTypeOfDeclaration: ts.notImplemented,
77533         createReturnTypeOfSignatureDeclaration: ts.notImplemented,
77534         createTypeOfExpression: ts.notImplemented,
77535         createLiteralConstValue: ts.notImplemented,
77536         isSymbolAccessible: ts.notImplemented,
77537         isEntityNameVisible: ts.notImplemented,
77538         getConstantValue: ts.notImplemented,
77539         getReferencedValueDeclaration: ts.notImplemented,
77540         getTypeReferenceSerializationKind: ts.notImplemented,
77541         isOptionalParameter: ts.notImplemented,
77542         moduleExportsSomeValue: ts.notImplemented,
77543         isArgumentsLocalBinding: ts.notImplemented,
77544         getExternalModuleFileFromDeclaration: ts.notImplemented,
77545         getTypeReferenceDirectivesForEntityName: ts.notImplemented,
77546         getTypeReferenceDirectivesForSymbol: ts.notImplemented,
77547         isLiteralConstDeclaration: ts.notImplemented,
77548         getJsxFactoryEntity: ts.notImplemented,
77549         getAllAccessorDeclarations: ts.notImplemented,
77550         getSymbolOfExternalModuleSpecifier: ts.notImplemented,
77551         isBindingCapturedByNode: ts.notImplemented,
77552         getDeclarationStatementsForSourceFile: ts.notImplemented,
77553         isImportRequiredByAugmentation: ts.notImplemented,
77554     };
77555     function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) {
77556         var sourceFiles = bundle.sourceFiles.map(function (fileName) {
77557             var sourceFile = ts.createNode(290, 0, 0);
77558             sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames());
77559             sourceFile.text = "";
77560             sourceFile.statements = ts.createNodeArray();
77561             return sourceFile;
77562         });
77563         var jsBundle = ts.Debug.checkDefined(bundle.js);
77564         ts.forEach(jsBundle.sources && jsBundle.sources.prologues, function (prologueInfo) {
77565             var sourceFile = sourceFiles[prologueInfo.file];
77566             sourceFile.text = prologueInfo.text;
77567             sourceFile.end = prologueInfo.text.length;
77568             sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) {
77569                 var statement = ts.createNode(226, directive.pos, directive.end);
77570                 statement.expression = ts.createNode(10, directive.expression.pos, directive.expression.end);
77571                 statement.expression.text = directive.expression.text;
77572                 return statement;
77573             }));
77574         });
77575         return sourceFiles;
77576     }
77577     function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
77578         var _a = getOutputPathsForBundle(config.options, false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
77579         var buildInfoText = host.readFile(ts.Debug.checkDefined(buildInfoPath));
77580         if (!buildInfoText)
77581             return buildInfoPath;
77582         var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
77583         if (!jsFileText)
77584             return jsFilePath;
77585         var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
77586         if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
77587             return sourceMapFilePath || "inline sourcemap decoding";
77588         var declarationText = declarationFilePath && host.readFile(declarationFilePath);
77589         if (declarationFilePath && !declarationText)
77590             return declarationFilePath;
77591         var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
77592         if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
77593             return declarationMapPath || "inline sourcemap decoding";
77594         var buildInfo = getBuildInfo(buildInfoText);
77595         if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts))
77596             return buildInfoPath;
77597         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
77598         var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, true);
77599         var outputFiles = [];
77600         var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); });
77601         var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host);
77602         var emitHost = {
77603             getPrependNodes: ts.memoize(function () { return __spreadArrays(prependNodes, [ownPrependInput]); }),
77604             getCanonicalFileName: host.getCanonicalFileName,
77605             getCommonSourceDirectory: function () { return ts.getNormalizedAbsolutePath(buildInfo.bundle.commonSourceDirectory, buildInfoDirectory); },
77606             getCompilerOptions: function () { return config.options; },
77607             getCurrentDirectory: function () { return host.getCurrentDirectory(); },
77608             getNewLine: function () { return host.getNewLine(); },
77609             getSourceFile: ts.returnUndefined,
77610             getSourceFileByPath: ts.returnUndefined,
77611             getSourceFiles: function () { return sourceFilesForJsEmit; },
77612             getLibFileFromReference: ts.notImplemented,
77613             isSourceFileFromExternalLibrary: ts.returnFalse,
77614             getResolvedProjectReferenceToRedirect: ts.returnUndefined,
77615             getProjectReferenceRedirect: ts.returnUndefined,
77616             isSourceOfProjectReferenceRedirect: ts.returnFalse,
77617             writeFile: function (name, text, writeByteOrderMark) {
77618                 switch (name) {
77619                     case jsFilePath:
77620                         if (jsFileText === text)
77621                             return;
77622                         break;
77623                     case sourceMapFilePath:
77624                         if (sourceMapText === text)
77625                             return;
77626                         break;
77627                     case buildInfoPath:
77628                         var newBuildInfo = getBuildInfo(text);
77629                         newBuildInfo.program = buildInfo.program;
77630                         var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
77631                         newBuildInfo.bundle.js.sources = js.sources;
77632                         if (dts) {
77633                             newBuildInfo.bundle.dts.sources = dts.sources;
77634                         }
77635                         newBuildInfo.bundle.sourceFiles = sourceFiles;
77636                         outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark });
77637                         return;
77638                     case declarationFilePath:
77639                         if (declarationText === text)
77640                             return;
77641                         break;
77642                     case declarationMapPath:
77643                         if (declarationMapText === text)
77644                             return;
77645                         break;
77646                     default:
77647                         ts.Debug.fail("Unexpected path: " + name);
77648                 }
77649                 outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark });
77650             },
77651             isEmitBlocked: ts.returnFalse,
77652             readFile: function (f) { return host.readFile(f); },
77653             fileExists: function (f) { return host.fileExists(f); },
77654             useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
77655             getProgramBuildInfo: ts.returnUndefined,
77656             getSourceFileFromReference: ts.returnUndefined,
77657             redirectTargetsMap: ts.createMultiMap()
77658         };
77659         emitFiles(ts.notImplementedResolver, emitHost, undefined, ts.getTransformers(config.options, customTransformers));
77660         return outputFiles;
77661     }
77662     ts.emitUsingBuildInfo = emitUsingBuildInfo;
77663     function createPrinter(printerOptions, handlers) {
77664         if (printerOptions === void 0) { printerOptions = {}; }
77665         if (handlers === void 0) { handlers = {}; }
77666         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;
77667         var extendedDiagnostics = !!printerOptions.extendedDiagnostics;
77668         var newLine = ts.getNewLineCharacter(printerOptions);
77669         var moduleKind = ts.getEmitModuleKind(printerOptions);
77670         var bundledHelpers = ts.createMap();
77671         var currentSourceFile;
77672         var nodeIdToGeneratedName;
77673         var autoGeneratedIdToGeneratedName;
77674         var generatedNames;
77675         var tempFlagsStack;
77676         var tempFlags;
77677         var reservedNamesStack;
77678         var reservedNames;
77679         var preserveSourceNewlines = printerOptions.preserveSourceNewlines;
77680         var writer;
77681         var ownWriter;
77682         var write = writeBase;
77683         var isOwnFileEmit;
77684         var bundleFileInfo = printerOptions.writeBundleFileInfo ? { sections: [] } : undefined;
77685         var relativeToBuildInfo = bundleFileInfo ? ts.Debug.checkDefined(printerOptions.relativeToBuildInfo) : undefined;
77686         var recordInternalSection = printerOptions.recordInternalSection;
77687         var sourceFileTextPos = 0;
77688         var sourceFileTextKind = "text";
77689         var sourceMapsDisabled = true;
77690         var sourceMapGenerator;
77691         var sourceMapSource;
77692         var sourceMapSourceIndex = -1;
77693         var containerPos = -1;
77694         var containerEnd = -1;
77695         var declarationListContainerEnd = -1;
77696         var currentLineMap;
77697         var detachedCommentsInfo;
77698         var hasWrittenComment = false;
77699         var commentsDisabled = !!printerOptions.removeComments;
77700         var lastNode;
77701         var lastSubstitution;
77702         var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit;
77703         reset();
77704         return {
77705             printNode: printNode,
77706             printList: printList,
77707             printFile: printFile,
77708             printBundle: printBundle,
77709             writeNode: writeNode,
77710             writeList: writeList,
77711             writeFile: writeFile,
77712             writeBundle: writeBundle,
77713             bundleFileInfo: bundleFileInfo
77714         };
77715         function printNode(hint, node, sourceFile) {
77716             switch (hint) {
77717                 case 0:
77718                     ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node.");
77719                     break;
77720                 case 2:
77721                     ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node.");
77722                     break;
77723                 case 1:
77724                     ts.Debug.assert(ts.isExpression(node), "Expected an Expression node.");
77725                     break;
77726             }
77727             switch (node.kind) {
77728                 case 290: return printFile(node);
77729                 case 291: return printBundle(node);
77730                 case 292: return printUnparsedSource(node);
77731             }
77732             writeNode(hint, node, sourceFile, beginPrint());
77733             return endPrint();
77734         }
77735         function printList(format, nodes, sourceFile) {
77736             writeList(format, nodes, sourceFile, beginPrint());
77737             return endPrint();
77738         }
77739         function printBundle(bundle) {
77740             writeBundle(bundle, beginPrint(), undefined);
77741             return endPrint();
77742         }
77743         function printFile(sourceFile) {
77744             writeFile(sourceFile, beginPrint(), undefined);
77745             return endPrint();
77746         }
77747         function printUnparsedSource(unparsed) {
77748             writeUnparsedSource(unparsed, beginPrint());
77749             return endPrint();
77750         }
77751         function writeNode(hint, node, sourceFile, output) {
77752             var previousWriter = writer;
77753             setWriter(output, undefined);
77754             print(hint, node, sourceFile);
77755             reset();
77756             writer = previousWriter;
77757         }
77758         function writeList(format, nodes, sourceFile, output) {
77759             var previousWriter = writer;
77760             setWriter(output, undefined);
77761             if (sourceFile) {
77762                 setSourceFile(sourceFile);
77763             }
77764             emitList(syntheticParent, nodes, format);
77765             reset();
77766             writer = previousWriter;
77767         }
77768         function getTextPosWithWriteLine() {
77769             return writer.getTextPosWithWriteLine ? writer.getTextPosWithWriteLine() : writer.getTextPos();
77770         }
77771         function updateOrPushBundleFileTextLike(pos, end, kind) {
77772             var last = ts.lastOrUndefined(bundleFileInfo.sections);
77773             if (last && last.kind === kind) {
77774                 last.end = end;
77775             }
77776             else {
77777                 bundleFileInfo.sections.push({ pos: pos, end: end, kind: kind });
77778             }
77779         }
77780         function recordBundleFileInternalSectionStart(node) {
77781             if (recordInternalSection &&
77782                 bundleFileInfo &&
77783                 currentSourceFile &&
77784                 (ts.isDeclaration(node) || ts.isVariableStatement(node)) &&
77785                 ts.isInternalDeclaration(node, currentSourceFile) &&
77786                 sourceFileTextKind !== "internal") {
77787                 var prevSourceFileTextKind = sourceFileTextKind;
77788                 recordBundleFileTextLikeSection(writer.getTextPos());
77789                 sourceFileTextPos = getTextPosWithWriteLine();
77790                 sourceFileTextKind = "internal";
77791                 return prevSourceFileTextKind;
77792             }
77793             return undefined;
77794         }
77795         function recordBundleFileInternalSectionEnd(prevSourceFileTextKind) {
77796             if (prevSourceFileTextKind) {
77797                 recordBundleFileTextLikeSection(writer.getTextPos());
77798                 sourceFileTextPos = getTextPosWithWriteLine();
77799                 sourceFileTextKind = prevSourceFileTextKind;
77800             }
77801         }
77802         function recordBundleFileTextLikeSection(end) {
77803             if (sourceFileTextPos < end) {
77804                 updateOrPushBundleFileTextLike(sourceFileTextPos, end, sourceFileTextKind);
77805                 return true;
77806             }
77807             return false;
77808         }
77809         function writeBundle(bundle, output, sourceMapGenerator) {
77810             var _a;
77811             isOwnFileEmit = false;
77812             var previousWriter = writer;
77813             setWriter(output, sourceMapGenerator);
77814             emitShebangIfNeeded(bundle);
77815             emitPrologueDirectivesIfNeeded(bundle);
77816             emitHelpers(bundle);
77817             emitSyntheticTripleSlashReferencesIfNeeded(bundle);
77818             for (var _b = 0, _c = bundle.prepends; _b < _c.length; _b++) {
77819                 var prepend = _c[_b];
77820                 writeLine();
77821                 var pos = writer.getTextPos();
77822                 var savedSections = bundleFileInfo && bundleFileInfo.sections;
77823                 if (savedSections)
77824                     bundleFileInfo.sections = [];
77825                 print(4, prepend, undefined);
77826                 if (bundleFileInfo) {
77827                     var newSections = bundleFileInfo.sections;
77828                     bundleFileInfo.sections = savedSections;
77829                     if (prepend.oldFileOfCurrentEmit)
77830                         (_a = bundleFileInfo.sections).push.apply(_a, newSections);
77831                     else {
77832                         newSections.forEach(function (section) { return ts.Debug.assert(ts.isBundleFileTextLike(section)); });
77833                         bundleFileInfo.sections.push({
77834                             pos: pos,
77835                             end: writer.getTextPos(),
77836                             kind: "prepend",
77837                             data: relativeToBuildInfo(prepend.fileName),
77838                             texts: newSections
77839                         });
77840                     }
77841                 }
77842             }
77843             sourceFileTextPos = getTextPosWithWriteLine();
77844             for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) {
77845                 var sourceFile = _e[_d];
77846                 print(0, sourceFile, sourceFile);
77847             }
77848             if (bundleFileInfo && bundle.sourceFiles.length) {
77849                 var end = writer.getTextPos();
77850                 if (recordBundleFileTextLikeSection(end)) {
77851                     var prologues = getPrologueDirectivesFromBundledSourceFiles(bundle);
77852                     if (prologues) {
77853                         if (!bundleFileInfo.sources)
77854                             bundleFileInfo.sources = {};
77855                         bundleFileInfo.sources.prologues = prologues;
77856                     }
77857                     var helpers = getHelpersFromBundledSourceFiles(bundle);
77858                     if (helpers) {
77859                         if (!bundleFileInfo.sources)
77860                             bundleFileInfo.sources = {};
77861                         bundleFileInfo.sources.helpers = helpers;
77862                     }
77863                 }
77864             }
77865             reset();
77866             writer = previousWriter;
77867         }
77868         function writeUnparsedSource(unparsed, output) {
77869             var previousWriter = writer;
77870             setWriter(output, undefined);
77871             print(4, unparsed, undefined);
77872             reset();
77873             writer = previousWriter;
77874         }
77875         function writeFile(sourceFile, output, sourceMapGenerator) {
77876             isOwnFileEmit = true;
77877             var previousWriter = writer;
77878             setWriter(output, sourceMapGenerator);
77879             emitShebangIfNeeded(sourceFile);
77880             emitPrologueDirectivesIfNeeded(sourceFile);
77881             print(0, sourceFile, sourceFile);
77882             reset();
77883             writer = previousWriter;
77884         }
77885         function beginPrint() {
77886             return ownWriter || (ownWriter = ts.createTextWriter(newLine));
77887         }
77888         function endPrint() {
77889             var text = ownWriter.getText();
77890             ownWriter.clear();
77891             return text;
77892         }
77893         function print(hint, node, sourceFile) {
77894             if (sourceFile) {
77895                 setSourceFile(sourceFile);
77896             }
77897             pipelineEmit(hint, node);
77898         }
77899         function setSourceFile(sourceFile) {
77900             currentSourceFile = sourceFile;
77901             currentLineMap = undefined;
77902             detachedCommentsInfo = undefined;
77903             if (sourceFile) {
77904                 setSourceMapSource(sourceFile);
77905             }
77906         }
77907         function setWriter(_writer, _sourceMapGenerator) {
77908             if (_writer && printerOptions.omitTrailingSemicolon) {
77909                 _writer = ts.getTrailingSemicolonDeferringWriter(_writer);
77910             }
77911             writer = _writer;
77912             sourceMapGenerator = _sourceMapGenerator;
77913             sourceMapsDisabled = !writer || !sourceMapGenerator;
77914         }
77915         function reset() {
77916             nodeIdToGeneratedName = [];
77917             autoGeneratedIdToGeneratedName = [];
77918             generatedNames = ts.createMap();
77919             tempFlagsStack = [];
77920             tempFlags = 0;
77921             reservedNamesStack = [];
77922             currentSourceFile = undefined;
77923             currentLineMap = undefined;
77924             detachedCommentsInfo = undefined;
77925             lastNode = undefined;
77926             lastSubstitution = undefined;
77927             setWriter(undefined, undefined);
77928         }
77929         function getCurrentLineMap() {
77930             return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile));
77931         }
77932         function emit(node) {
77933             if (node === undefined)
77934                 return;
77935             var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node);
77936             var substitute = pipelineEmit(4, node);
77937             recordBundleFileInternalSectionEnd(prevSourceFileTextKind);
77938             return substitute;
77939         }
77940         function emitIdentifierName(node) {
77941             if (node === undefined)
77942                 return;
77943             return pipelineEmit(2, node);
77944         }
77945         function emitExpression(node) {
77946             if (node === undefined)
77947                 return;
77948             return pipelineEmit(1, node);
77949         }
77950         function emitJsxAttributeValue(node) {
77951             return pipelineEmit(ts.isStringLiteral(node) ? 6 : 4, node);
77952         }
77953         function pipelineEmit(emitHint, node) {
77954             var savedLastNode = lastNode;
77955             var savedLastSubstitution = lastSubstitution;
77956             var savedPreserveSourceNewlines = preserveSourceNewlines;
77957             lastNode = node;
77958             lastSubstitution = undefined;
77959             if (preserveSourceNewlines && !!(ts.getEmitFlags(node) & 134217728)) {
77960                 preserveSourceNewlines = false;
77961             }
77962             var pipelinePhase = getPipelinePhase(0, emitHint, node);
77963             pipelinePhase(emitHint, node);
77964             ts.Debug.assert(lastNode === node);
77965             var substitute = lastSubstitution;
77966             lastNode = savedLastNode;
77967             lastSubstitution = savedLastSubstitution;
77968             preserveSourceNewlines = savedPreserveSourceNewlines;
77969             return substitute || node;
77970         }
77971         function getPipelinePhase(phase, emitHint, node) {
77972             switch (phase) {
77973                 case 0:
77974                     if (onEmitNode !== ts.noEmitNotification && (!isEmitNotificationEnabled || isEmitNotificationEnabled(node))) {
77975                         return pipelineEmitWithNotification;
77976                     }
77977                 case 1:
77978                     if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node)) !== node) {
77979                         return pipelineEmitWithSubstitution;
77980                     }
77981                 case 2:
77982                     if (!commentsDisabled && node.kind !== 290) {
77983                         return pipelineEmitWithComments;
77984                     }
77985                 case 3:
77986                     if (!sourceMapsDisabled && node.kind !== 290 && !ts.isInJsonFile(node)) {
77987                         return pipelineEmitWithSourceMap;
77988                     }
77989                 case 4:
77990                     return pipelineEmitWithHint;
77991                 default:
77992                     return ts.Debug.assertNever(phase);
77993             }
77994         }
77995         function getNextPipelinePhase(currentPhase, emitHint, node) {
77996             return getPipelinePhase(currentPhase + 1, emitHint, node);
77997         }
77998         function pipelineEmitWithNotification(hint, node) {
77999             ts.Debug.assert(lastNode === node);
78000             var pipelinePhase = getNextPipelinePhase(0, hint, node);
78001             onEmitNode(hint, node, pipelinePhase);
78002             ts.Debug.assert(lastNode === node);
78003         }
78004         function pipelineEmitWithHint(hint, node) {
78005             ts.Debug.assert(lastNode === node || lastSubstitution === node);
78006             if (hint === 0)
78007                 return emitSourceFile(ts.cast(node, ts.isSourceFile));
78008             if (hint === 2)
78009                 return emitIdentifier(ts.cast(node, ts.isIdentifier));
78010             if (hint === 6)
78011                 return emitLiteral(ts.cast(node, ts.isStringLiteral), true);
78012             if (hint === 3)
78013                 return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration));
78014             if (hint === 5) {
78015                 ts.Debug.assertNode(node, ts.isEmptyStatement);
78016                 return emitEmptyStatement(true);
78017             }
78018             if (hint === 4) {
78019                 if (ts.isKeyword(node.kind))
78020                     return writeTokenNode(node, writeKeyword);
78021                 switch (node.kind) {
78022                     case 15:
78023                     case 16:
78024                     case 17:
78025                         return emitLiteral(node, false);
78026                     case 292:
78027                     case 286:
78028                         return emitUnparsedSourceOrPrepend(node);
78029                     case 285:
78030                         return writeUnparsedNode(node);
78031                     case 287:
78032                     case 288:
78033                         return emitUnparsedTextLike(node);
78034                     case 289:
78035                         return emitUnparsedSyntheticReference(node);
78036                     case 75:
78037                         return emitIdentifier(node);
78038                     case 76:
78039                         return emitPrivateIdentifier(node);
78040                     case 153:
78041                         return emitQualifiedName(node);
78042                     case 154:
78043                         return emitComputedPropertyName(node);
78044                     case 155:
78045                         return emitTypeParameter(node);
78046                     case 156:
78047                         return emitParameter(node);
78048                     case 157:
78049                         return emitDecorator(node);
78050                     case 158:
78051                         return emitPropertySignature(node);
78052                     case 159:
78053                         return emitPropertyDeclaration(node);
78054                     case 160:
78055                         return emitMethodSignature(node);
78056                     case 161:
78057                         return emitMethodDeclaration(node);
78058                     case 162:
78059                         return emitConstructor(node);
78060                     case 163:
78061                     case 164:
78062                         return emitAccessorDeclaration(node);
78063                     case 165:
78064                         return emitCallSignature(node);
78065                     case 166:
78066                         return emitConstructSignature(node);
78067                     case 167:
78068                         return emitIndexSignature(node);
78069                     case 168:
78070                         return emitTypePredicate(node);
78071                     case 169:
78072                         return emitTypeReference(node);
78073                     case 170:
78074                         return emitFunctionType(node);
78075                     case 300:
78076                         return emitJSDocFunctionType(node);
78077                     case 171:
78078                         return emitConstructorType(node);
78079                     case 172:
78080                         return emitTypeQuery(node);
78081                     case 173:
78082                         return emitTypeLiteral(node);
78083                     case 174:
78084                         return emitArrayType(node);
78085                     case 175:
78086                         return emitTupleType(node);
78087                     case 176:
78088                         return emitOptionalType(node);
78089                     case 178:
78090                         return emitUnionType(node);
78091                     case 179:
78092                         return emitIntersectionType(node);
78093                     case 180:
78094                         return emitConditionalType(node);
78095                     case 181:
78096                         return emitInferType(node);
78097                     case 182:
78098                         return emitParenthesizedType(node);
78099                     case 216:
78100                         return emitExpressionWithTypeArguments(node);
78101                     case 183:
78102                         return emitThisType();
78103                     case 184:
78104                         return emitTypeOperator(node);
78105                     case 185:
78106                         return emitIndexedAccessType(node);
78107                     case 186:
78108                         return emitMappedType(node);
78109                     case 187:
78110                         return emitLiteralType(node);
78111                     case 188:
78112                         return emitImportTypeNode(node);
78113                     case 295:
78114                         writePunctuation("*");
78115                         return;
78116                     case 296:
78117                         writePunctuation("?");
78118                         return;
78119                     case 297:
78120                         return emitJSDocNullableType(node);
78121                     case 298:
78122                         return emitJSDocNonNullableType(node);
78123                     case 299:
78124                         return emitJSDocOptionalType(node);
78125                     case 177:
78126                     case 301:
78127                         return emitRestOrJSDocVariadicType(node);
78128                     case 189:
78129                         return emitObjectBindingPattern(node);
78130                     case 190:
78131                         return emitArrayBindingPattern(node);
78132                     case 191:
78133                         return emitBindingElement(node);
78134                     case 221:
78135                         return emitTemplateSpan(node);
78136                     case 222:
78137                         return emitSemicolonClassElement();
78138                     case 223:
78139                         return emitBlock(node);
78140                     case 225:
78141                         return emitVariableStatement(node);
78142                     case 224:
78143                         return emitEmptyStatement(false);
78144                     case 226:
78145                         return emitExpressionStatement(node);
78146                     case 227:
78147                         return emitIfStatement(node);
78148                     case 228:
78149                         return emitDoStatement(node);
78150                     case 229:
78151                         return emitWhileStatement(node);
78152                     case 230:
78153                         return emitForStatement(node);
78154                     case 231:
78155                         return emitForInStatement(node);
78156                     case 232:
78157                         return emitForOfStatement(node);
78158                     case 233:
78159                         return emitContinueStatement(node);
78160                     case 234:
78161                         return emitBreakStatement(node);
78162                     case 235:
78163                         return emitReturnStatement(node);
78164                     case 236:
78165                         return emitWithStatement(node);
78166                     case 237:
78167                         return emitSwitchStatement(node);
78168                     case 238:
78169                         return emitLabeledStatement(node);
78170                     case 239:
78171                         return emitThrowStatement(node);
78172                     case 240:
78173                         return emitTryStatement(node);
78174                     case 241:
78175                         return emitDebuggerStatement(node);
78176                     case 242:
78177                         return emitVariableDeclaration(node);
78178                     case 243:
78179                         return emitVariableDeclarationList(node);
78180                     case 244:
78181                         return emitFunctionDeclaration(node);
78182                     case 245:
78183                         return emitClassDeclaration(node);
78184                     case 246:
78185                         return emitInterfaceDeclaration(node);
78186                     case 247:
78187                         return emitTypeAliasDeclaration(node);
78188                     case 248:
78189                         return emitEnumDeclaration(node);
78190                     case 249:
78191                         return emitModuleDeclaration(node);
78192                     case 250:
78193                         return emitModuleBlock(node);
78194                     case 251:
78195                         return emitCaseBlock(node);
78196                     case 252:
78197                         return emitNamespaceExportDeclaration(node);
78198                     case 253:
78199                         return emitImportEqualsDeclaration(node);
78200                     case 254:
78201                         return emitImportDeclaration(node);
78202                     case 255:
78203                         return emitImportClause(node);
78204                     case 256:
78205                         return emitNamespaceImport(node);
78206                     case 262:
78207                         return emitNamespaceExport(node);
78208                     case 257:
78209                         return emitNamedImports(node);
78210                     case 258:
78211                         return emitImportSpecifier(node);
78212                     case 259:
78213                         return emitExportAssignment(node);
78214                     case 260:
78215                         return emitExportDeclaration(node);
78216                     case 261:
78217                         return emitNamedExports(node);
78218                     case 263:
78219                         return emitExportSpecifier(node);
78220                     case 264:
78221                         return;
78222                     case 265:
78223                         return emitExternalModuleReference(node);
78224                     case 11:
78225                         return emitJsxText(node);
78226                     case 268:
78227                     case 271:
78228                         return emitJsxOpeningElementOrFragment(node);
78229                     case 269:
78230                     case 272:
78231                         return emitJsxClosingElementOrFragment(node);
78232                     case 273:
78233                         return emitJsxAttribute(node);
78234                     case 274:
78235                         return emitJsxAttributes(node);
78236                     case 275:
78237                         return emitJsxSpreadAttribute(node);
78238                     case 276:
78239                         return emitJsxExpression(node);
78240                     case 277:
78241                         return emitCaseClause(node);
78242                     case 278:
78243                         return emitDefaultClause(node);
78244                     case 279:
78245                         return emitHeritageClause(node);
78246                     case 280:
78247                         return emitCatchClause(node);
78248                     case 281:
78249                         return emitPropertyAssignment(node);
78250                     case 282:
78251                         return emitShorthandPropertyAssignment(node);
78252                     case 283:
78253                         return emitSpreadAssignment(node);
78254                     case 284:
78255                         return emitEnumMember(node);
78256                     case 317:
78257                     case 323:
78258                         return emitJSDocPropertyLikeTag(node);
78259                     case 318:
78260                     case 320:
78261                     case 319:
78262                     case 316:
78263                         return emitJSDocSimpleTypedTag(node);
78264                     case 308:
78265                     case 307:
78266                         return emitJSDocHeritageTag(node);
78267                     case 321:
78268                         return emitJSDocTemplateTag(node);
78269                     case 322:
78270                         return emitJSDocTypedefTag(node);
78271                     case 315:
78272                         return emitJSDocCallbackTag(node);
78273                     case 305:
78274                         return emitJSDocSignature(node);
78275                     case 304:
78276                         return emitJSDocTypeLiteral(node);
78277                     case 310:
78278                     case 306:
78279                         return emitJSDocSimpleTag(node);
78280                     case 303:
78281                         return emitJSDoc(node);
78282                 }
78283                 if (ts.isExpression(node)) {
78284                     hint = 1;
78285                     if (substituteNode !== ts.noEmitSubstitution) {
78286                         lastSubstitution = node = substituteNode(hint, node);
78287                     }
78288                 }
78289                 else if (ts.isToken(node)) {
78290                     return writeTokenNode(node, writePunctuation);
78291                 }
78292             }
78293             if (hint === 1) {
78294                 switch (node.kind) {
78295                     case 8:
78296                     case 9:
78297                         return emitNumericOrBigIntLiteral(node);
78298                     case 10:
78299                     case 13:
78300                     case 14:
78301                         return emitLiteral(node, false);
78302                     case 75:
78303                         return emitIdentifier(node);
78304                     case 91:
78305                     case 100:
78306                     case 102:
78307                     case 106:
78308                     case 104:
78309                     case 96:
78310                         writeTokenNode(node, writeKeyword);
78311                         return;
78312                     case 192:
78313                         return emitArrayLiteralExpression(node);
78314                     case 193:
78315                         return emitObjectLiteralExpression(node);
78316                     case 194:
78317                         return emitPropertyAccessExpression(node);
78318                     case 195:
78319                         return emitElementAccessExpression(node);
78320                     case 196:
78321                         return emitCallExpression(node);
78322                     case 197:
78323                         return emitNewExpression(node);
78324                     case 198:
78325                         return emitTaggedTemplateExpression(node);
78326                     case 199:
78327                         return emitTypeAssertionExpression(node);
78328                     case 200:
78329                         return emitParenthesizedExpression(node);
78330                     case 201:
78331                         return emitFunctionExpression(node);
78332                     case 202:
78333                         return emitArrowFunction(node);
78334                     case 203:
78335                         return emitDeleteExpression(node);
78336                     case 204:
78337                         return emitTypeOfExpression(node);
78338                     case 205:
78339                         return emitVoidExpression(node);
78340                     case 206:
78341                         return emitAwaitExpression(node);
78342                     case 207:
78343                         return emitPrefixUnaryExpression(node);
78344                     case 208:
78345                         return emitPostfixUnaryExpression(node);
78346                     case 209:
78347                         return emitBinaryExpression(node);
78348                     case 210:
78349                         return emitConditionalExpression(node);
78350                     case 211:
78351                         return emitTemplateExpression(node);
78352                     case 212:
78353                         return emitYieldExpression(node);
78354                     case 213:
78355                         return emitSpreadExpression(node);
78356                     case 214:
78357                         return emitClassExpression(node);
78358                     case 215:
78359                         return;
78360                     case 217:
78361                         return emitAsExpression(node);
78362                     case 218:
78363                         return emitNonNullExpression(node);
78364                     case 219:
78365                         return emitMetaProperty(node);
78366                     case 266:
78367                         return emitJsxElement(node);
78368                     case 267:
78369                         return emitJsxSelfClosingElement(node);
78370                     case 270:
78371                         return emitJsxFragment(node);
78372                     case 326:
78373                         return emitPartiallyEmittedExpression(node);
78374                     case 327:
78375                         return emitCommaList(node);
78376                 }
78377             }
78378         }
78379         function emitMappedTypeParameter(node) {
78380             emit(node.name);
78381             writeSpace();
78382             writeKeyword("in");
78383             writeSpace();
78384             emit(node.constraint);
78385         }
78386         function pipelineEmitWithSubstitution(hint, node) {
78387             ts.Debug.assert(lastNode === node || lastSubstitution === node);
78388             var pipelinePhase = getNextPipelinePhase(1, hint, node);
78389             pipelinePhase(hint, lastSubstitution);
78390             ts.Debug.assert(lastNode === node || lastSubstitution === node);
78391         }
78392         function getHelpersFromBundledSourceFiles(bundle) {
78393             var result;
78394             if (moduleKind === ts.ModuleKind.None || printerOptions.noEmitHelpers) {
78395                 return undefined;
78396             }
78397             var bundledHelpers = ts.createMap();
78398             for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) {
78399                 var sourceFile = _b[_a];
78400                 var shouldSkip = ts.getExternalHelpersModuleName(sourceFile) !== undefined;
78401                 var helpers = getSortedEmitHelpers(sourceFile);
78402                 if (!helpers)
78403                     continue;
78404                 for (var _c = 0, helpers_4 = helpers; _c < helpers_4.length; _c++) {
78405                     var helper = helpers_4[_c];
78406                     if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) {
78407                         bundledHelpers.set(helper.name, true);
78408                         (result || (result = [])).push(helper.name);
78409                     }
78410                 }
78411             }
78412             return result;
78413         }
78414         function emitHelpers(node) {
78415             var helpersEmitted = false;
78416             var bundle = node.kind === 291 ? node : undefined;
78417             if (bundle && moduleKind === ts.ModuleKind.None) {
78418                 return;
78419             }
78420             var numPrepends = bundle ? bundle.prepends.length : 0;
78421             var numNodes = bundle ? bundle.sourceFiles.length + numPrepends : 1;
78422             for (var i = 0; i < numNodes; i++) {
78423                 var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node;
78424                 var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile;
78425                 var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.hasRecordedExternalHelpers(sourceFile));
78426                 var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit;
78427                 var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode);
78428                 if (helpers) {
78429                     for (var _a = 0, helpers_5 = helpers; _a < helpers_5.length; _a++) {
78430                         var helper = helpers_5[_a];
78431                         if (!helper.scoped) {
78432                             if (shouldSkip)
78433                                 continue;
78434                             if (shouldBundle) {
78435                                 if (bundledHelpers.get(helper.name)) {
78436                                     continue;
78437                                 }
78438                                 bundledHelpers.set(helper.name, true);
78439                             }
78440                         }
78441                         else if (bundle) {
78442                             continue;
78443                         }
78444                         var pos = getTextPosWithWriteLine();
78445                         if (typeof helper.text === "string") {
78446                             writeLines(helper.text);
78447                         }
78448                         else {
78449                             writeLines(helper.text(makeFileLevelOptimisticUniqueName));
78450                         }
78451                         if (bundleFileInfo)
78452                             bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers", data: helper.name });
78453                         helpersEmitted = true;
78454                     }
78455                 }
78456             }
78457             return helpersEmitted;
78458         }
78459         function getSortedEmitHelpers(node) {
78460             var helpers = ts.getEmitHelpers(node);
78461             return helpers && ts.stableSort(helpers, ts.compareEmitHelpers);
78462         }
78463         function emitNumericOrBigIntLiteral(node) {
78464             emitLiteral(node, false);
78465         }
78466         function emitLiteral(node, jsxAttributeEscape) {
78467             var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape, jsxAttributeEscape);
78468             if ((printerOptions.sourceMap || printerOptions.inlineSourceMap)
78469                 && (node.kind === 10 || ts.isTemplateLiteralKind(node.kind))) {
78470                 writeLiteral(text);
78471             }
78472             else {
78473                 writeStringLiteral(text);
78474             }
78475         }
78476         function emitUnparsedSourceOrPrepend(unparsed) {
78477             for (var _a = 0, _b = unparsed.texts; _a < _b.length; _a++) {
78478                 var text = _b[_a];
78479                 writeLine();
78480                 emit(text);
78481             }
78482         }
78483         function writeUnparsedNode(unparsed) {
78484             writer.rawWrite(unparsed.parent.text.substring(unparsed.pos, unparsed.end));
78485         }
78486         function emitUnparsedTextLike(unparsed) {
78487             var pos = getTextPosWithWriteLine();
78488             writeUnparsedNode(unparsed);
78489             if (bundleFileInfo) {
78490                 updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 287 ?
78491                     "text" :
78492                     "internal");
78493             }
78494         }
78495         function emitUnparsedSyntheticReference(unparsed) {
78496             var pos = getTextPosWithWriteLine();
78497             writeUnparsedNode(unparsed);
78498             if (bundleFileInfo) {
78499                 var section = ts.clone(unparsed.section);
78500                 section.pos = pos;
78501                 section.end = writer.getTextPos();
78502                 bundleFileInfo.sections.push(section);
78503             }
78504         }
78505         function emitIdentifier(node) {
78506             var writeText = node.symbol ? writeSymbol : write;
78507             writeText(getTextOfNode(node, false), node.symbol);
78508             emitList(node, node.typeArguments, 53776);
78509         }
78510         function emitPrivateIdentifier(node) {
78511             var writeText = node.symbol ? writeSymbol : write;
78512             writeText(getTextOfNode(node, false), node.symbol);
78513         }
78514         function emitQualifiedName(node) {
78515             emitEntityName(node.left);
78516             writePunctuation(".");
78517             emit(node.right);
78518         }
78519         function emitEntityName(node) {
78520             if (node.kind === 75) {
78521                 emitExpression(node);
78522             }
78523             else {
78524                 emit(node);
78525             }
78526         }
78527         function emitComputedPropertyName(node) {
78528             writePunctuation("[");
78529             emitExpression(node.expression);
78530             writePunctuation("]");
78531         }
78532         function emitTypeParameter(node) {
78533             emit(node.name);
78534             if (node.constraint) {
78535                 writeSpace();
78536                 writeKeyword("extends");
78537                 writeSpace();
78538                 emit(node.constraint);
78539             }
78540             if (node.default) {
78541                 writeSpace();
78542                 writeOperator("=");
78543                 writeSpace();
78544                 emit(node.default);
78545             }
78546         }
78547         function emitParameter(node) {
78548             emitDecorators(node, node.decorators);
78549             emitModifiers(node, node.modifiers);
78550             emit(node.dotDotDotToken);
78551             emitNodeWithWriter(node.name, writeParameter);
78552             emit(node.questionToken);
78553             if (node.parent && node.parent.kind === 300 && !node.name) {
78554                 emit(node.type);
78555             }
78556             else {
78557                 emitTypeAnnotation(node.type);
78558             }
78559             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);
78560         }
78561         function emitDecorator(decorator) {
78562             writePunctuation("@");
78563             emitExpression(decorator.expression);
78564         }
78565         function emitPropertySignature(node) {
78566             emitDecorators(node, node.decorators);
78567             emitModifiers(node, node.modifiers);
78568             emitNodeWithWriter(node.name, writeProperty);
78569             emit(node.questionToken);
78570             emitTypeAnnotation(node.type);
78571             writeTrailingSemicolon();
78572         }
78573         function emitPropertyDeclaration(node) {
78574             emitDecorators(node, node.decorators);
78575             emitModifiers(node, node.modifiers);
78576             emit(node.name);
78577             emit(node.questionToken);
78578             emit(node.exclamationToken);
78579             emitTypeAnnotation(node.type);
78580             emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name.end, node);
78581             writeTrailingSemicolon();
78582         }
78583         function emitMethodSignature(node) {
78584             pushNameGenerationScope(node);
78585             emitDecorators(node, node.decorators);
78586             emitModifiers(node, node.modifiers);
78587             emit(node.name);
78588             emit(node.questionToken);
78589             emitTypeParameters(node, node.typeParameters);
78590             emitParameters(node, node.parameters);
78591             emitTypeAnnotation(node.type);
78592             writeTrailingSemicolon();
78593             popNameGenerationScope(node);
78594         }
78595         function emitMethodDeclaration(node) {
78596             emitDecorators(node, node.decorators);
78597             emitModifiers(node, node.modifiers);
78598             emit(node.asteriskToken);
78599             emit(node.name);
78600             emit(node.questionToken);
78601             emitSignatureAndBody(node, emitSignatureHead);
78602         }
78603         function emitConstructor(node) {
78604             emitModifiers(node, node.modifiers);
78605             writeKeyword("constructor");
78606             emitSignatureAndBody(node, emitSignatureHead);
78607         }
78608         function emitAccessorDeclaration(node) {
78609             emitDecorators(node, node.decorators);
78610             emitModifiers(node, node.modifiers);
78611             writeKeyword(node.kind === 163 ? "get" : "set");
78612             writeSpace();
78613             emit(node.name);
78614             emitSignatureAndBody(node, emitSignatureHead);
78615         }
78616         function emitCallSignature(node) {
78617             pushNameGenerationScope(node);
78618             emitDecorators(node, node.decorators);
78619             emitModifiers(node, node.modifiers);
78620             emitTypeParameters(node, node.typeParameters);
78621             emitParameters(node, node.parameters);
78622             emitTypeAnnotation(node.type);
78623             writeTrailingSemicolon();
78624             popNameGenerationScope(node);
78625         }
78626         function emitConstructSignature(node) {
78627             pushNameGenerationScope(node);
78628             emitDecorators(node, node.decorators);
78629             emitModifiers(node, node.modifiers);
78630             writeKeyword("new");
78631             writeSpace();
78632             emitTypeParameters(node, node.typeParameters);
78633             emitParameters(node, node.parameters);
78634             emitTypeAnnotation(node.type);
78635             writeTrailingSemicolon();
78636             popNameGenerationScope(node);
78637         }
78638         function emitIndexSignature(node) {
78639             emitDecorators(node, node.decorators);
78640             emitModifiers(node, node.modifiers);
78641             emitParametersForIndexSignature(node, node.parameters);
78642             emitTypeAnnotation(node.type);
78643             writeTrailingSemicolon();
78644         }
78645         function emitSemicolonClassElement() {
78646             writeTrailingSemicolon();
78647         }
78648         function emitTypePredicate(node) {
78649             if (node.assertsModifier) {
78650                 emit(node.assertsModifier);
78651                 writeSpace();
78652             }
78653             emit(node.parameterName);
78654             if (node.type) {
78655                 writeSpace();
78656                 writeKeyword("is");
78657                 writeSpace();
78658                 emit(node.type);
78659             }
78660         }
78661         function emitTypeReference(node) {
78662             emit(node.typeName);
78663             emitTypeArguments(node, node.typeArguments);
78664         }
78665         function emitFunctionType(node) {
78666             pushNameGenerationScope(node);
78667             emitTypeParameters(node, node.typeParameters);
78668             emitParametersForArrow(node, node.parameters);
78669             writeSpace();
78670             writePunctuation("=>");
78671             writeSpace();
78672             emit(node.type);
78673             popNameGenerationScope(node);
78674         }
78675         function emitJSDocFunctionType(node) {
78676             writeKeyword("function");
78677             emitParameters(node, node.parameters);
78678             writePunctuation(":");
78679             emit(node.type);
78680         }
78681         function emitJSDocNullableType(node) {
78682             writePunctuation("?");
78683             emit(node.type);
78684         }
78685         function emitJSDocNonNullableType(node) {
78686             writePunctuation("!");
78687             emit(node.type);
78688         }
78689         function emitJSDocOptionalType(node) {
78690             emit(node.type);
78691             writePunctuation("=");
78692         }
78693         function emitConstructorType(node) {
78694             pushNameGenerationScope(node);
78695             writeKeyword("new");
78696             writeSpace();
78697             emitTypeParameters(node, node.typeParameters);
78698             emitParameters(node, node.parameters);
78699             writeSpace();
78700             writePunctuation("=>");
78701             writeSpace();
78702             emit(node.type);
78703             popNameGenerationScope(node);
78704         }
78705         function emitTypeQuery(node) {
78706             writeKeyword("typeof");
78707             writeSpace();
78708             emit(node.exprName);
78709         }
78710         function emitTypeLiteral(node) {
78711             writePunctuation("{");
78712             var flags = ts.getEmitFlags(node) & 1 ? 768 : 32897;
78713             emitList(node, node.members, flags | 524288);
78714             writePunctuation("}");
78715         }
78716         function emitArrayType(node) {
78717             emit(node.elementType);
78718             writePunctuation("[");
78719             writePunctuation("]");
78720         }
78721         function emitRestOrJSDocVariadicType(node) {
78722             writePunctuation("...");
78723             emit(node.type);
78724         }
78725         function emitTupleType(node) {
78726             writePunctuation("[");
78727             emitList(node, node.elementTypes, 528);
78728             writePunctuation("]");
78729         }
78730         function emitOptionalType(node) {
78731             emit(node.type);
78732             writePunctuation("?");
78733         }
78734         function emitUnionType(node) {
78735             emitList(node, node.types, 516);
78736         }
78737         function emitIntersectionType(node) {
78738             emitList(node, node.types, 520);
78739         }
78740         function emitConditionalType(node) {
78741             emit(node.checkType);
78742             writeSpace();
78743             writeKeyword("extends");
78744             writeSpace();
78745             emit(node.extendsType);
78746             writeSpace();
78747             writePunctuation("?");
78748             writeSpace();
78749             emit(node.trueType);
78750             writeSpace();
78751             writePunctuation(":");
78752             writeSpace();
78753             emit(node.falseType);
78754         }
78755         function emitInferType(node) {
78756             writeKeyword("infer");
78757             writeSpace();
78758             emit(node.typeParameter);
78759         }
78760         function emitParenthesizedType(node) {
78761             writePunctuation("(");
78762             emit(node.type);
78763             writePunctuation(")");
78764         }
78765         function emitThisType() {
78766             writeKeyword("this");
78767         }
78768         function emitTypeOperator(node) {
78769             writeTokenText(node.operator, writeKeyword);
78770             writeSpace();
78771             emit(node.type);
78772         }
78773         function emitIndexedAccessType(node) {
78774             emit(node.objectType);
78775             writePunctuation("[");
78776             emit(node.indexType);
78777             writePunctuation("]");
78778         }
78779         function emitMappedType(node) {
78780             var emitFlags = ts.getEmitFlags(node);
78781             writePunctuation("{");
78782             if (emitFlags & 1) {
78783                 writeSpace();
78784             }
78785             else {
78786                 writeLine();
78787                 increaseIndent();
78788             }
78789             if (node.readonlyToken) {
78790                 emit(node.readonlyToken);
78791                 if (node.readonlyToken.kind !== 138) {
78792                     writeKeyword("readonly");
78793                 }
78794                 writeSpace();
78795             }
78796             writePunctuation("[");
78797             pipelineEmit(3, node.typeParameter);
78798             writePunctuation("]");
78799             if (node.questionToken) {
78800                 emit(node.questionToken);
78801                 if (node.questionToken.kind !== 57) {
78802                     writePunctuation("?");
78803                 }
78804             }
78805             writePunctuation(":");
78806             writeSpace();
78807             emit(node.type);
78808             writeTrailingSemicolon();
78809             if (emitFlags & 1) {
78810                 writeSpace();
78811             }
78812             else {
78813                 writeLine();
78814                 decreaseIndent();
78815             }
78816             writePunctuation("}");
78817         }
78818         function emitLiteralType(node) {
78819             emitExpression(node.literal);
78820         }
78821         function emitImportTypeNode(node) {
78822             if (node.isTypeOf) {
78823                 writeKeyword("typeof");
78824                 writeSpace();
78825             }
78826             writeKeyword("import");
78827             writePunctuation("(");
78828             emit(node.argument);
78829             writePunctuation(")");
78830             if (node.qualifier) {
78831                 writePunctuation(".");
78832                 emit(node.qualifier);
78833             }
78834             emitTypeArguments(node, node.typeArguments);
78835         }
78836         function emitObjectBindingPattern(node) {
78837             writePunctuation("{");
78838             emitList(node, node.elements, 525136);
78839             writePunctuation("}");
78840         }
78841         function emitArrayBindingPattern(node) {
78842             writePunctuation("[");
78843             emitList(node, node.elements, 524880);
78844             writePunctuation("]");
78845         }
78846         function emitBindingElement(node) {
78847             emit(node.dotDotDotToken);
78848             if (node.propertyName) {
78849                 emit(node.propertyName);
78850                 writePunctuation(":");
78851                 writeSpace();
78852             }
78853             emit(node.name);
78854             emitInitializer(node.initializer, node.name.end, node);
78855         }
78856         function emitArrayLiteralExpression(node) {
78857             var elements = node.elements;
78858             var preferNewLine = node.multiLine ? 65536 : 0;
78859             emitExpressionList(node, elements, 8914 | preferNewLine);
78860         }
78861         function emitObjectLiteralExpression(node) {
78862             ts.forEach(node.properties, generateMemberNames);
78863             var indentedFlag = ts.getEmitFlags(node) & 65536;
78864             if (indentedFlag) {
78865                 increaseIndent();
78866             }
78867             var preferNewLine = node.multiLine ? 65536 : 0;
78868             var allowTrailingComma = currentSourceFile.languageVersion >= 1 && !ts.isJsonSourceFile(currentSourceFile) ? 64 : 0;
78869             emitList(node, node.properties, 526226 | allowTrailingComma | preferNewLine);
78870             if (indentedFlag) {
78871                 decreaseIndent();
78872             }
78873         }
78874         function emitPropertyAccessExpression(node) {
78875             var expression = ts.cast(emitExpression(node.expression), ts.isExpression);
78876             var token = node.questionDotToken || ts.createNode(24, node.expression.end, node.name.pos);
78877             var linesBeforeDot = getLinesBetweenNodes(node, node.expression, token);
78878             var linesAfterDot = getLinesBetweenNodes(node, token, node.name);
78879             writeLinesAndIndent(linesBeforeDot, false);
78880             var shouldEmitDotDot = token.kind !== 28 &&
78881                 mayNeedDotDotForPropertyAccess(expression) &&
78882                 !writer.hasTrailingComment() &&
78883                 !writer.hasTrailingWhitespace();
78884             if (shouldEmitDotDot) {
78885                 writePunctuation(".");
78886             }
78887             if (node.questionDotToken) {
78888                 emit(token);
78889             }
78890             else {
78891                 emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node);
78892             }
78893             writeLinesAndIndent(linesAfterDot, false);
78894             emit(node.name);
78895             decreaseIndentIf(linesBeforeDot, linesAfterDot);
78896         }
78897         function mayNeedDotDotForPropertyAccess(expression) {
78898             expression = ts.skipPartiallyEmittedExpressions(expression);
78899             if (ts.isNumericLiteral(expression)) {
78900                 var text = getLiteralTextOfNode(expression, true, false);
78901                 return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24));
78902             }
78903             else if (ts.isAccessExpression(expression)) {
78904                 var constantValue = ts.getConstantValue(expression);
78905                 return typeof constantValue === "number" && isFinite(constantValue)
78906                     && Math.floor(constantValue) === constantValue;
78907             }
78908         }
78909         function emitElementAccessExpression(node) {
78910             emitExpression(node.expression);
78911             emit(node.questionDotToken);
78912             emitTokenWithComment(22, node.expression.end, writePunctuation, node);
78913             emitExpression(node.argumentExpression);
78914             emitTokenWithComment(23, node.argumentExpression.end, writePunctuation, node);
78915         }
78916         function emitCallExpression(node) {
78917             emitExpression(node.expression);
78918             emit(node.questionDotToken);
78919             emitTypeArguments(node, node.typeArguments);
78920             emitExpressionList(node, node.arguments, 2576);
78921         }
78922         function emitNewExpression(node) {
78923             emitTokenWithComment(99, node.pos, writeKeyword, node);
78924             writeSpace();
78925             emitExpression(node.expression);
78926             emitTypeArguments(node, node.typeArguments);
78927             emitExpressionList(node, node.arguments, 18960);
78928         }
78929         function emitTaggedTemplateExpression(node) {
78930             emitExpression(node.tag);
78931             emitTypeArguments(node, node.typeArguments);
78932             writeSpace();
78933             emitExpression(node.template);
78934         }
78935         function emitTypeAssertionExpression(node) {
78936             writePunctuation("<");
78937             emit(node.type);
78938             writePunctuation(">");
78939             emitExpression(node.expression);
78940         }
78941         function emitParenthesizedExpression(node) {
78942             var openParenPos = emitTokenWithComment(20, node.pos, writePunctuation, node);
78943             var indented = writeLineSeparatorsAndIndentBefore(node.expression, node);
78944             emitExpression(node.expression);
78945             writeLineSeparatorsAfter(node.expression, node);
78946             decreaseIndentIf(indented);
78947             emitTokenWithComment(21, node.expression ? node.expression.end : openParenPos, writePunctuation, node);
78948         }
78949         function emitFunctionExpression(node) {
78950             generateNameIfNeeded(node.name);
78951             emitFunctionDeclarationOrExpression(node);
78952         }
78953         function emitArrowFunction(node) {
78954             emitDecorators(node, node.decorators);
78955             emitModifiers(node, node.modifiers);
78956             emitSignatureAndBody(node, emitArrowFunctionHead);
78957         }
78958         function emitArrowFunctionHead(node) {
78959             emitTypeParameters(node, node.typeParameters);
78960             emitParametersForArrow(node, node.parameters);
78961             emitTypeAnnotation(node.type);
78962             writeSpace();
78963             emit(node.equalsGreaterThanToken);
78964         }
78965         function emitDeleteExpression(node) {
78966             emitTokenWithComment(85, node.pos, writeKeyword, node);
78967             writeSpace();
78968             emitExpression(node.expression);
78969         }
78970         function emitTypeOfExpression(node) {
78971             emitTokenWithComment(108, node.pos, writeKeyword, node);
78972             writeSpace();
78973             emitExpression(node.expression);
78974         }
78975         function emitVoidExpression(node) {
78976             emitTokenWithComment(110, node.pos, writeKeyword, node);
78977             writeSpace();
78978             emitExpression(node.expression);
78979         }
78980         function emitAwaitExpression(node) {
78981             emitTokenWithComment(127, node.pos, writeKeyword, node);
78982             writeSpace();
78983             emitExpression(node.expression);
78984         }
78985         function emitPrefixUnaryExpression(node) {
78986             writeTokenText(node.operator, writeOperator);
78987             if (shouldEmitWhitespaceBeforeOperand(node)) {
78988                 writeSpace();
78989             }
78990             emitExpression(node.operand);
78991         }
78992         function shouldEmitWhitespaceBeforeOperand(node) {
78993             var operand = node.operand;
78994             return operand.kind === 207
78995                 && ((node.operator === 39 && (operand.operator === 39 || operand.operator === 45))
78996                     || (node.operator === 40 && (operand.operator === 40 || operand.operator === 46)));
78997         }
78998         function emitPostfixUnaryExpression(node) {
78999             emitExpression(node.operand);
79000             writeTokenText(node.operator, writeOperator);
79001         }
79002         function emitBinaryExpression(node) {
79003             var nodeStack = [node];
79004             var stateStack = [0];
79005             var stackIndex = 0;
79006             while (stackIndex >= 0) {
79007                 node = nodeStack[stackIndex];
79008                 switch (stateStack[stackIndex]) {
79009                     case 0: {
79010                         maybePipelineEmitExpression(node.left);
79011                         break;
79012                     }
79013                     case 1: {
79014                         var isCommaOperator = node.operatorToken.kind !== 27;
79015                         var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken);
79016                         var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right);
79017                         writeLinesAndIndent(linesBeforeOperator, isCommaOperator);
79018                         emitLeadingCommentsOfPosition(node.operatorToken.pos);
79019                         writeTokenNode(node.operatorToken, node.operatorToken.kind === 97 ? writeKeyword : writeOperator);
79020                         emitTrailingCommentsOfPosition(node.operatorToken.end, true);
79021                         writeLinesAndIndent(linesAfterOperator, true);
79022                         maybePipelineEmitExpression(node.right);
79023                         break;
79024                     }
79025                     case 2: {
79026                         var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken);
79027                         var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right);
79028                         decreaseIndentIf(linesBeforeOperator, linesAfterOperator);
79029                         stackIndex--;
79030                         break;
79031                     }
79032                     default: return ts.Debug.fail("Invalid state " + stateStack[stackIndex] + " for emitBinaryExpressionWorker");
79033                 }
79034             }
79035             function maybePipelineEmitExpression(next) {
79036                 stateStack[stackIndex]++;
79037                 var savedLastNode = lastNode;
79038                 var savedLastSubstitution = lastSubstitution;
79039                 lastNode = next;
79040                 lastSubstitution = undefined;
79041                 var pipelinePhase = getPipelinePhase(0, 1, next);
79042                 if (pipelinePhase === pipelineEmitWithHint && ts.isBinaryExpression(next)) {
79043                     stackIndex++;
79044                     stateStack[stackIndex] = 0;
79045                     nodeStack[stackIndex] = next;
79046                 }
79047                 else {
79048                     pipelinePhase(1, next);
79049                 }
79050                 ts.Debug.assert(lastNode === next);
79051                 lastNode = savedLastNode;
79052                 lastSubstitution = savedLastSubstitution;
79053             }
79054         }
79055         function emitConditionalExpression(node) {
79056             var linesBeforeQuestion = getLinesBetweenNodes(node, node.condition, node.questionToken);
79057             var linesAfterQuestion = getLinesBetweenNodes(node, node.questionToken, node.whenTrue);
79058             var linesBeforeColon = getLinesBetweenNodes(node, node.whenTrue, node.colonToken);
79059             var linesAfterColon = getLinesBetweenNodes(node, node.colonToken, node.whenFalse);
79060             emitExpression(node.condition);
79061             writeLinesAndIndent(linesBeforeQuestion, true);
79062             emit(node.questionToken);
79063             writeLinesAndIndent(linesAfterQuestion, true);
79064             emitExpression(node.whenTrue);
79065             decreaseIndentIf(linesBeforeQuestion, linesAfterQuestion);
79066             writeLinesAndIndent(linesBeforeColon, true);
79067             emit(node.colonToken);
79068             writeLinesAndIndent(linesAfterColon, true);
79069             emitExpression(node.whenFalse);
79070             decreaseIndentIf(linesBeforeColon, linesAfterColon);
79071         }
79072         function emitTemplateExpression(node) {
79073             emit(node.head);
79074             emitList(node, node.templateSpans, 262144);
79075         }
79076         function emitYieldExpression(node) {
79077             emitTokenWithComment(121, node.pos, writeKeyword, node);
79078             emit(node.asteriskToken);
79079             emitExpressionWithLeadingSpace(node.expression);
79080         }
79081         function emitSpreadExpression(node) {
79082             emitTokenWithComment(25, node.pos, writePunctuation, node);
79083             emitExpression(node.expression);
79084         }
79085         function emitClassExpression(node) {
79086             generateNameIfNeeded(node.name);
79087             emitClassDeclarationOrExpression(node);
79088         }
79089         function emitExpressionWithTypeArguments(node) {
79090             emitExpression(node.expression);
79091             emitTypeArguments(node, node.typeArguments);
79092         }
79093         function emitAsExpression(node) {
79094             emitExpression(node.expression);
79095             if (node.type) {
79096                 writeSpace();
79097                 writeKeyword("as");
79098                 writeSpace();
79099                 emit(node.type);
79100             }
79101         }
79102         function emitNonNullExpression(node) {
79103             emitExpression(node.expression);
79104             writeOperator("!");
79105         }
79106         function emitMetaProperty(node) {
79107             writeToken(node.keywordToken, node.pos, writePunctuation);
79108             writePunctuation(".");
79109             emit(node.name);
79110         }
79111         function emitTemplateSpan(node) {
79112             emitExpression(node.expression);
79113             emit(node.literal);
79114         }
79115         function emitBlock(node) {
79116             emitBlockStatements(node, !node.multiLine && isEmptyBlock(node));
79117         }
79118         function emitBlockStatements(node, forceSingleLine) {
79119             emitTokenWithComment(18, node.pos, writePunctuation, node);
79120             var format = forceSingleLine || ts.getEmitFlags(node) & 1 ? 768 : 129;
79121             emitList(node, node.statements, format);
79122             emitTokenWithComment(19, node.statements.end, writePunctuation, node, !!(format & 1));
79123         }
79124         function emitVariableStatement(node) {
79125             emitModifiers(node, node.modifiers);
79126             emit(node.declarationList);
79127             writeTrailingSemicolon();
79128         }
79129         function emitEmptyStatement(isEmbeddedStatement) {
79130             if (isEmbeddedStatement) {
79131                 writePunctuation(";");
79132             }
79133             else {
79134                 writeTrailingSemicolon();
79135             }
79136         }
79137         function emitExpressionStatement(node) {
79138             emitExpression(node.expression);
79139             if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
79140                 writeTrailingSemicolon();
79141             }
79142         }
79143         function emitIfStatement(node) {
79144             var openParenPos = emitTokenWithComment(95, node.pos, writeKeyword, node);
79145             writeSpace();
79146             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79147             emitExpression(node.expression);
79148             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
79149             emitEmbeddedStatement(node, node.thenStatement);
79150             if (node.elseStatement) {
79151                 writeLineOrSpace(node);
79152                 emitTokenWithComment(87, node.thenStatement.end, writeKeyword, node);
79153                 if (node.elseStatement.kind === 227) {
79154                     writeSpace();
79155                     emit(node.elseStatement);
79156                 }
79157                 else {
79158                     emitEmbeddedStatement(node, node.elseStatement);
79159                 }
79160             }
79161         }
79162         function emitWhileClause(node, startPos) {
79163             var openParenPos = emitTokenWithComment(111, startPos, writeKeyword, node);
79164             writeSpace();
79165             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79166             emitExpression(node.expression);
79167             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
79168         }
79169         function emitDoStatement(node) {
79170             emitTokenWithComment(86, node.pos, writeKeyword, node);
79171             emitEmbeddedStatement(node, node.statement);
79172             if (ts.isBlock(node.statement)) {
79173                 writeSpace();
79174             }
79175             else {
79176                 writeLineOrSpace(node);
79177             }
79178             emitWhileClause(node, node.statement.end);
79179             writeTrailingSemicolon();
79180         }
79181         function emitWhileStatement(node) {
79182             emitWhileClause(node, node.pos);
79183             emitEmbeddedStatement(node, node.statement);
79184         }
79185         function emitForStatement(node) {
79186             var openParenPos = emitTokenWithComment(93, node.pos, writeKeyword, node);
79187             writeSpace();
79188             var pos = emitTokenWithComment(20, openParenPos, writePunctuation, node);
79189             emitForBinding(node.initializer);
79190             pos = emitTokenWithComment(26, node.initializer ? node.initializer.end : pos, writePunctuation, node);
79191             emitExpressionWithLeadingSpace(node.condition);
79192             pos = emitTokenWithComment(26, node.condition ? node.condition.end : pos, writePunctuation, node);
79193             emitExpressionWithLeadingSpace(node.incrementor);
79194             emitTokenWithComment(21, node.incrementor ? node.incrementor.end : pos, writePunctuation, node);
79195             emitEmbeddedStatement(node, node.statement);
79196         }
79197         function emitForInStatement(node) {
79198             var openParenPos = emitTokenWithComment(93, node.pos, writeKeyword, node);
79199             writeSpace();
79200             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79201             emitForBinding(node.initializer);
79202             writeSpace();
79203             emitTokenWithComment(97, node.initializer.end, writeKeyword, node);
79204             writeSpace();
79205             emitExpression(node.expression);
79206             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
79207             emitEmbeddedStatement(node, node.statement);
79208         }
79209         function emitForOfStatement(node) {
79210             var openParenPos = emitTokenWithComment(93, node.pos, writeKeyword, node);
79211             writeSpace();
79212             emitWithTrailingSpace(node.awaitModifier);
79213             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79214             emitForBinding(node.initializer);
79215             writeSpace();
79216             emitTokenWithComment(152, node.initializer.end, writeKeyword, node);
79217             writeSpace();
79218             emitExpression(node.expression);
79219             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
79220             emitEmbeddedStatement(node, node.statement);
79221         }
79222         function emitForBinding(node) {
79223             if (node !== undefined) {
79224                 if (node.kind === 243) {
79225                     emit(node);
79226                 }
79227                 else {
79228                     emitExpression(node);
79229                 }
79230             }
79231         }
79232         function emitContinueStatement(node) {
79233             emitTokenWithComment(82, node.pos, writeKeyword, node);
79234             emitWithLeadingSpace(node.label);
79235             writeTrailingSemicolon();
79236         }
79237         function emitBreakStatement(node) {
79238             emitTokenWithComment(77, node.pos, writeKeyword, node);
79239             emitWithLeadingSpace(node.label);
79240             writeTrailingSemicolon();
79241         }
79242         function emitTokenWithComment(token, pos, writer, contextNode, indentLeading) {
79243             var node = ts.getParseTreeNode(contextNode);
79244             var isSimilarNode = node && node.kind === contextNode.kind;
79245             var startPos = pos;
79246             if (isSimilarNode && currentSourceFile) {
79247                 pos = ts.skipTrivia(currentSourceFile.text, pos);
79248             }
79249             if (emitLeadingCommentsOfPosition && isSimilarNode && contextNode.pos !== startPos) {
79250                 var needsIndent = indentLeading && currentSourceFile && !ts.positionsAreOnSameLine(startPos, pos, currentSourceFile);
79251                 if (needsIndent) {
79252                     increaseIndent();
79253                 }
79254                 emitLeadingCommentsOfPosition(startPos);
79255                 if (needsIndent) {
79256                     decreaseIndent();
79257                 }
79258             }
79259             pos = writeTokenText(token, writer, pos);
79260             if (emitTrailingCommentsOfPosition && isSimilarNode && contextNode.end !== pos) {
79261                 emitTrailingCommentsOfPosition(pos, true);
79262             }
79263             return pos;
79264         }
79265         function emitReturnStatement(node) {
79266             emitTokenWithComment(101, node.pos, writeKeyword, node);
79267             emitExpressionWithLeadingSpace(node.expression);
79268             writeTrailingSemicolon();
79269         }
79270         function emitWithStatement(node) {
79271             var openParenPos = emitTokenWithComment(112, node.pos, writeKeyword, node);
79272             writeSpace();
79273             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79274             emitExpression(node.expression);
79275             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
79276             emitEmbeddedStatement(node, node.statement);
79277         }
79278         function emitSwitchStatement(node) {
79279             var openParenPos = emitTokenWithComment(103, node.pos, writeKeyword, node);
79280             writeSpace();
79281             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79282             emitExpression(node.expression);
79283             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
79284             writeSpace();
79285             emit(node.caseBlock);
79286         }
79287         function emitLabeledStatement(node) {
79288             emit(node.label);
79289             emitTokenWithComment(58, node.label.end, writePunctuation, node);
79290             writeSpace();
79291             emit(node.statement);
79292         }
79293         function emitThrowStatement(node) {
79294             emitTokenWithComment(105, node.pos, writeKeyword, node);
79295             emitExpressionWithLeadingSpace(node.expression);
79296             writeTrailingSemicolon();
79297         }
79298         function emitTryStatement(node) {
79299             emitTokenWithComment(107, node.pos, writeKeyword, node);
79300             writeSpace();
79301             emit(node.tryBlock);
79302             if (node.catchClause) {
79303                 writeLineOrSpace(node);
79304                 emit(node.catchClause);
79305             }
79306             if (node.finallyBlock) {
79307                 writeLineOrSpace(node);
79308                 emitTokenWithComment(92, (node.catchClause || node.tryBlock).end, writeKeyword, node);
79309                 writeSpace();
79310                 emit(node.finallyBlock);
79311             }
79312         }
79313         function emitDebuggerStatement(node) {
79314             writeToken(83, node.pos, writeKeyword);
79315             writeTrailingSemicolon();
79316         }
79317         function emitVariableDeclaration(node) {
79318             emit(node.name);
79319             emit(node.exclamationToken);
79320             emitTypeAnnotation(node.type);
79321             emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node);
79322         }
79323         function emitVariableDeclarationList(node) {
79324             writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var");
79325             writeSpace();
79326             emitList(node, node.declarations, 528);
79327         }
79328         function emitFunctionDeclaration(node) {
79329             emitFunctionDeclarationOrExpression(node);
79330         }
79331         function emitFunctionDeclarationOrExpression(node) {
79332             emitDecorators(node, node.decorators);
79333             emitModifiers(node, node.modifiers);
79334             writeKeyword("function");
79335             emit(node.asteriskToken);
79336             writeSpace();
79337             emitIdentifierName(node.name);
79338             emitSignatureAndBody(node, emitSignatureHead);
79339         }
79340         function emitBlockCallback(_hint, body) {
79341             emitBlockFunctionBody(body);
79342         }
79343         function emitSignatureAndBody(node, emitSignatureHead) {
79344             var body = node.body;
79345             if (body) {
79346                 if (ts.isBlock(body)) {
79347                     var indentedFlag = ts.getEmitFlags(node) & 65536;
79348                     if (indentedFlag) {
79349                         increaseIndent();
79350                     }
79351                     pushNameGenerationScope(node);
79352                     ts.forEach(node.parameters, generateNames);
79353                     generateNames(node.body);
79354                     emitSignatureHead(node);
79355                     if (onEmitNode) {
79356                         onEmitNode(4, body, emitBlockCallback);
79357                     }
79358                     else {
79359                         emitBlockFunctionBody(body);
79360                     }
79361                     popNameGenerationScope(node);
79362                     if (indentedFlag) {
79363                         decreaseIndent();
79364                     }
79365                 }
79366                 else {
79367                     emitSignatureHead(node);
79368                     writeSpace();
79369                     emitExpression(body);
79370                 }
79371             }
79372             else {
79373                 emitSignatureHead(node);
79374                 writeTrailingSemicolon();
79375             }
79376         }
79377         function emitSignatureHead(node) {
79378             emitTypeParameters(node, node.typeParameters);
79379             emitParameters(node, node.parameters);
79380             emitTypeAnnotation(node.type);
79381         }
79382         function shouldEmitBlockFunctionBodyOnSingleLine(body) {
79383             if (ts.getEmitFlags(body) & 1) {
79384                 return true;
79385             }
79386             if (body.multiLine) {
79387                 return false;
79388             }
79389             if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
79390                 return false;
79391             }
79392             if (getLeadingLineTerminatorCount(body, body.statements, 2)
79393                 || getClosingLineTerminatorCount(body, body.statements, 2)) {
79394                 return false;
79395             }
79396             var previousStatement;
79397             for (var _a = 0, _b = body.statements; _a < _b.length; _a++) {
79398                 var statement = _b[_a];
79399                 if (getSeparatingLineTerminatorCount(previousStatement, statement, 2) > 0) {
79400                     return false;
79401                 }
79402                 previousStatement = statement;
79403             }
79404             return true;
79405         }
79406         function emitBlockFunctionBody(body) {
79407             writeSpace();
79408             writePunctuation("{");
79409             increaseIndent();
79410             var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body)
79411                 ? emitBlockFunctionBodyOnSingleLine
79412                 : emitBlockFunctionBodyWorker;
79413             if (emitBodyWithDetachedComments) {
79414                 emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
79415             }
79416             else {
79417                 emitBlockFunctionBody(body);
79418             }
79419             decreaseIndent();
79420             writeToken(19, body.statements.end, writePunctuation, body);
79421         }
79422         function emitBlockFunctionBodyOnSingleLine(body) {
79423             emitBlockFunctionBodyWorker(body, true);
79424         }
79425         function emitBlockFunctionBodyWorker(body, emitBlockFunctionBodyOnSingleLine) {
79426             var statementOffset = emitPrologueDirectives(body.statements);
79427             var pos = writer.getTextPos();
79428             emitHelpers(body);
79429             if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) {
79430                 decreaseIndent();
79431                 emitList(body, body.statements, 768);
79432                 increaseIndent();
79433             }
79434             else {
79435                 emitList(body, body.statements, 1, statementOffset);
79436             }
79437         }
79438         function emitClassDeclaration(node) {
79439             emitClassDeclarationOrExpression(node);
79440         }
79441         function emitClassDeclarationOrExpression(node) {
79442             ts.forEach(node.members, generateMemberNames);
79443             emitDecorators(node, node.decorators);
79444             emitModifiers(node, node.modifiers);
79445             writeKeyword("class");
79446             if (node.name) {
79447                 writeSpace();
79448                 emitIdentifierName(node.name);
79449             }
79450             var indentedFlag = ts.getEmitFlags(node) & 65536;
79451             if (indentedFlag) {
79452                 increaseIndent();
79453             }
79454             emitTypeParameters(node, node.typeParameters);
79455             emitList(node, node.heritageClauses, 0);
79456             writeSpace();
79457             writePunctuation("{");
79458             emitList(node, node.members, 129);
79459             writePunctuation("}");
79460             if (indentedFlag) {
79461                 decreaseIndent();
79462             }
79463         }
79464         function emitInterfaceDeclaration(node) {
79465             emitDecorators(node, node.decorators);
79466             emitModifiers(node, node.modifiers);
79467             writeKeyword("interface");
79468             writeSpace();
79469             emit(node.name);
79470             emitTypeParameters(node, node.typeParameters);
79471             emitList(node, node.heritageClauses, 512);
79472             writeSpace();
79473             writePunctuation("{");
79474             emitList(node, node.members, 129);
79475             writePunctuation("}");
79476         }
79477         function emitTypeAliasDeclaration(node) {
79478             emitDecorators(node, node.decorators);
79479             emitModifiers(node, node.modifiers);
79480             writeKeyword("type");
79481             writeSpace();
79482             emit(node.name);
79483             emitTypeParameters(node, node.typeParameters);
79484             writeSpace();
79485             writePunctuation("=");
79486             writeSpace();
79487             emit(node.type);
79488             writeTrailingSemicolon();
79489         }
79490         function emitEnumDeclaration(node) {
79491             emitModifiers(node, node.modifiers);
79492             writeKeyword("enum");
79493             writeSpace();
79494             emit(node.name);
79495             writeSpace();
79496             writePunctuation("{");
79497             emitList(node, node.members, 145);
79498             writePunctuation("}");
79499         }
79500         function emitModuleDeclaration(node) {
79501             emitModifiers(node, node.modifiers);
79502             if (~node.flags & 1024) {
79503                 writeKeyword(node.flags & 16 ? "namespace" : "module");
79504                 writeSpace();
79505             }
79506             emit(node.name);
79507             var body = node.body;
79508             if (!body)
79509                 return writeTrailingSemicolon();
79510             while (body.kind === 249) {
79511                 writePunctuation(".");
79512                 emit(body.name);
79513                 body = body.body;
79514             }
79515             writeSpace();
79516             emit(body);
79517         }
79518         function emitModuleBlock(node) {
79519             pushNameGenerationScope(node);
79520             ts.forEach(node.statements, generateNames);
79521             emitBlockStatements(node, isEmptyBlock(node));
79522             popNameGenerationScope(node);
79523         }
79524         function emitCaseBlock(node) {
79525             emitTokenWithComment(18, node.pos, writePunctuation, node);
79526             emitList(node, node.clauses, 129);
79527             emitTokenWithComment(19, node.clauses.end, writePunctuation, node, true);
79528         }
79529         function emitImportEqualsDeclaration(node) {
79530             emitModifiers(node, node.modifiers);
79531             emitTokenWithComment(96, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node);
79532             writeSpace();
79533             emit(node.name);
79534             writeSpace();
79535             emitTokenWithComment(62, node.name.end, writePunctuation, node);
79536             writeSpace();
79537             emitModuleReference(node.moduleReference);
79538             writeTrailingSemicolon();
79539         }
79540         function emitModuleReference(node) {
79541             if (node.kind === 75) {
79542                 emitExpression(node);
79543             }
79544             else {
79545                 emit(node);
79546             }
79547         }
79548         function emitImportDeclaration(node) {
79549             emitModifiers(node, node.modifiers);
79550             emitTokenWithComment(96, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node);
79551             writeSpace();
79552             if (node.importClause) {
79553                 emit(node.importClause);
79554                 writeSpace();
79555                 emitTokenWithComment(149, node.importClause.end, writeKeyword, node);
79556                 writeSpace();
79557             }
79558             emitExpression(node.moduleSpecifier);
79559             writeTrailingSemicolon();
79560         }
79561         function emitImportClause(node) {
79562             if (node.isTypeOnly) {
79563                 emitTokenWithComment(145, node.pos, writeKeyword, node);
79564                 writeSpace();
79565             }
79566             emit(node.name);
79567             if (node.name && node.namedBindings) {
79568                 emitTokenWithComment(27, node.name.end, writePunctuation, node);
79569                 writeSpace();
79570             }
79571             emit(node.namedBindings);
79572         }
79573         function emitNamespaceImport(node) {
79574             var asPos = emitTokenWithComment(41, node.pos, writePunctuation, node);
79575             writeSpace();
79576             emitTokenWithComment(123, asPos, writeKeyword, node);
79577             writeSpace();
79578             emit(node.name);
79579         }
79580         function emitNamedImports(node) {
79581             emitNamedImportsOrExports(node);
79582         }
79583         function emitImportSpecifier(node) {
79584             emitImportOrExportSpecifier(node);
79585         }
79586         function emitExportAssignment(node) {
79587             var nextPos = emitTokenWithComment(89, node.pos, writeKeyword, node);
79588             writeSpace();
79589             if (node.isExportEquals) {
79590                 emitTokenWithComment(62, nextPos, writeOperator, node);
79591             }
79592             else {
79593                 emitTokenWithComment(84, nextPos, writeKeyword, node);
79594             }
79595             writeSpace();
79596             emitExpression(node.expression);
79597             writeTrailingSemicolon();
79598         }
79599         function emitExportDeclaration(node) {
79600             var nextPos = emitTokenWithComment(89, node.pos, writeKeyword, node);
79601             writeSpace();
79602             if (node.isTypeOnly) {
79603                 nextPos = emitTokenWithComment(145, nextPos, writeKeyword, node);
79604                 writeSpace();
79605             }
79606             if (node.exportClause) {
79607                 emit(node.exportClause);
79608             }
79609             else {
79610                 nextPos = emitTokenWithComment(41, nextPos, writePunctuation, node);
79611             }
79612             if (node.moduleSpecifier) {
79613                 writeSpace();
79614                 var fromPos = node.exportClause ? node.exportClause.end : nextPos;
79615                 emitTokenWithComment(149, fromPos, writeKeyword, node);
79616                 writeSpace();
79617                 emitExpression(node.moduleSpecifier);
79618             }
79619             writeTrailingSemicolon();
79620         }
79621         function emitNamespaceExportDeclaration(node) {
79622             var nextPos = emitTokenWithComment(89, node.pos, writeKeyword, node);
79623             writeSpace();
79624             nextPos = emitTokenWithComment(123, nextPos, writeKeyword, node);
79625             writeSpace();
79626             nextPos = emitTokenWithComment(136, nextPos, writeKeyword, node);
79627             writeSpace();
79628             emit(node.name);
79629             writeTrailingSemicolon();
79630         }
79631         function emitNamespaceExport(node) {
79632             var asPos = emitTokenWithComment(41, node.pos, writePunctuation, node);
79633             writeSpace();
79634             emitTokenWithComment(123, asPos, writeKeyword, node);
79635             writeSpace();
79636             emit(node.name);
79637         }
79638         function emitNamedExports(node) {
79639             emitNamedImportsOrExports(node);
79640         }
79641         function emitExportSpecifier(node) {
79642             emitImportOrExportSpecifier(node);
79643         }
79644         function emitNamedImportsOrExports(node) {
79645             writePunctuation("{");
79646             emitList(node, node.elements, 525136);
79647             writePunctuation("}");
79648         }
79649         function emitImportOrExportSpecifier(node) {
79650             if (node.propertyName) {
79651                 emit(node.propertyName);
79652                 writeSpace();
79653                 emitTokenWithComment(123, node.propertyName.end, writeKeyword, node);
79654                 writeSpace();
79655             }
79656             emit(node.name);
79657         }
79658         function emitExternalModuleReference(node) {
79659             writeKeyword("require");
79660             writePunctuation("(");
79661             emitExpression(node.expression);
79662             writePunctuation(")");
79663         }
79664         function emitJsxElement(node) {
79665             emit(node.openingElement);
79666             emitList(node, node.children, 262144);
79667             emit(node.closingElement);
79668         }
79669         function emitJsxSelfClosingElement(node) {
79670             writePunctuation("<");
79671             emitJsxTagName(node.tagName);
79672             emitTypeArguments(node, node.typeArguments);
79673             writeSpace();
79674             emit(node.attributes);
79675             writePunctuation("/>");
79676         }
79677         function emitJsxFragment(node) {
79678             emit(node.openingFragment);
79679             emitList(node, node.children, 262144);
79680             emit(node.closingFragment);
79681         }
79682         function emitJsxOpeningElementOrFragment(node) {
79683             writePunctuation("<");
79684             if (ts.isJsxOpeningElement(node)) {
79685                 var indented = writeLineSeparatorsAndIndentBefore(node.tagName, node);
79686                 emitJsxTagName(node.tagName);
79687                 emitTypeArguments(node, node.typeArguments);
79688                 if (node.attributes.properties && node.attributes.properties.length > 0) {
79689                     writeSpace();
79690                 }
79691                 emit(node.attributes);
79692                 writeLineSeparatorsAfter(node.attributes, node);
79693                 decreaseIndentIf(indented);
79694             }
79695             writePunctuation(">");
79696         }
79697         function emitJsxText(node) {
79698             writer.writeLiteral(node.text);
79699         }
79700         function emitJsxClosingElementOrFragment(node) {
79701             writePunctuation("</");
79702             if (ts.isJsxClosingElement(node)) {
79703                 emitJsxTagName(node.tagName);
79704             }
79705             writePunctuation(">");
79706         }
79707         function emitJsxAttributes(node) {
79708             emitList(node, node.properties, 262656);
79709         }
79710         function emitJsxAttribute(node) {
79711             emit(node.name);
79712             emitNodeWithPrefix("=", writePunctuation, node.initializer, emitJsxAttributeValue);
79713         }
79714         function emitJsxSpreadAttribute(node) {
79715             writePunctuation("{...");
79716             emitExpression(node.expression);
79717             writePunctuation("}");
79718         }
79719         function emitJsxExpression(node) {
79720             if (node.expression) {
79721                 writePunctuation("{");
79722                 emit(node.dotDotDotToken);
79723                 emitExpression(node.expression);
79724                 writePunctuation("}");
79725             }
79726         }
79727         function emitJsxTagName(node) {
79728             if (node.kind === 75) {
79729                 emitExpression(node);
79730             }
79731             else {
79732                 emit(node);
79733             }
79734         }
79735         function emitCaseClause(node) {
79736             emitTokenWithComment(78, node.pos, writeKeyword, node);
79737             writeSpace();
79738             emitExpression(node.expression);
79739             emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end);
79740         }
79741         function emitDefaultClause(node) {
79742             var pos = emitTokenWithComment(84, node.pos, writeKeyword, node);
79743             emitCaseOrDefaultClauseRest(node, node.statements, pos);
79744         }
79745         function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) {
79746             var emitAsSingleStatement = statements.length === 1 &&
79747                 (ts.nodeIsSynthesized(parentNode) ||
79748                     ts.nodeIsSynthesized(statements[0]) ||
79749                     ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile));
79750             var format = 163969;
79751             if (emitAsSingleStatement) {
79752                 writeToken(58, colonPos, writePunctuation, parentNode);
79753                 writeSpace();
79754                 format &= ~(1 | 128);
79755             }
79756             else {
79757                 emitTokenWithComment(58, colonPos, writePunctuation, parentNode);
79758             }
79759             emitList(parentNode, statements, format);
79760         }
79761         function emitHeritageClause(node) {
79762             writeSpace();
79763             writeTokenText(node.token, writeKeyword);
79764             writeSpace();
79765             emitList(node, node.types, 528);
79766         }
79767         function emitCatchClause(node) {
79768             var openParenPos = emitTokenWithComment(79, node.pos, writeKeyword, node);
79769             writeSpace();
79770             if (node.variableDeclaration) {
79771                 emitTokenWithComment(20, openParenPos, writePunctuation, node);
79772                 emit(node.variableDeclaration);
79773                 emitTokenWithComment(21, node.variableDeclaration.end, writePunctuation, node);
79774                 writeSpace();
79775             }
79776             emit(node.block);
79777         }
79778         function emitPropertyAssignment(node) {
79779             emit(node.name);
79780             writePunctuation(":");
79781             writeSpace();
79782             var initializer = node.initializer;
79783             if (emitTrailingCommentsOfPosition && (ts.getEmitFlags(initializer) & 512) === 0) {
79784                 var commentRange = ts.getCommentRange(initializer);
79785                 emitTrailingCommentsOfPosition(commentRange.pos);
79786             }
79787             emitExpression(initializer);
79788         }
79789         function emitShorthandPropertyAssignment(node) {
79790             emit(node.name);
79791             if (node.objectAssignmentInitializer) {
79792                 writeSpace();
79793                 writePunctuation("=");
79794                 writeSpace();
79795                 emitExpression(node.objectAssignmentInitializer);
79796             }
79797         }
79798         function emitSpreadAssignment(node) {
79799             if (node.expression) {
79800                 emitTokenWithComment(25, node.pos, writePunctuation, node);
79801                 emitExpression(node.expression);
79802             }
79803         }
79804         function emitEnumMember(node) {
79805             emit(node.name);
79806             emitInitializer(node.initializer, node.name.end, node);
79807         }
79808         function emitJSDoc(node) {
79809             write("/**");
79810             if (node.comment) {
79811                 var lines = node.comment.split(/\r\n?|\n/g);
79812                 for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) {
79813                     var line = lines_2[_a];
79814                     writeLine();
79815                     writeSpace();
79816                     writePunctuation("*");
79817                     writeSpace();
79818                     write(line);
79819                 }
79820             }
79821             if (node.tags) {
79822                 if (node.tags.length === 1 && node.tags[0].kind === 320 && !node.comment) {
79823                     writeSpace();
79824                     emit(node.tags[0]);
79825                 }
79826                 else {
79827                     emitList(node, node.tags, 33);
79828                 }
79829             }
79830             writeSpace();
79831             write("*/");
79832         }
79833         function emitJSDocSimpleTypedTag(tag) {
79834             emitJSDocTagName(tag.tagName);
79835             emitJSDocTypeExpression(tag.typeExpression);
79836             emitJSDocComment(tag.comment);
79837         }
79838         function emitJSDocHeritageTag(tag) {
79839             emitJSDocTagName(tag.tagName);
79840             writeSpace();
79841             writePunctuation("{");
79842             emit(tag.class);
79843             writePunctuation("}");
79844             emitJSDocComment(tag.comment);
79845         }
79846         function emitJSDocTemplateTag(tag) {
79847             emitJSDocTagName(tag.tagName);
79848             emitJSDocTypeExpression(tag.constraint);
79849             writeSpace();
79850             emitList(tag, tag.typeParameters, 528);
79851             emitJSDocComment(tag.comment);
79852         }
79853         function emitJSDocTypedefTag(tag) {
79854             emitJSDocTagName(tag.tagName);
79855             if (tag.typeExpression) {
79856                 if (tag.typeExpression.kind === 294) {
79857                     emitJSDocTypeExpression(tag.typeExpression);
79858                 }
79859                 else {
79860                     writeSpace();
79861                     writePunctuation("{");
79862                     write("Object");
79863                     if (tag.typeExpression.isArrayType) {
79864                         writePunctuation("[");
79865                         writePunctuation("]");
79866                     }
79867                     writePunctuation("}");
79868                 }
79869             }
79870             if (tag.fullName) {
79871                 writeSpace();
79872                 emit(tag.fullName);
79873             }
79874             emitJSDocComment(tag.comment);
79875             if (tag.typeExpression && tag.typeExpression.kind === 304) {
79876                 emitJSDocTypeLiteral(tag.typeExpression);
79877             }
79878         }
79879         function emitJSDocCallbackTag(tag) {
79880             emitJSDocTagName(tag.tagName);
79881             if (tag.name) {
79882                 writeSpace();
79883                 emit(tag.name);
79884             }
79885             emitJSDocComment(tag.comment);
79886             emitJSDocSignature(tag.typeExpression);
79887         }
79888         function emitJSDocSimpleTag(tag) {
79889             emitJSDocTagName(tag.tagName);
79890             emitJSDocComment(tag.comment);
79891         }
79892         function emitJSDocTypeLiteral(lit) {
79893             emitList(lit, ts.createNodeArray(lit.jsDocPropertyTags), 33);
79894         }
79895         function emitJSDocSignature(sig) {
79896             if (sig.typeParameters) {
79897                 emitList(sig, ts.createNodeArray(sig.typeParameters), 33);
79898             }
79899             if (sig.parameters) {
79900                 emitList(sig, ts.createNodeArray(sig.parameters), 33);
79901             }
79902             if (sig.type) {
79903                 writeLine();
79904                 writeSpace();
79905                 writePunctuation("*");
79906                 writeSpace();
79907                 emit(sig.type);
79908             }
79909         }
79910         function emitJSDocPropertyLikeTag(param) {
79911             emitJSDocTagName(param.tagName);
79912             emitJSDocTypeExpression(param.typeExpression);
79913             writeSpace();
79914             if (param.isBracketed) {
79915                 writePunctuation("[");
79916             }
79917             emit(param.name);
79918             if (param.isBracketed) {
79919                 writePunctuation("]");
79920             }
79921             emitJSDocComment(param.comment);
79922         }
79923         function emitJSDocTagName(tagName) {
79924             writePunctuation("@");
79925             emit(tagName);
79926         }
79927         function emitJSDocComment(comment) {
79928             if (comment) {
79929                 writeSpace();
79930                 write(comment);
79931             }
79932         }
79933         function emitJSDocTypeExpression(typeExpression) {
79934             if (typeExpression) {
79935                 writeSpace();
79936                 writePunctuation("{");
79937                 emit(typeExpression.type);
79938                 writePunctuation("}");
79939             }
79940         }
79941         function emitSourceFile(node) {
79942             writeLine();
79943             var statements = node.statements;
79944             if (emitBodyWithDetachedComments) {
79945                 var shouldEmitDetachedComment = statements.length === 0 ||
79946                     !ts.isPrologueDirective(statements[0]) ||
79947                     ts.nodeIsSynthesized(statements[0]);
79948                 if (shouldEmitDetachedComment) {
79949                     emitBodyWithDetachedComments(node, statements, emitSourceFileWorker);
79950                     return;
79951                 }
79952             }
79953             emitSourceFileWorker(node);
79954         }
79955         function emitSyntheticTripleSlashReferencesIfNeeded(node) {
79956             emitTripleSlashDirectives(!!node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || [], node.syntheticLibReferences || []);
79957             for (var _a = 0, _b = node.prepends; _a < _b.length; _a++) {
79958                 var prepend = _b[_a];
79959                 if (ts.isUnparsedSource(prepend) && prepend.syntheticReferences) {
79960                     for (var _c = 0, _d = prepend.syntheticReferences; _c < _d.length; _c++) {
79961                         var ref = _d[_c];
79962                         emit(ref);
79963                         writeLine();
79964                     }
79965                 }
79966             }
79967         }
79968         function emitTripleSlashDirectivesIfNeeded(node) {
79969             if (node.isDeclarationFile)
79970                 emitTripleSlashDirectives(node.hasNoDefaultLib, node.referencedFiles, node.typeReferenceDirectives, node.libReferenceDirectives);
79971         }
79972         function emitTripleSlashDirectives(hasNoDefaultLib, files, types, libs) {
79973             if (hasNoDefaultLib) {
79974                 var pos = writer.getTextPos();
79975                 writeComment("/// <reference no-default-lib=\"true\"/>");
79976                 if (bundleFileInfo)
79977                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" });
79978                 writeLine();
79979             }
79980             if (currentSourceFile && currentSourceFile.moduleName) {
79981                 writeComment("/// <amd-module name=\"" + currentSourceFile.moduleName + "\" />");
79982                 writeLine();
79983             }
79984             if (currentSourceFile && currentSourceFile.amdDependencies) {
79985                 for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) {
79986                     var dep = _b[_a];
79987                     if (dep.name) {
79988                         writeComment("/// <amd-dependency name=\"" + dep.name + "\" path=\"" + dep.path + "\" />");
79989                     }
79990                     else {
79991                         writeComment("/// <amd-dependency path=\"" + dep.path + "\" />");
79992                     }
79993                     writeLine();
79994                 }
79995             }
79996             for (var _c = 0, files_1 = files; _c < files_1.length; _c++) {
79997                 var directive = files_1[_c];
79998                 var pos = writer.getTextPos();
79999                 writeComment("/// <reference path=\"" + directive.fileName + "\" />");
80000                 if (bundleFileInfo)
80001                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference", data: directive.fileName });
80002                 writeLine();
80003             }
80004             for (var _d = 0, types_22 = types; _d < types_22.length; _d++) {
80005                 var directive = types_22[_d];
80006                 var pos = writer.getTextPos();
80007                 writeComment("/// <reference types=\"" + directive.fileName + "\" />");
80008                 if (bundleFileInfo)
80009                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "type", data: directive.fileName });
80010                 writeLine();
80011             }
80012             for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) {
80013                 var directive = libs_1[_e];
80014                 var pos = writer.getTextPos();
80015                 writeComment("/// <reference lib=\"" + directive.fileName + "\" />");
80016                 if (bundleFileInfo)
80017                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib", data: directive.fileName });
80018                 writeLine();
80019             }
80020         }
80021         function emitSourceFileWorker(node) {
80022             var statements = node.statements;
80023             pushNameGenerationScope(node);
80024             ts.forEach(node.statements, generateNames);
80025             emitHelpers(node);
80026             var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); });
80027             emitTripleSlashDirectivesIfNeeded(node);
80028             emitList(node, statements, 1, index === -1 ? statements.length : index);
80029             popNameGenerationScope(node);
80030         }
80031         function emitPartiallyEmittedExpression(node) {
80032             emitExpression(node.expression);
80033         }
80034         function emitCommaList(node) {
80035             emitExpressionList(node, node.elements, 528);
80036         }
80037         function emitPrologueDirectives(statements, sourceFile, seenPrologueDirectives, recordBundleFileSection) {
80038             var needsToSetSourceFile = !!sourceFile;
80039             for (var i = 0; i < statements.length; i++) {
80040                 var statement = statements[i];
80041                 if (ts.isPrologueDirective(statement)) {
80042                     var shouldEmitPrologueDirective = seenPrologueDirectives ? !seenPrologueDirectives.has(statement.expression.text) : true;
80043                     if (shouldEmitPrologueDirective) {
80044                         if (needsToSetSourceFile) {
80045                             needsToSetSourceFile = false;
80046                             setSourceFile(sourceFile);
80047                         }
80048                         writeLine();
80049                         var pos = writer.getTextPos();
80050                         emit(statement);
80051                         if (recordBundleFileSection && bundleFileInfo)
80052                             bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue", data: statement.expression.text });
80053                         if (seenPrologueDirectives) {
80054                             seenPrologueDirectives.set(statement.expression.text, true);
80055                         }
80056                     }
80057                 }
80058                 else {
80059                     return i;
80060                 }
80061             }
80062             return statements.length;
80063         }
80064         function emitUnparsedPrologues(prologues, seenPrologueDirectives) {
80065             for (var _a = 0, prologues_1 = prologues; _a < prologues_1.length; _a++) {
80066                 var prologue = prologues_1[_a];
80067                 if (!seenPrologueDirectives.has(prologue.data)) {
80068                     writeLine();
80069                     var pos = writer.getTextPos();
80070                     emit(prologue);
80071                     if (bundleFileInfo)
80072                         bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue", data: prologue.data });
80073                     if (seenPrologueDirectives) {
80074                         seenPrologueDirectives.set(prologue.data, true);
80075                     }
80076                 }
80077             }
80078         }
80079         function emitPrologueDirectivesIfNeeded(sourceFileOrBundle) {
80080             if (ts.isSourceFile(sourceFileOrBundle)) {
80081                 emitPrologueDirectives(sourceFileOrBundle.statements, sourceFileOrBundle);
80082             }
80083             else {
80084                 var seenPrologueDirectives = ts.createMap();
80085                 for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) {
80086                     var prepend = _b[_a];
80087                     emitUnparsedPrologues(prepend.prologues, seenPrologueDirectives);
80088                 }
80089                 for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) {
80090                     var sourceFile = _d[_c];
80091                     emitPrologueDirectives(sourceFile.statements, sourceFile, seenPrologueDirectives, true);
80092                 }
80093                 setSourceFile(undefined);
80094             }
80095         }
80096         function getPrologueDirectivesFromBundledSourceFiles(bundle) {
80097             var seenPrologueDirectives = ts.createMap();
80098             var prologues;
80099             for (var index = 0; index < bundle.sourceFiles.length; index++) {
80100                 var sourceFile = bundle.sourceFiles[index];
80101                 var directives = void 0;
80102                 var end = 0;
80103                 for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) {
80104                     var statement = _b[_a];
80105                     if (!ts.isPrologueDirective(statement))
80106                         break;
80107                     if (seenPrologueDirectives.has(statement.expression.text))
80108                         continue;
80109                     seenPrologueDirectives.set(statement.expression.text, true);
80110                     (directives || (directives = [])).push({
80111                         pos: statement.pos,
80112                         end: statement.end,
80113                         expression: {
80114                             pos: statement.expression.pos,
80115                             end: statement.expression.end,
80116                             text: statement.expression.text
80117                         }
80118                     });
80119                     end = end < statement.end ? statement.end : end;
80120                 }
80121                 if (directives)
80122                     (prologues || (prologues = [])).push({ file: index, text: sourceFile.text.substring(0, end), directives: directives });
80123             }
80124             return prologues;
80125         }
80126         function emitShebangIfNeeded(sourceFileOrBundle) {
80127             if (ts.isSourceFile(sourceFileOrBundle) || ts.isUnparsedSource(sourceFileOrBundle)) {
80128                 var shebang = ts.getShebang(sourceFileOrBundle.text);
80129                 if (shebang) {
80130                     writeComment(shebang);
80131                     writeLine();
80132                     return true;
80133                 }
80134             }
80135             else {
80136                 for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) {
80137                     var prepend = _b[_a];
80138                     ts.Debug.assertNode(prepend, ts.isUnparsedSource);
80139                     if (emitShebangIfNeeded(prepend)) {
80140                         return true;
80141                     }
80142                 }
80143                 for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) {
80144                     var sourceFile = _d[_c];
80145                     if (emitShebangIfNeeded(sourceFile)) {
80146                         return true;
80147                     }
80148                 }
80149             }
80150         }
80151         function emitNodeWithWriter(node, writer) {
80152             if (!node)
80153                 return;
80154             var savedWrite = write;
80155             write = writer;
80156             emit(node);
80157             write = savedWrite;
80158         }
80159         function emitModifiers(node, modifiers) {
80160             if (modifiers && modifiers.length) {
80161                 emitList(node, modifiers, 262656);
80162                 writeSpace();
80163             }
80164         }
80165         function emitTypeAnnotation(node) {
80166             if (node) {
80167                 writePunctuation(":");
80168                 writeSpace();
80169                 emit(node);
80170             }
80171         }
80172         function emitInitializer(node, equalCommentStartPos, container) {
80173             if (node) {
80174                 writeSpace();
80175                 emitTokenWithComment(62, equalCommentStartPos, writeOperator, container);
80176                 writeSpace();
80177                 emitExpression(node);
80178             }
80179         }
80180         function emitNodeWithPrefix(prefix, prefixWriter, node, emit) {
80181             if (node) {
80182                 prefixWriter(prefix);
80183                 emit(node);
80184             }
80185         }
80186         function emitWithLeadingSpace(node) {
80187             if (node) {
80188                 writeSpace();
80189                 emit(node);
80190             }
80191         }
80192         function emitExpressionWithLeadingSpace(node) {
80193             if (node) {
80194                 writeSpace();
80195                 emitExpression(node);
80196             }
80197         }
80198         function emitWithTrailingSpace(node) {
80199             if (node) {
80200                 emit(node);
80201                 writeSpace();
80202             }
80203         }
80204         function emitEmbeddedStatement(parent, node) {
80205             if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1) {
80206                 writeSpace();
80207                 emit(node);
80208             }
80209             else {
80210                 writeLine();
80211                 increaseIndent();
80212                 if (ts.isEmptyStatement(node)) {
80213                     pipelineEmit(5, node);
80214                 }
80215                 else {
80216                     emit(node);
80217                 }
80218                 decreaseIndent();
80219             }
80220         }
80221         function emitDecorators(parentNode, decorators) {
80222             emitList(parentNode, decorators, 2146305);
80223         }
80224         function emitTypeArguments(parentNode, typeArguments) {
80225             emitList(parentNode, typeArguments, 53776);
80226         }
80227         function emitTypeParameters(parentNode, typeParameters) {
80228             if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) {
80229                 return emitTypeArguments(parentNode, parentNode.typeArguments);
80230             }
80231             emitList(parentNode, typeParameters, 53776);
80232         }
80233         function emitParameters(parentNode, parameters) {
80234             emitList(parentNode, parameters, 2576);
80235         }
80236         function canEmitSimpleArrowHead(parentNode, parameters) {
80237             var parameter = ts.singleOrUndefined(parameters);
80238             return parameter
80239                 && parameter.pos === parentNode.pos
80240                 && ts.isArrowFunction(parentNode)
80241                 && !parentNode.type
80242                 && !ts.some(parentNode.decorators)
80243                 && !ts.some(parentNode.modifiers)
80244                 && !ts.some(parentNode.typeParameters)
80245                 && !ts.some(parameter.decorators)
80246                 && !ts.some(parameter.modifiers)
80247                 && !parameter.dotDotDotToken
80248                 && !parameter.questionToken
80249                 && !parameter.type
80250                 && !parameter.initializer
80251                 && ts.isIdentifier(parameter.name);
80252         }
80253         function emitParametersForArrow(parentNode, parameters) {
80254             if (canEmitSimpleArrowHead(parentNode, parameters)) {
80255                 emitList(parentNode, parameters, 2576 & ~2048);
80256             }
80257             else {
80258                 emitParameters(parentNode, parameters);
80259             }
80260         }
80261         function emitParametersForIndexSignature(parentNode, parameters) {
80262             emitList(parentNode, parameters, 8848);
80263         }
80264         function emitList(parentNode, children, format, start, count) {
80265             emitNodeList(emit, parentNode, children, format, start, count);
80266         }
80267         function emitExpressionList(parentNode, children, format, start, count) {
80268             emitNodeList(emitExpression, parentNode, children, format, start, count);
80269         }
80270         function writeDelimiter(format) {
80271             switch (format & 60) {
80272                 case 0:
80273                     break;
80274                 case 16:
80275                     writePunctuation(",");
80276                     break;
80277                 case 4:
80278                     writeSpace();
80279                     writePunctuation("|");
80280                     break;
80281                 case 32:
80282                     writeSpace();
80283                     writePunctuation("*");
80284                     writeSpace();
80285                     break;
80286                 case 8:
80287                     writeSpace();
80288                     writePunctuation("&");
80289                     break;
80290             }
80291         }
80292         function emitNodeList(emit, parentNode, children, format, start, count) {
80293             if (start === void 0) { start = 0; }
80294             if (count === void 0) { count = children ? children.length - start : 0; }
80295             var isUndefined = children === undefined;
80296             if (isUndefined && format & 16384) {
80297                 return;
80298             }
80299             var isEmpty = children === undefined || start >= children.length || count === 0;
80300             if (isEmpty && format & 32768) {
80301                 if (onBeforeEmitNodeArray) {
80302                     onBeforeEmitNodeArray(children);
80303                 }
80304                 if (onAfterEmitNodeArray) {
80305                     onAfterEmitNodeArray(children);
80306                 }
80307                 return;
80308             }
80309             if (format & 15360) {
80310                 writePunctuation(getOpeningBracket(format));
80311                 if (isEmpty && !isUndefined) {
80312                     emitTrailingCommentsOfPosition(children.pos, true);
80313                 }
80314             }
80315             if (onBeforeEmitNodeArray) {
80316                 onBeforeEmitNodeArray(children);
80317             }
80318             if (isEmpty) {
80319                 if (format & 1 && !(preserveSourceNewlines && ts.rangeIsOnSingleLine(parentNode, currentSourceFile))) {
80320                     writeLine();
80321                 }
80322                 else if (format & 256 && !(format & 524288)) {
80323                     writeSpace();
80324                 }
80325             }
80326             else {
80327                 var mayEmitInterveningComments = (format & 262144) === 0;
80328                 var shouldEmitInterveningComments = mayEmitInterveningComments;
80329                 var leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children, format);
80330                 if (leadingLineTerminatorCount) {
80331                     writeLine(leadingLineTerminatorCount);
80332                     shouldEmitInterveningComments = false;
80333                 }
80334                 else if (format & 256) {
80335                     writeSpace();
80336                 }
80337                 if (format & 128) {
80338                     increaseIndent();
80339                 }
80340                 var previousSibling = void 0;
80341                 var previousSourceFileTextKind = void 0;
80342                 var shouldDecreaseIndentAfterEmit = false;
80343                 for (var i = 0; i < count; i++) {
80344                     var child = children[start + i];
80345                     if (format & 32) {
80346                         writeLine();
80347                         writeDelimiter(format);
80348                     }
80349                     else if (previousSibling) {
80350                         if (format & 60 && previousSibling.end !== parentNode.end) {
80351                             emitLeadingCommentsOfPosition(previousSibling.end);
80352                         }
80353                         writeDelimiter(format);
80354                         recordBundleFileInternalSectionEnd(previousSourceFileTextKind);
80355                         var separatingLineTerminatorCount = getSeparatingLineTerminatorCount(previousSibling, child, format);
80356                         if (separatingLineTerminatorCount > 0) {
80357                             if ((format & (3 | 128)) === 0) {
80358                                 increaseIndent();
80359                                 shouldDecreaseIndentAfterEmit = true;
80360                             }
80361                             writeLine(separatingLineTerminatorCount);
80362                             shouldEmitInterveningComments = false;
80363                         }
80364                         else if (previousSibling && format & 512) {
80365                             writeSpace();
80366                         }
80367                     }
80368                     previousSourceFileTextKind = recordBundleFileInternalSectionStart(child);
80369                     if (shouldEmitInterveningComments) {
80370                         if (emitTrailingCommentsOfPosition) {
80371                             var commentRange = ts.getCommentRange(child);
80372                             emitTrailingCommentsOfPosition(commentRange.pos);
80373                         }
80374                     }
80375                     else {
80376                         shouldEmitInterveningComments = mayEmitInterveningComments;
80377                     }
80378                     emit(child);
80379                     if (shouldDecreaseIndentAfterEmit) {
80380                         decreaseIndent();
80381                         shouldDecreaseIndentAfterEmit = false;
80382                     }
80383                     previousSibling = child;
80384                 }
80385                 var hasTrailingComma = (format & 64) && children.hasTrailingComma;
80386                 if (format & 16 && hasTrailingComma) {
80387                     writePunctuation(",");
80388                 }
80389                 if (previousSibling && format & 60 && previousSibling.end !== parentNode.end && !(ts.getEmitFlags(previousSibling) & 1024)) {
80390                     emitLeadingCommentsOfPosition(previousSibling.end);
80391                 }
80392                 if (format & 128) {
80393                     decreaseIndent();
80394                 }
80395                 recordBundleFileInternalSectionEnd(previousSourceFileTextKind);
80396                 var closingLineTerminatorCount = getClosingLineTerminatorCount(parentNode, children, format);
80397                 if (closingLineTerminatorCount) {
80398                     writeLine(closingLineTerminatorCount);
80399                 }
80400                 else if (format & (2097152 | 256)) {
80401                     writeSpace();
80402                 }
80403             }
80404             if (onAfterEmitNodeArray) {
80405                 onAfterEmitNodeArray(children);
80406             }
80407             if (format & 15360) {
80408                 if (isEmpty && !isUndefined) {
80409                     emitLeadingCommentsOfPosition(children.end);
80410                 }
80411                 writePunctuation(getClosingBracket(format));
80412             }
80413         }
80414         function writeLiteral(s) {
80415             writer.writeLiteral(s);
80416         }
80417         function writeStringLiteral(s) {
80418             writer.writeStringLiteral(s);
80419         }
80420         function writeBase(s) {
80421             writer.write(s);
80422         }
80423         function writeSymbol(s, sym) {
80424             writer.writeSymbol(s, sym);
80425         }
80426         function writePunctuation(s) {
80427             writer.writePunctuation(s);
80428         }
80429         function writeTrailingSemicolon() {
80430             writer.writeTrailingSemicolon(";");
80431         }
80432         function writeKeyword(s) {
80433             writer.writeKeyword(s);
80434         }
80435         function writeOperator(s) {
80436             writer.writeOperator(s);
80437         }
80438         function writeParameter(s) {
80439             writer.writeParameter(s);
80440         }
80441         function writeComment(s) {
80442             writer.writeComment(s);
80443         }
80444         function writeSpace() {
80445             writer.writeSpace(" ");
80446         }
80447         function writeProperty(s) {
80448             writer.writeProperty(s);
80449         }
80450         function writeLine(count) {
80451             if (count === void 0) { count = 1; }
80452             for (var i = 0; i < count; i++) {
80453                 writer.writeLine(i > 0);
80454             }
80455         }
80456         function increaseIndent() {
80457             writer.increaseIndent();
80458         }
80459         function decreaseIndent() {
80460             writer.decreaseIndent();
80461         }
80462         function writeToken(token, pos, writer, contextNode) {
80463             return !sourceMapsDisabled
80464                 ? emitTokenWithSourceMap(contextNode, token, writer, pos, writeTokenText)
80465                 : writeTokenText(token, writer, pos);
80466         }
80467         function writeTokenNode(node, writer) {
80468             if (onBeforeEmitToken) {
80469                 onBeforeEmitToken(node);
80470             }
80471             writer(ts.tokenToString(node.kind));
80472             if (onAfterEmitToken) {
80473                 onAfterEmitToken(node);
80474             }
80475         }
80476         function writeTokenText(token, writer, pos) {
80477             var tokenString = ts.tokenToString(token);
80478             writer(tokenString);
80479             return pos < 0 ? pos : pos + tokenString.length;
80480         }
80481         function writeLineOrSpace(node) {
80482             if (ts.getEmitFlags(node) & 1) {
80483                 writeSpace();
80484             }
80485             else {
80486                 writeLine();
80487             }
80488         }
80489         function writeLines(text) {
80490             var lines = text.split(/\r\n?|\n/g);
80491             var indentation = ts.guessIndentation(lines);
80492             for (var _a = 0, lines_3 = lines; _a < lines_3.length; _a++) {
80493                 var lineText = lines_3[_a];
80494                 var line = indentation ? lineText.slice(indentation) : lineText;
80495                 if (line.length) {
80496                     writeLine();
80497                     write(line);
80498                 }
80499             }
80500         }
80501         function writeLinesAndIndent(lineCount, writeSpaceIfNotIndenting) {
80502             if (lineCount) {
80503                 increaseIndent();
80504                 writeLine(lineCount);
80505             }
80506             else if (writeSpaceIfNotIndenting) {
80507                 writeSpace();
80508             }
80509         }
80510         function decreaseIndentIf(value1, value2) {
80511             if (value1) {
80512                 decreaseIndent();
80513             }
80514             if (value2) {
80515                 decreaseIndent();
80516             }
80517         }
80518         function getLeadingLineTerminatorCount(parentNode, children, format) {
80519             if (format & 2 || preserveSourceNewlines) {
80520                 if (format & 65536) {
80521                     return 1;
80522                 }
80523                 var firstChild_1 = children[0];
80524                 if (firstChild_1 === undefined) {
80525                     return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
80526                 }
80527                 if (firstChild_1.kind === 11) {
80528                     return 0;
80529                 }
80530                 if (!ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(firstChild_1) && (!firstChild_1.parent || firstChild_1.parent === parentNode)) {
80531                     if (preserveSourceNewlines) {
80532                         return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(firstChild_1.pos, parentNode.pos, currentSourceFile, includeComments); });
80533                     }
80534                     return ts.rangeStartPositionsAreOnSameLine(parentNode, firstChild_1, currentSourceFile) ? 0 : 1;
80535                 }
80536                 if (synthesizedNodeStartsOnNewLine(firstChild_1, format)) {
80537                     return 1;
80538                 }
80539             }
80540             return format & 1 ? 1 : 0;
80541         }
80542         function getSeparatingLineTerminatorCount(previousNode, nextNode, format) {
80543             if (format & 2 || preserveSourceNewlines) {
80544                 if (previousNode === undefined || nextNode === undefined) {
80545                     return 0;
80546                 }
80547                 if (nextNode.kind === 11) {
80548                     return 0;
80549                 }
80550                 else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode) && previousNode.parent === nextNode.parent) {
80551                     if (preserveSourceNewlines) {
80552                         return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); });
80553                     }
80554                     return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1;
80555                 }
80556                 else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) {
80557                     return 1;
80558                 }
80559             }
80560             else if (ts.getStartsOnNewLine(nextNode)) {
80561                 return 1;
80562             }
80563             return format & 1 ? 1 : 0;
80564         }
80565         function getClosingLineTerminatorCount(parentNode, children, format) {
80566             if (format & 2 || preserveSourceNewlines) {
80567                 if (format & 65536) {
80568                     return 1;
80569                 }
80570                 var lastChild_1 = ts.lastOrUndefined(children);
80571                 if (lastChild_1 === undefined) {
80572                     return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
80573                 }
80574                 if (!ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild_1) && (!lastChild_1.parent || lastChild_1.parent === parentNode)) {
80575                     if (preserveSourceNewlines) {
80576                         return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(lastChild_1.end, parentNode.end, currentSourceFile, includeComments); });
80577                     }
80578                     return ts.rangeEndPositionsAreOnSameLine(parentNode, lastChild_1, currentSourceFile) ? 0 : 1;
80579                 }
80580                 if (synthesizedNodeStartsOnNewLine(lastChild_1, format)) {
80581                     return 1;
80582                 }
80583             }
80584             if (format & 1 && !(format & 131072)) {
80585                 return 1;
80586             }
80587             return 0;
80588         }
80589         function getEffectiveLines(getLineDifference) {
80590             ts.Debug.assert(!!preserveSourceNewlines);
80591             var lines = getLineDifference(true);
80592             if (lines === 0) {
80593                 return getLineDifference(false);
80594             }
80595             return lines;
80596         }
80597         function writeLineSeparatorsAndIndentBefore(node, parent) {
80598             var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], 0);
80599             if (leadingNewlines) {
80600                 writeLinesAndIndent(leadingNewlines, false);
80601             }
80602             return !!leadingNewlines;
80603         }
80604         function writeLineSeparatorsAfter(node, parent) {
80605             var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], 0);
80606             if (trailingNewlines) {
80607                 writeLine(trailingNewlines);
80608             }
80609         }
80610         function synthesizedNodeStartsOnNewLine(node, format) {
80611             if (ts.nodeIsSynthesized(node)) {
80612                 var startsOnNewLine = ts.getStartsOnNewLine(node);
80613                 if (startsOnNewLine === undefined) {
80614                     return (format & 65536) !== 0;
80615                 }
80616                 return startsOnNewLine;
80617             }
80618             return (format & 65536) !== 0;
80619         }
80620         function getLinesBetweenNodes(parent, node1, node2) {
80621             if (ts.getEmitFlags(parent) & 131072) {
80622                 return 0;
80623             }
80624             parent = skipSynthesizedParentheses(parent);
80625             node1 = skipSynthesizedParentheses(node1);
80626             node2 = skipSynthesizedParentheses(node2);
80627             if (ts.getStartsOnNewLine(node2)) {
80628                 return 1;
80629             }
80630             if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
80631                 if (preserveSourceNewlines) {
80632                     return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); });
80633                 }
80634                 return ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile) ? 0 : 1;
80635             }
80636             return 0;
80637         }
80638         function isEmptyBlock(block) {
80639             return block.statements.length === 0
80640                 && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile);
80641         }
80642         function skipSynthesizedParentheses(node) {
80643             while (node.kind === 200 && ts.nodeIsSynthesized(node)) {
80644                 node = node.expression;
80645             }
80646             return node;
80647         }
80648         function getTextOfNode(node, includeTrivia) {
80649             if (ts.isGeneratedIdentifier(node)) {
80650                 return generateName(node);
80651             }
80652             else if ((ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) {
80653                 return ts.idText(node);
80654             }
80655             else if (node.kind === 10 && node.textSourceNode) {
80656                 return getTextOfNode(node.textSourceNode, includeTrivia);
80657             }
80658             else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) {
80659                 return node.text;
80660             }
80661             return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia);
80662         }
80663         function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) {
80664             if (node.kind === 10 && node.textSourceNode) {
80665                 var textSourceNode = node.textSourceNode;
80666                 if (ts.isIdentifier(textSourceNode)) {
80667                     return jsxAttributeEscape ? "\"" + ts.escapeJsxAttributeString(getTextOfNode(textSourceNode)) + "\"" :
80668                         neverAsciiEscape || (ts.getEmitFlags(node) & 16777216) ? "\"" + ts.escapeString(getTextOfNode(textSourceNode)) + "\"" :
80669                             "\"" + ts.escapeNonAsciiString(getTextOfNode(textSourceNode)) + "\"";
80670                 }
80671                 else {
80672                     return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape);
80673                 }
80674             }
80675             return ts.getLiteralText(node, currentSourceFile, neverAsciiEscape, jsxAttributeEscape);
80676         }
80677         function pushNameGenerationScope(node) {
80678             if (node && ts.getEmitFlags(node) & 524288) {
80679                 return;
80680             }
80681             tempFlagsStack.push(tempFlags);
80682             tempFlags = 0;
80683             reservedNamesStack.push(reservedNames);
80684         }
80685         function popNameGenerationScope(node) {
80686             if (node && ts.getEmitFlags(node) & 524288) {
80687                 return;
80688             }
80689             tempFlags = tempFlagsStack.pop();
80690             reservedNames = reservedNamesStack.pop();
80691         }
80692         function reserveNameInNestedScopes(name) {
80693             if (!reservedNames || reservedNames === ts.lastOrUndefined(reservedNamesStack)) {
80694                 reservedNames = ts.createMap();
80695             }
80696             reservedNames.set(name, true);
80697         }
80698         function generateNames(node) {
80699             if (!node)
80700                 return;
80701             switch (node.kind) {
80702                 case 223:
80703                     ts.forEach(node.statements, generateNames);
80704                     break;
80705                 case 238:
80706                 case 236:
80707                 case 228:
80708                 case 229:
80709                     generateNames(node.statement);
80710                     break;
80711                 case 227:
80712                     generateNames(node.thenStatement);
80713                     generateNames(node.elseStatement);
80714                     break;
80715                 case 230:
80716                 case 232:
80717                 case 231:
80718                     generateNames(node.initializer);
80719                     generateNames(node.statement);
80720                     break;
80721                 case 237:
80722                     generateNames(node.caseBlock);
80723                     break;
80724                 case 251:
80725                     ts.forEach(node.clauses, generateNames);
80726                     break;
80727                 case 277:
80728                 case 278:
80729                     ts.forEach(node.statements, generateNames);
80730                     break;
80731                 case 240:
80732                     generateNames(node.tryBlock);
80733                     generateNames(node.catchClause);
80734                     generateNames(node.finallyBlock);
80735                     break;
80736                 case 280:
80737                     generateNames(node.variableDeclaration);
80738                     generateNames(node.block);
80739                     break;
80740                 case 225:
80741                     generateNames(node.declarationList);
80742                     break;
80743                 case 243:
80744                     ts.forEach(node.declarations, generateNames);
80745                     break;
80746                 case 242:
80747                 case 156:
80748                 case 191:
80749                 case 245:
80750                     generateNameIfNeeded(node.name);
80751                     break;
80752                 case 244:
80753                     generateNameIfNeeded(node.name);
80754                     if (ts.getEmitFlags(node) & 524288) {
80755                         ts.forEach(node.parameters, generateNames);
80756                         generateNames(node.body);
80757                     }
80758                     break;
80759                 case 189:
80760                 case 190:
80761                     ts.forEach(node.elements, generateNames);
80762                     break;
80763                 case 254:
80764                     generateNames(node.importClause);
80765                     break;
80766                 case 255:
80767                     generateNameIfNeeded(node.name);
80768                     generateNames(node.namedBindings);
80769                     break;
80770                 case 256:
80771                     generateNameIfNeeded(node.name);
80772                     break;
80773                 case 262:
80774                     generateNameIfNeeded(node.name);
80775                     break;
80776                 case 257:
80777                     ts.forEach(node.elements, generateNames);
80778                     break;
80779                 case 258:
80780                     generateNameIfNeeded(node.propertyName || node.name);
80781                     break;
80782             }
80783         }
80784         function generateMemberNames(node) {
80785             if (!node)
80786                 return;
80787             switch (node.kind) {
80788                 case 281:
80789                 case 282:
80790                 case 159:
80791                 case 161:
80792                 case 163:
80793                 case 164:
80794                     generateNameIfNeeded(node.name);
80795                     break;
80796             }
80797         }
80798         function generateNameIfNeeded(name) {
80799             if (name) {
80800                 if (ts.isGeneratedIdentifier(name)) {
80801                     generateName(name);
80802                 }
80803                 else if (ts.isBindingPattern(name)) {
80804                     generateNames(name);
80805                 }
80806             }
80807         }
80808         function generateName(name) {
80809             if ((name.autoGenerateFlags & 7) === 4) {
80810                 return generateNameCached(getNodeForGeneratedName(name), name.autoGenerateFlags);
80811             }
80812             else {
80813                 var autoGenerateId = name.autoGenerateId;
80814                 return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = makeName(name));
80815             }
80816         }
80817         function generateNameCached(node, flags) {
80818             var nodeId = ts.getNodeId(node);
80819             return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = generateNameForNode(node, flags));
80820         }
80821         function isUniqueName(name) {
80822             return isFileLevelUniqueName(name)
80823                 && !generatedNames.has(name)
80824                 && !(reservedNames && reservedNames.has(name));
80825         }
80826         function isFileLevelUniqueName(name) {
80827             return currentSourceFile ? ts.isFileLevelUniqueName(currentSourceFile, name, hasGlobalName) : true;
80828         }
80829         function isUniqueLocalName(name, container) {
80830             for (var node = container; ts.isNodeDescendantOf(node, container); node = node.nextContainer) {
80831                 if (node.locals) {
80832                     var local = node.locals.get(ts.escapeLeadingUnderscores(name));
80833                     if (local && local.flags & (111551 | 1048576 | 2097152)) {
80834                         return false;
80835                     }
80836                 }
80837             }
80838             return true;
80839         }
80840         function makeTempVariableName(flags, reservedInNestedScopes) {
80841             if (flags && !(tempFlags & flags)) {
80842                 var name = flags === 268435456 ? "_i" : "_n";
80843                 if (isUniqueName(name)) {
80844                     tempFlags |= flags;
80845                     if (reservedInNestedScopes) {
80846                         reserveNameInNestedScopes(name);
80847                     }
80848                     return name;
80849                 }
80850             }
80851             while (true) {
80852                 var count = tempFlags & 268435455;
80853                 tempFlags++;
80854                 if (count !== 8 && count !== 13) {
80855                     var name = count < 26
80856                         ? "_" + String.fromCharCode(97 + count)
80857                         : "_" + (count - 26);
80858                     if (isUniqueName(name)) {
80859                         if (reservedInNestedScopes) {
80860                             reserveNameInNestedScopes(name);
80861                         }
80862                         return name;
80863                     }
80864                 }
80865             }
80866         }
80867         function makeUniqueName(baseName, checkFn, optimistic, scoped) {
80868             if (checkFn === void 0) { checkFn = isUniqueName; }
80869             if (optimistic) {
80870                 if (checkFn(baseName)) {
80871                     if (scoped) {
80872                         reserveNameInNestedScopes(baseName);
80873                     }
80874                     else {
80875                         generatedNames.set(baseName, true);
80876                     }
80877                     return baseName;
80878                 }
80879             }
80880             if (baseName.charCodeAt(baseName.length - 1) !== 95) {
80881                 baseName += "_";
80882             }
80883             var i = 1;
80884             while (true) {
80885                 var generatedName = baseName + i;
80886                 if (checkFn(generatedName)) {
80887                     if (scoped) {
80888                         reserveNameInNestedScopes(generatedName);
80889                     }
80890                     else {
80891                         generatedNames.set(generatedName, true);
80892                     }
80893                     return generatedName;
80894                 }
80895                 i++;
80896             }
80897         }
80898         function makeFileLevelOptimisticUniqueName(name) {
80899             return makeUniqueName(name, isFileLevelUniqueName, true);
80900         }
80901         function generateNameForModuleOrEnum(node) {
80902             var name = getTextOfNode(node.name);
80903             return isUniqueLocalName(name, node) ? name : makeUniqueName(name);
80904         }
80905         function generateNameForImportOrExportDeclaration(node) {
80906             var expr = ts.getExternalModuleName(node);
80907             var baseName = ts.isStringLiteral(expr) ?
80908                 ts.makeIdentifierFromModuleName(expr.text) : "module";
80909             return makeUniqueName(baseName);
80910         }
80911         function generateNameForExportDefault() {
80912             return makeUniqueName("default");
80913         }
80914         function generateNameForClassExpression() {
80915             return makeUniqueName("class");
80916         }
80917         function generateNameForMethodOrAccessor(node) {
80918             if (ts.isIdentifier(node.name)) {
80919                 return generateNameCached(node.name);
80920             }
80921             return makeTempVariableName(0);
80922         }
80923         function generateNameForNode(node, flags) {
80924             switch (node.kind) {
80925                 case 75:
80926                     return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16), !!(flags & 8));
80927                 case 249:
80928                 case 248:
80929                     return generateNameForModuleOrEnum(node);
80930                 case 254:
80931                 case 260:
80932                     return generateNameForImportOrExportDeclaration(node);
80933                 case 244:
80934                 case 245:
80935                 case 259:
80936                     return generateNameForExportDefault();
80937                 case 214:
80938                     return generateNameForClassExpression();
80939                 case 161:
80940                 case 163:
80941                 case 164:
80942                     return generateNameForMethodOrAccessor(node);
80943                 case 154:
80944                     return makeTempVariableName(0, true);
80945                 default:
80946                     return makeTempVariableName(0);
80947             }
80948         }
80949         function makeName(name) {
80950             switch (name.autoGenerateFlags & 7) {
80951                 case 1:
80952                     return makeTempVariableName(0, !!(name.autoGenerateFlags & 8));
80953                 case 2:
80954                     return makeTempVariableName(268435456, !!(name.autoGenerateFlags & 8));
80955                 case 3:
80956                     return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16), !!(name.autoGenerateFlags & 8));
80957             }
80958             return ts.Debug.fail("Unsupported GeneratedIdentifierKind.");
80959         }
80960         function getNodeForGeneratedName(name) {
80961             var autoGenerateId = name.autoGenerateId;
80962             var node = name;
80963             var original = node.original;
80964             while (original) {
80965                 node = original;
80966                 if (ts.isIdentifier(node)
80967                     && !!(node.autoGenerateFlags & 4)
80968                     && node.autoGenerateId !== autoGenerateId) {
80969                     break;
80970                 }
80971                 original = node.original;
80972             }
80973             return node;
80974         }
80975         function pipelineEmitWithComments(hint, node) {
80976             ts.Debug.assert(lastNode === node || lastSubstitution === node);
80977             enterComment();
80978             hasWrittenComment = false;
80979             var emitFlags = ts.getEmitFlags(node);
80980             var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end;
80981             var isEmittedNode = node.kind !== 325;
80982             var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0 || node.kind === 11;
80983             var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0 || node.kind === 11;
80984             var savedContainerPos = containerPos;
80985             var savedContainerEnd = containerEnd;
80986             var savedDeclarationListContainerEnd = declarationListContainerEnd;
80987             if ((pos > 0 || end > 0) && pos !== end) {
80988                 if (!skipLeadingComments) {
80989                     emitLeadingComments(pos, isEmittedNode);
80990                 }
80991                 if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512) !== 0)) {
80992                     containerPos = pos;
80993                 }
80994                 if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024) !== 0)) {
80995                     containerEnd = end;
80996                     if (node.kind === 243) {
80997                         declarationListContainerEnd = end;
80998                     }
80999                 }
81000             }
81001             ts.forEach(ts.getSyntheticLeadingComments(node), emitLeadingSynthesizedComment);
81002             exitComment();
81003             var pipelinePhase = getNextPipelinePhase(2, hint, node);
81004             if (emitFlags & 2048) {
81005                 commentsDisabled = true;
81006                 pipelinePhase(hint, node);
81007                 commentsDisabled = false;
81008             }
81009             else {
81010                 pipelinePhase(hint, node);
81011             }
81012             enterComment();
81013             ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment);
81014             if ((pos > 0 || end > 0) && pos !== end) {
81015                 containerPos = savedContainerPos;
81016                 containerEnd = savedContainerEnd;
81017                 declarationListContainerEnd = savedDeclarationListContainerEnd;
81018                 if (!skipTrailingComments && isEmittedNode) {
81019                     emitTrailingComments(end);
81020                 }
81021             }
81022             exitComment();
81023             ts.Debug.assert(lastNode === node || lastSubstitution === node);
81024         }
81025         function emitLeadingSynthesizedComment(comment) {
81026             if (comment.kind === 2) {
81027                 writer.writeLine();
81028             }
81029             writeSynthesizedComment(comment);
81030             if (comment.hasTrailingNewLine || comment.kind === 2) {
81031                 writer.writeLine();
81032             }
81033             else {
81034                 writer.writeSpace(" ");
81035             }
81036         }
81037         function emitTrailingSynthesizedComment(comment) {
81038             if (!writer.isAtStartOfLine()) {
81039                 writer.writeSpace(" ");
81040             }
81041             writeSynthesizedComment(comment);
81042             if (comment.hasTrailingNewLine) {
81043                 writer.writeLine();
81044             }
81045         }
81046         function writeSynthesizedComment(comment) {
81047             var text = formatSynthesizedComment(comment);
81048             var lineMap = comment.kind === 3 ? ts.computeLineStarts(text) : undefined;
81049             ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine);
81050         }
81051         function formatSynthesizedComment(comment) {
81052             return comment.kind === 3
81053                 ? "/*" + comment.text + "*/"
81054                 : "//" + comment.text;
81055         }
81056         function emitBodyWithDetachedComments(node, detachedRange, emitCallback) {
81057             enterComment();
81058             var pos = detachedRange.pos, end = detachedRange.end;
81059             var emitFlags = ts.getEmitFlags(node);
81060             var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0;
81061             var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024) !== 0;
81062             if (!skipLeadingComments) {
81063                 emitDetachedCommentsAndUpdateCommentsInfo(detachedRange);
81064             }
81065             exitComment();
81066             if (emitFlags & 2048 && !commentsDisabled) {
81067                 commentsDisabled = true;
81068                 emitCallback(node);
81069                 commentsDisabled = false;
81070             }
81071             else {
81072                 emitCallback(node);
81073             }
81074             enterComment();
81075             if (!skipTrailingComments) {
81076                 emitLeadingComments(detachedRange.end, true);
81077                 if (hasWrittenComment && !writer.isAtStartOfLine()) {
81078                     writer.writeLine();
81079                 }
81080             }
81081             exitComment();
81082         }
81083         function emitLeadingComments(pos, isEmittedNode) {
81084             hasWrittenComment = false;
81085             if (isEmittedNode) {
81086                 forEachLeadingCommentToEmit(pos, emitLeadingComment);
81087             }
81088             else if (pos === 0) {
81089                 forEachLeadingCommentToEmit(pos, emitTripleSlashLeadingComment);
81090             }
81091         }
81092         function emitTripleSlashLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
81093             if (isTripleSlashComment(commentPos, commentEnd)) {
81094                 emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos);
81095             }
81096         }
81097         function shouldWriteComment(text, pos) {
81098             if (printerOptions.onlyPrintJsDocStyle) {
81099                 return (ts.isJSDocLikeText(text, pos) || ts.isPinnedComment(text, pos));
81100             }
81101             return true;
81102         }
81103         function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
81104             if (!shouldWriteComment(currentSourceFile.text, commentPos))
81105                 return;
81106             if (!hasWrittenComment) {
81107                 ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos);
81108                 hasWrittenComment = true;
81109             }
81110             emitPos(commentPos);
81111             ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
81112             emitPos(commentEnd);
81113             if (hasTrailingNewLine) {
81114                 writer.writeLine();
81115             }
81116             else if (kind === 3) {
81117                 writer.writeSpace(" ");
81118             }
81119         }
81120         function emitLeadingCommentsOfPosition(pos) {
81121             if (commentsDisabled || pos === -1) {
81122                 return;
81123             }
81124             emitLeadingComments(pos, true);
81125         }
81126         function emitTrailingComments(pos) {
81127             forEachTrailingCommentToEmit(pos, emitTrailingComment);
81128         }
81129         function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) {
81130             if (!shouldWriteComment(currentSourceFile.text, commentPos))
81131                 return;
81132             if (!writer.isAtStartOfLine()) {
81133                 writer.writeSpace(" ");
81134             }
81135             emitPos(commentPos);
81136             ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
81137             emitPos(commentEnd);
81138             if (hasTrailingNewLine) {
81139                 writer.writeLine();
81140             }
81141         }
81142         function emitTrailingCommentsOfPosition(pos, prefixSpace) {
81143             if (commentsDisabled) {
81144                 return;
81145             }
81146             enterComment();
81147             forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition);
81148             exitComment();
81149         }
81150         function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) {
81151             emitPos(commentPos);
81152             ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
81153             emitPos(commentEnd);
81154             if (hasTrailingNewLine) {
81155                 writer.writeLine();
81156             }
81157             else {
81158                 writer.writeSpace(" ");
81159             }
81160         }
81161         function forEachLeadingCommentToEmit(pos, cb) {
81162             if (currentSourceFile && (containerPos === -1 || pos !== containerPos)) {
81163                 if (hasDetachedComments(pos)) {
81164                     forEachLeadingCommentWithoutDetachedComments(cb);
81165                 }
81166                 else {
81167                     ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, pos);
81168                 }
81169             }
81170         }
81171         function forEachTrailingCommentToEmit(end, cb) {
81172             if (currentSourceFile && (containerEnd === -1 || (end !== containerEnd && end !== declarationListContainerEnd))) {
81173                 ts.forEachTrailingCommentRange(currentSourceFile.text, end, cb);
81174             }
81175         }
81176         function hasDetachedComments(pos) {
81177             return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos;
81178         }
81179         function forEachLeadingCommentWithoutDetachedComments(cb) {
81180             var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos;
81181             if (detachedCommentsInfo.length - 1) {
81182                 detachedCommentsInfo.pop();
81183             }
81184             else {
81185                 detachedCommentsInfo = undefined;
81186             }
81187             ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, pos);
81188         }
81189         function emitDetachedCommentsAndUpdateCommentsInfo(range) {
81190             var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled);
81191             if (currentDetachedCommentInfo) {
81192                 if (detachedCommentsInfo) {
81193                     detachedCommentsInfo.push(currentDetachedCommentInfo);
81194                 }
81195                 else {
81196                     detachedCommentsInfo = [currentDetachedCommentInfo];
81197                 }
81198             }
81199         }
81200         function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) {
81201             if (!shouldWriteComment(currentSourceFile.text, commentPos))
81202                 return;
81203             emitPos(commentPos);
81204             ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine);
81205             emitPos(commentEnd);
81206         }
81207         function isTripleSlashComment(commentPos, commentEnd) {
81208             return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
81209         }
81210         function getParsedSourceMap(node) {
81211             if (node.parsedSourceMap === undefined && node.sourceMapText !== undefined) {
81212                 node.parsedSourceMap = ts.tryParseRawSourceMap(node.sourceMapText) || false;
81213             }
81214             return node.parsedSourceMap || undefined;
81215         }
81216         function pipelineEmitWithSourceMap(hint, node) {
81217             ts.Debug.assert(lastNode === node || lastSubstitution === node);
81218             var pipelinePhase = getNextPipelinePhase(3, hint, node);
81219             if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) {
81220                 pipelinePhase(hint, node);
81221             }
81222             else if (ts.isUnparsedNode(node)) {
81223                 var parsed = getParsedSourceMap(node.parent);
81224                 if (parsed && sourceMapGenerator) {
81225                     sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.parent.sourceMapPath, node.parent.getLineAndCharacterOfPosition(node.pos), node.parent.getLineAndCharacterOfPosition(node.end));
81226                 }
81227                 pipelinePhase(hint, node);
81228             }
81229             else {
81230                 var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b;
81231                 var emitFlags = ts.getEmitFlags(node);
81232                 if (node.kind !== 325
81233                     && (emitFlags & 16) === 0
81234                     && pos >= 0) {
81235                     emitSourcePos(source, skipSourceTrivia(source, pos));
81236                 }
81237                 if (emitFlags & 64) {
81238                     sourceMapsDisabled = true;
81239                     pipelinePhase(hint, node);
81240                     sourceMapsDisabled = false;
81241                 }
81242                 else {
81243                     pipelinePhase(hint, node);
81244                 }
81245                 if (node.kind !== 325
81246                     && (emitFlags & 32) === 0
81247                     && end >= 0) {
81248                     emitSourcePos(source, end);
81249                 }
81250             }
81251             ts.Debug.assert(lastNode === node || lastSubstitution === node);
81252         }
81253         function skipSourceTrivia(source, pos) {
81254             return source.skipTrivia ? source.skipTrivia(pos) : ts.skipTrivia(source.text, pos);
81255         }
81256         function emitPos(pos) {
81257             if (sourceMapsDisabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(sourceMapSource)) {
81258                 return;
81259             }
81260             var _a = ts.getLineAndCharacterOfPosition(sourceMapSource, pos), sourceLine = _a.line, sourceCharacter = _a.character;
81261             sourceMapGenerator.addMapping(writer.getLine(), writer.getColumn(), sourceMapSourceIndex, sourceLine, sourceCharacter, undefined);
81262         }
81263         function emitSourcePos(source, pos) {
81264             if (source !== sourceMapSource) {
81265                 var savedSourceMapSource = sourceMapSource;
81266                 setSourceMapSource(source);
81267                 emitPos(pos);
81268                 setSourceMapSource(savedSourceMapSource);
81269             }
81270             else {
81271                 emitPos(pos);
81272             }
81273         }
81274         function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) {
81275             if (sourceMapsDisabled || node && ts.isInJsonFile(node)) {
81276                 return emitCallback(token, writer, tokenPos);
81277             }
81278             var emitNode = node && node.emitNode;
81279             var emitFlags = emitNode && emitNode.flags || 0;
81280             var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token];
81281             var source = range && range.source || sourceMapSource;
81282             tokenPos = skipSourceTrivia(source, range ? range.pos : tokenPos);
81283             if ((emitFlags & 128) === 0 && tokenPos >= 0) {
81284                 emitSourcePos(source, tokenPos);
81285             }
81286             tokenPos = emitCallback(token, writer, tokenPos);
81287             if (range)
81288                 tokenPos = range.end;
81289             if ((emitFlags & 256) === 0 && tokenPos >= 0) {
81290                 emitSourcePos(source, tokenPos);
81291             }
81292             return tokenPos;
81293         }
81294         function setSourceMapSource(source) {
81295             if (sourceMapsDisabled) {
81296                 return;
81297             }
81298             sourceMapSource = source;
81299             if (isJsonSourceMapSource(source)) {
81300                 return;
81301             }
81302             sourceMapSourceIndex = sourceMapGenerator.addSource(source.fileName);
81303             if (printerOptions.inlineSources) {
81304                 sourceMapGenerator.setSourceContent(sourceMapSourceIndex, source.text);
81305             }
81306         }
81307         function isJsonSourceMapSource(sourceFile) {
81308             return ts.fileExtensionIs(sourceFile.fileName, ".json");
81309         }
81310     }
81311     ts.createPrinter = createPrinter;
81312     function createBracketsMap() {
81313         var brackets = [];
81314         brackets[1024] = ["{", "}"];
81315         brackets[2048] = ["(", ")"];
81316         brackets[4096] = ["<", ">"];
81317         brackets[8192] = ["[", "]"];
81318         return brackets;
81319     }
81320     function getOpeningBracket(format) {
81321         return brackets[format & 15360][0];
81322     }
81323     function getClosingBracket(format) {
81324         return brackets[format & 15360][1];
81325     }
81326 })(ts || (ts = {}));
81327 var ts;
81328 (function (ts) {
81329     function createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames) {
81330         if (!host.getDirectories || !host.readDirectory) {
81331             return undefined;
81332         }
81333         var cachedReadDirectoryResult = ts.createMap();
81334         var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
81335         return {
81336             useCaseSensitiveFileNames: useCaseSensitiveFileNames,
81337             fileExists: fileExists,
81338             readFile: function (path, encoding) { return host.readFile(path, encoding); },
81339             directoryExists: host.directoryExists && directoryExists,
81340             getDirectories: getDirectories,
81341             readDirectory: readDirectory,
81342             createDirectory: host.createDirectory && createDirectory,
81343             writeFile: host.writeFile && writeFile,
81344             addOrDeleteFileOrDirectory: addOrDeleteFileOrDirectory,
81345             addOrDeleteFile: addOrDeleteFile,
81346             clearCache: clearCache,
81347             realpath: host.realpath && realpath
81348         };
81349         function toPath(fileName) {
81350             return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
81351         }
81352         function getCachedFileSystemEntries(rootDirPath) {
81353             return cachedReadDirectoryResult.get(ts.ensureTrailingDirectorySeparator(rootDirPath));
81354         }
81355         function getCachedFileSystemEntriesForBaseDir(path) {
81356             return getCachedFileSystemEntries(ts.getDirectoryPath(path));
81357         }
81358         function getBaseNameOfFileName(fileName) {
81359             return ts.getBaseFileName(ts.normalizePath(fileName));
81360         }
81361         function createCachedFileSystemEntries(rootDir, rootDirPath) {
81362             var resultFromHost = {
81363                 files: ts.map(host.readDirectory(rootDir, undefined, undefined, ["*.*"]), getBaseNameOfFileName) || [],
81364                 directories: host.getDirectories(rootDir) || []
81365             };
81366             cachedReadDirectoryResult.set(ts.ensureTrailingDirectorySeparator(rootDirPath), resultFromHost);
81367             return resultFromHost;
81368         }
81369         function tryReadDirectory(rootDir, rootDirPath) {
81370             rootDirPath = ts.ensureTrailingDirectorySeparator(rootDirPath);
81371             var cachedResult = getCachedFileSystemEntries(rootDirPath);
81372             if (cachedResult) {
81373                 return cachedResult;
81374             }
81375             try {
81376                 return createCachedFileSystemEntries(rootDir, rootDirPath);
81377             }
81378             catch (_e) {
81379                 ts.Debug.assert(!cachedReadDirectoryResult.has(ts.ensureTrailingDirectorySeparator(rootDirPath)));
81380                 return undefined;
81381             }
81382         }
81383         function fileNameEqual(name1, name2) {
81384             return getCanonicalFileName(name1) === getCanonicalFileName(name2);
81385         }
81386         function hasEntry(entries, name) {
81387             return ts.some(entries, function (file) { return fileNameEqual(file, name); });
81388         }
81389         function updateFileSystemEntry(entries, baseName, isValid) {
81390             if (hasEntry(entries, baseName)) {
81391                 if (!isValid) {
81392                     return ts.filterMutate(entries, function (entry) { return !fileNameEqual(entry, baseName); });
81393                 }
81394             }
81395             else if (isValid) {
81396                 return entries.push(baseName);
81397             }
81398         }
81399         function writeFile(fileName, data, writeByteOrderMark) {
81400             var path = toPath(fileName);
81401             var result = getCachedFileSystemEntriesForBaseDir(path);
81402             if (result) {
81403                 updateFilesOfFileSystemEntry(result, getBaseNameOfFileName(fileName), true);
81404             }
81405             return host.writeFile(fileName, data, writeByteOrderMark);
81406         }
81407         function fileExists(fileName) {
81408             var path = toPath(fileName);
81409             var result = getCachedFileSystemEntriesForBaseDir(path);
81410             return result && hasEntry(result.files, getBaseNameOfFileName(fileName)) ||
81411                 host.fileExists(fileName);
81412         }
81413         function directoryExists(dirPath) {
81414             var path = toPath(dirPath);
81415             return cachedReadDirectoryResult.has(ts.ensureTrailingDirectorySeparator(path)) || host.directoryExists(dirPath);
81416         }
81417         function createDirectory(dirPath) {
81418             var path = toPath(dirPath);
81419             var result = getCachedFileSystemEntriesForBaseDir(path);
81420             var baseFileName = getBaseNameOfFileName(dirPath);
81421             if (result) {
81422                 updateFileSystemEntry(result.directories, baseFileName, true);
81423             }
81424             host.createDirectory(dirPath);
81425         }
81426         function getDirectories(rootDir) {
81427             var rootDirPath = toPath(rootDir);
81428             var result = tryReadDirectory(rootDir, rootDirPath);
81429             if (result) {
81430                 return result.directories.slice();
81431             }
81432             return host.getDirectories(rootDir);
81433         }
81434         function readDirectory(rootDir, extensions, excludes, includes, depth) {
81435             var rootDirPath = toPath(rootDir);
81436             var result = tryReadDirectory(rootDir, rootDirPath);
81437             if (result) {
81438                 return ts.matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath);
81439             }
81440             return host.readDirectory(rootDir, extensions, excludes, includes, depth);
81441             function getFileSystemEntries(dir) {
81442                 var path = toPath(dir);
81443                 if (path === rootDirPath) {
81444                     return result;
81445                 }
81446                 return tryReadDirectory(dir, path) || ts.emptyFileSystemEntries;
81447             }
81448         }
81449         function realpath(s) {
81450             return host.realpath ? host.realpath(s) : s;
81451         }
81452         function addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath) {
81453             var existingResult = getCachedFileSystemEntries(fileOrDirectoryPath);
81454             if (existingResult) {
81455                 clearCache();
81456                 return undefined;
81457             }
81458             var parentResult = getCachedFileSystemEntriesForBaseDir(fileOrDirectoryPath);
81459             if (!parentResult) {
81460                 return undefined;
81461             }
81462             if (!host.directoryExists) {
81463                 clearCache();
81464                 return undefined;
81465             }
81466             var baseName = getBaseNameOfFileName(fileOrDirectory);
81467             var fsQueryResult = {
81468                 fileExists: host.fileExists(fileOrDirectoryPath),
81469                 directoryExists: host.directoryExists(fileOrDirectoryPath)
81470             };
81471             if (fsQueryResult.directoryExists || hasEntry(parentResult.directories, baseName)) {
81472                 clearCache();
81473             }
81474             else {
81475                 updateFilesOfFileSystemEntry(parentResult, baseName, fsQueryResult.fileExists);
81476             }
81477             return fsQueryResult;
81478         }
81479         function addOrDeleteFile(fileName, filePath, eventKind) {
81480             if (eventKind === ts.FileWatcherEventKind.Changed) {
81481                 return;
81482             }
81483             var parentResult = getCachedFileSystemEntriesForBaseDir(filePath);
81484             if (parentResult) {
81485                 updateFilesOfFileSystemEntry(parentResult, getBaseNameOfFileName(fileName), eventKind === ts.FileWatcherEventKind.Created);
81486             }
81487         }
81488         function updateFilesOfFileSystemEntry(parentResult, baseName, fileExists) {
81489             updateFileSystemEntry(parentResult.files, baseName, fileExists);
81490         }
81491         function clearCache() {
81492             cachedReadDirectoryResult.clear();
81493         }
81494     }
81495     ts.createCachedDirectoryStructureHost = createCachedDirectoryStructureHost;
81496     var ConfigFileProgramReloadLevel;
81497     (function (ConfigFileProgramReloadLevel) {
81498         ConfigFileProgramReloadLevel[ConfigFileProgramReloadLevel["None"] = 0] = "None";
81499         ConfigFileProgramReloadLevel[ConfigFileProgramReloadLevel["Partial"] = 1] = "Partial";
81500         ConfigFileProgramReloadLevel[ConfigFileProgramReloadLevel["Full"] = 2] = "Full";
81501     })(ConfigFileProgramReloadLevel = ts.ConfigFileProgramReloadLevel || (ts.ConfigFileProgramReloadLevel = {}));
81502     function updateMissingFilePathsWatch(program, missingFileWatches, createMissingFileWatch) {
81503         var missingFilePaths = program.getMissingFilePaths();
81504         var newMissingFilePathMap = ts.arrayToSet(missingFilePaths);
81505         ts.mutateMap(missingFileWatches, newMissingFilePathMap, {
81506             createNewValue: createMissingFileWatch,
81507             onDeleteValue: ts.closeFileWatcher
81508         });
81509     }
81510     ts.updateMissingFilePathsWatch = updateMissingFilePathsWatch;
81511     function updateWatchingWildcardDirectories(existingWatchedForWildcards, wildcardDirectories, watchDirectory) {
81512         ts.mutateMap(existingWatchedForWildcards, wildcardDirectories, {
81513             createNewValue: createWildcardDirectoryWatcher,
81514             onDeleteValue: closeFileWatcherOf,
81515             onExistingValue: updateWildcardDirectoryWatcher
81516         });
81517         function createWildcardDirectoryWatcher(directory, flags) {
81518             return {
81519                 watcher: watchDirectory(directory, flags),
81520                 flags: flags
81521             };
81522         }
81523         function updateWildcardDirectoryWatcher(existingWatcher, flags, directory) {
81524             if (existingWatcher.flags === flags) {
81525                 return;
81526             }
81527             existingWatcher.watcher.close();
81528             existingWatchedForWildcards.set(directory, createWildcardDirectoryWatcher(directory, flags));
81529         }
81530     }
81531     ts.updateWatchingWildcardDirectories = updateWatchingWildcardDirectories;
81532     function isEmittedFileOfProgram(program, file) {
81533         if (!program) {
81534             return false;
81535         }
81536         return program.isEmittedFile(file);
81537     }
81538     ts.isEmittedFileOfProgram = isEmittedFileOfProgram;
81539     var WatchLogLevel;
81540     (function (WatchLogLevel) {
81541         WatchLogLevel[WatchLogLevel["None"] = 0] = "None";
81542         WatchLogLevel[WatchLogLevel["TriggerOnly"] = 1] = "TriggerOnly";
81543         WatchLogLevel[WatchLogLevel["Verbose"] = 2] = "Verbose";
81544     })(WatchLogLevel = ts.WatchLogLevel || (ts.WatchLogLevel = {}));
81545     function getWatchFactory(watchLogLevel, log, getDetailWatchInfo) {
81546         return getWatchFactoryWith(watchLogLevel, log, getDetailWatchInfo, watchFile, watchDirectory);
81547     }
81548     ts.getWatchFactory = getWatchFactory;
81549     function getWatchFactoryWith(watchLogLevel, log, getDetailWatchInfo, watchFile, watchDirectory) {
81550         var createFileWatcher = getCreateFileWatcher(watchLogLevel, watchFile);
81551         var createFilePathWatcher = watchLogLevel === WatchLogLevel.None ? watchFilePath : createFileWatcher;
81552         var createDirectoryWatcher = getCreateFileWatcher(watchLogLevel, watchDirectory);
81553         if (watchLogLevel === WatchLogLevel.Verbose && ts.sysLog === ts.noop) {
81554             ts.setSysLog(function (s) { return log(s); });
81555         }
81556         return {
81557             watchFile: function (host, file, callback, pollingInterval, options, detailInfo1, detailInfo2) {
81558                 return createFileWatcher(host, file, callback, pollingInterval, options, undefined, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo);
81559             },
81560             watchFilePath: function (host, file, callback, pollingInterval, options, path, detailInfo1, detailInfo2) {
81561                 return createFilePathWatcher(host, file, callback, pollingInterval, options, path, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo);
81562             },
81563             watchDirectory: function (host, directory, callback, flags, options, detailInfo1, detailInfo2) {
81564                 return createDirectoryWatcher(host, directory, callback, flags, options, undefined, detailInfo1, detailInfo2, watchDirectory, log, "DirectoryWatcher", getDetailWatchInfo);
81565             }
81566         };
81567     }
81568     function watchFile(host, file, callback, pollingInterval, options) {
81569         return host.watchFile(file, callback, pollingInterval, options);
81570     }
81571     function watchFilePath(host, file, callback, pollingInterval, options, path) {
81572         return watchFile(host, file, function (fileName, eventKind) { return callback(fileName, eventKind, path); }, pollingInterval, options);
81573     }
81574     function watchDirectory(host, directory, callback, flags, options) {
81575         return host.watchDirectory(directory, callback, (flags & 1) !== 0, options);
81576     }
81577     function getCreateFileWatcher(watchLogLevel, addWatch) {
81578         switch (watchLogLevel) {
81579             case WatchLogLevel.None:
81580                 return addWatch;
81581             case WatchLogLevel.TriggerOnly:
81582                 return createFileWatcherWithTriggerLogging;
81583             case WatchLogLevel.Verbose:
81584                 return addWatch === watchDirectory ? createDirectoryWatcherWithLogging : createFileWatcherWithLogging;
81585         }
81586     }
81587     function createFileWatcherWithLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo) {
81588         log(watchCaption + ":: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo));
81589         var watcher = createFileWatcherWithTriggerLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo);
81590         return {
81591             close: function () {
81592                 log(watchCaption + ":: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo));
81593                 watcher.close();
81594             }
81595         };
81596     }
81597     function createDirectoryWatcherWithLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo) {
81598         var watchInfo = watchCaption + ":: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo);
81599         log(watchInfo);
81600         var start = ts.timestamp();
81601         var watcher = createFileWatcherWithTriggerLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo);
81602         var elapsed = ts.timestamp() - start;
81603         log("Elapsed:: " + elapsed + "ms " + watchInfo);
81604         return {
81605             close: function () {
81606                 var watchInfo = watchCaption + ":: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo);
81607                 log(watchInfo);
81608                 var start = ts.timestamp();
81609                 watcher.close();
81610                 var elapsed = ts.timestamp() - start;
81611                 log("Elapsed:: " + elapsed + "ms " + watchInfo);
81612             }
81613         };
81614     }
81615     function createFileWatcherWithTriggerLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo) {
81616         return addWatch(host, file, function (fileName, cbOptional) {
81617             var triggerredInfo = watchCaption + ":: Triggered with " + fileName + " " + (cbOptional !== undefined ? cbOptional : "") + ":: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo);
81618             log(triggerredInfo);
81619             var start = ts.timestamp();
81620             cb(fileName, cbOptional, passThrough);
81621             var elapsed = ts.timestamp() - start;
81622             log("Elapsed:: " + elapsed + "ms " + triggerredInfo);
81623         }, flags, options);
81624     }
81625     function getFallbackOptions(options) {
81626         var fallbackPolling = options === null || options === void 0 ? void 0 : options.fallbackPolling;
81627         return {
81628             watchFile: fallbackPolling !== undefined ?
81629                 fallbackPolling :
81630                 ts.WatchFileKind.PriorityPollingInterval
81631         };
81632     }
81633     ts.getFallbackOptions = getFallbackOptions;
81634     function getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo) {
81635         return "WatchInfo: " + file + " " + flags + " " + JSON.stringify(options) + " " + (getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : detailInfo1 + " " + detailInfo2);
81636     }
81637     function closeFileWatcherOf(objWithWatcher) {
81638         objWithWatcher.watcher.close();
81639     }
81640     ts.closeFileWatcherOf = closeFileWatcherOf;
81641 })(ts || (ts = {}));
81642 var ts;
81643 (function (ts) {
81644     function findConfigFile(searchPath, fileExists, configName) {
81645         if (configName === void 0) { configName = "tsconfig.json"; }
81646         return ts.forEachAncestorDirectory(searchPath, function (ancestor) {
81647             var fileName = ts.combinePaths(ancestor, configName);
81648             return fileExists(fileName) ? fileName : undefined;
81649         });
81650     }
81651     ts.findConfigFile = findConfigFile;
81652     function resolveTripleslashReference(moduleName, containingFile) {
81653         var basePath = ts.getDirectoryPath(containingFile);
81654         var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName);
81655         return ts.normalizePath(referencedFileName);
81656     }
81657     ts.resolveTripleslashReference = resolveTripleslashReference;
81658     function computeCommonSourceDirectoryOfFilenames(fileNames, currentDirectory, getCanonicalFileName) {
81659         var commonPathComponents;
81660         var failed = ts.forEach(fileNames, function (sourceFile) {
81661             var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile, currentDirectory);
81662             sourcePathComponents.pop();
81663             if (!commonPathComponents) {
81664                 commonPathComponents = sourcePathComponents;
81665                 return;
81666             }
81667             var n = Math.min(commonPathComponents.length, sourcePathComponents.length);
81668             for (var i = 0; i < n; i++) {
81669                 if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) {
81670                     if (i === 0) {
81671                         return true;
81672                     }
81673                     commonPathComponents.length = i;
81674                     break;
81675                 }
81676             }
81677             if (sourcePathComponents.length < commonPathComponents.length) {
81678                 commonPathComponents.length = sourcePathComponents.length;
81679             }
81680         });
81681         if (failed) {
81682             return "";
81683         }
81684         if (!commonPathComponents) {
81685             return currentDirectory;
81686         }
81687         return ts.getPathFromPathComponents(commonPathComponents);
81688     }
81689     ts.computeCommonSourceDirectoryOfFilenames = computeCommonSourceDirectoryOfFilenames;
81690     function createCompilerHost(options, setParentNodes) {
81691         return createCompilerHostWorker(options, setParentNodes);
81692     }
81693     ts.createCompilerHost = createCompilerHost;
81694     function createCompilerHostWorker(options, setParentNodes, system) {
81695         if (system === void 0) { system = ts.sys; }
81696         var existingDirectories = ts.createMap();
81697         var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
81698         function getSourceFile(fileName, languageVersion, onError) {
81699             var text;
81700             try {
81701                 ts.performance.mark("beforeIORead");
81702                 text = compilerHost.readFile(fileName);
81703                 ts.performance.mark("afterIORead");
81704                 ts.performance.measure("I/O Read", "beforeIORead", "afterIORead");
81705             }
81706             catch (e) {
81707                 if (onError) {
81708                     onError(e.message);
81709                 }
81710                 text = "";
81711             }
81712             return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined;
81713         }
81714         function directoryExists(directoryPath) {
81715             if (existingDirectories.has(directoryPath)) {
81716                 return true;
81717             }
81718             if ((compilerHost.directoryExists || system.directoryExists)(directoryPath)) {
81719                 existingDirectories.set(directoryPath, true);
81720                 return true;
81721             }
81722             return false;
81723         }
81724         function writeFile(fileName, data, writeByteOrderMark, onError) {
81725             try {
81726                 ts.performance.mark("beforeIOWrite");
81727                 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); });
81728                 ts.performance.mark("afterIOWrite");
81729                 ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
81730             }
81731             catch (e) {
81732                 if (onError) {
81733                     onError(e.message);
81734                 }
81735             }
81736         }
81737         var outputFingerprints;
81738         function writeFileWorker(fileName, data, writeByteOrderMark) {
81739             if (!ts.isWatchSet(options) || !system.createHash || !system.getModifiedTime) {
81740                 system.writeFile(fileName, data, writeByteOrderMark);
81741                 return;
81742             }
81743             if (!outputFingerprints) {
81744                 outputFingerprints = ts.createMap();
81745             }
81746             var hash = system.createHash(data);
81747             var mtimeBefore = system.getModifiedTime(fileName);
81748             if (mtimeBefore) {
81749                 var fingerprint = outputFingerprints.get(fileName);
81750                 if (fingerprint &&
81751                     fingerprint.byteOrderMark === writeByteOrderMark &&
81752                     fingerprint.hash === hash &&
81753                     fingerprint.mtime.getTime() === mtimeBefore.getTime()) {
81754                     return;
81755                 }
81756             }
81757             system.writeFile(fileName, data, writeByteOrderMark);
81758             var mtimeAfter = system.getModifiedTime(fileName) || ts.missingFileModifiedTime;
81759             outputFingerprints.set(fileName, {
81760                 hash: hash,
81761                 byteOrderMark: writeByteOrderMark,
81762                 mtime: mtimeAfter
81763             });
81764         }
81765         function getDefaultLibLocation() {
81766             return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath()));
81767         }
81768         var newLine = ts.getNewLineCharacter(options, function () { return system.newLine; });
81769         var realpath = system.realpath && (function (path) { return system.realpath(path); });
81770         var compilerHost = {
81771             getSourceFile: getSourceFile,
81772             getDefaultLibLocation: getDefaultLibLocation,
81773             getDefaultLibFileName: function (options) { return ts.combinePaths(getDefaultLibLocation(), ts.getDefaultLibFileName(options)); },
81774             writeFile: writeFile,
81775             getCurrentDirectory: ts.memoize(function () { return system.getCurrentDirectory(); }),
81776             useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; },
81777             getCanonicalFileName: getCanonicalFileName,
81778             getNewLine: function () { return newLine; },
81779             fileExists: function (fileName) { return system.fileExists(fileName); },
81780             readFile: function (fileName) { return system.readFile(fileName); },
81781             trace: function (s) { return system.write(s + newLine); },
81782             directoryExists: function (directoryName) { return system.directoryExists(directoryName); },
81783             getEnvironmentVariable: function (name) { return system.getEnvironmentVariable ? system.getEnvironmentVariable(name) : ""; },
81784             getDirectories: function (path) { return system.getDirectories(path); },
81785             realpath: realpath,
81786             readDirectory: function (path, extensions, include, exclude, depth) { return system.readDirectory(path, extensions, include, exclude, depth); },
81787             createDirectory: function (d) { return system.createDirectory(d); },
81788             createHash: ts.maybeBind(system, system.createHash)
81789         };
81790         return compilerHost;
81791     }
81792     ts.createCompilerHostWorker = createCompilerHostWorker;
81793     function changeCompilerHostLikeToUseCache(host, toPath, getSourceFile) {
81794         var originalReadFile = host.readFile;
81795         var originalFileExists = host.fileExists;
81796         var originalDirectoryExists = host.directoryExists;
81797         var originalCreateDirectory = host.createDirectory;
81798         var originalWriteFile = host.writeFile;
81799         var readFileCache = ts.createMap();
81800         var fileExistsCache = ts.createMap();
81801         var directoryExistsCache = ts.createMap();
81802         var sourceFileCache = ts.createMap();
81803         var readFileWithCache = function (fileName) {
81804             var key = toPath(fileName);
81805             var value = readFileCache.get(key);
81806             if (value !== undefined)
81807                 return value !== false ? value : undefined;
81808             return setReadFileCache(key, fileName);
81809         };
81810         var setReadFileCache = function (key, fileName) {
81811             var newValue = originalReadFile.call(host, fileName);
81812             readFileCache.set(key, newValue !== undefined ? newValue : false);
81813             return newValue;
81814         };
81815         host.readFile = function (fileName) {
81816             var key = toPath(fileName);
81817             var value = readFileCache.get(key);
81818             if (value !== undefined)
81819                 return value !== false ? value : undefined;
81820             if (!ts.fileExtensionIs(fileName, ".json") && !ts.isBuildInfoFile(fileName)) {
81821                 return originalReadFile.call(host, fileName);
81822             }
81823             return setReadFileCache(key, fileName);
81824         };
81825         var getSourceFileWithCache = getSourceFile ? function (fileName, languageVersion, onError, shouldCreateNewSourceFile) {
81826             var key = toPath(fileName);
81827             var value = sourceFileCache.get(key);
81828             if (value)
81829                 return value;
81830             var sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile);
81831             if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json"))) {
81832                 sourceFileCache.set(key, sourceFile);
81833             }
81834             return sourceFile;
81835         } : undefined;
81836         host.fileExists = function (fileName) {
81837             var key = toPath(fileName);
81838             var value = fileExistsCache.get(key);
81839             if (value !== undefined)
81840                 return value;
81841             var newValue = originalFileExists.call(host, fileName);
81842             fileExistsCache.set(key, !!newValue);
81843             return newValue;
81844         };
81845         if (originalWriteFile) {
81846             host.writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) {
81847                 var key = toPath(fileName);
81848                 fileExistsCache.delete(key);
81849                 var value = readFileCache.get(key);
81850                 if (value !== undefined && value !== data) {
81851                     readFileCache.delete(key);
81852                     sourceFileCache.delete(key);
81853                 }
81854                 else if (getSourceFileWithCache) {
81855                     var sourceFile = sourceFileCache.get(key);
81856                     if (sourceFile && sourceFile.text !== data) {
81857                         sourceFileCache.delete(key);
81858                     }
81859                 }
81860                 originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles);
81861             };
81862         }
81863         if (originalDirectoryExists && originalCreateDirectory) {
81864             host.directoryExists = function (directory) {
81865                 var key = toPath(directory);
81866                 var value = directoryExistsCache.get(key);
81867                 if (value !== undefined)
81868                     return value;
81869                 var newValue = originalDirectoryExists.call(host, directory);
81870                 directoryExistsCache.set(key, !!newValue);
81871                 return newValue;
81872             };
81873             host.createDirectory = function (directory) {
81874                 var key = toPath(directory);
81875                 directoryExistsCache.delete(key);
81876                 originalCreateDirectory.call(host, directory);
81877             };
81878         }
81879         return {
81880             originalReadFile: originalReadFile,
81881             originalFileExists: originalFileExists,
81882             originalDirectoryExists: originalDirectoryExists,
81883             originalCreateDirectory: originalCreateDirectory,
81884             originalWriteFile: originalWriteFile,
81885             getSourceFileWithCache: getSourceFileWithCache,
81886             readFileWithCache: readFileWithCache
81887         };
81888     }
81889     ts.changeCompilerHostLikeToUseCache = changeCompilerHostLikeToUseCache;
81890     function getPreEmitDiagnostics(program, sourceFile, cancellationToken) {
81891         var diagnostics;
81892         diagnostics = ts.addRange(diagnostics, program.getConfigFileParsingDiagnostics());
81893         diagnostics = ts.addRange(diagnostics, program.getOptionsDiagnostics(cancellationToken));
81894         diagnostics = ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile, cancellationToken));
81895         diagnostics = ts.addRange(diagnostics, program.getGlobalDiagnostics(cancellationToken));
81896         diagnostics = ts.addRange(diagnostics, program.getSemanticDiagnostics(sourceFile, cancellationToken));
81897         if (ts.getEmitDeclarations(program.getCompilerOptions())) {
81898             diagnostics = ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken));
81899         }
81900         return ts.sortAndDeduplicateDiagnostics(diagnostics || ts.emptyArray);
81901     }
81902     ts.getPreEmitDiagnostics = getPreEmitDiagnostics;
81903     function formatDiagnostics(diagnostics, host) {
81904         var output = "";
81905         for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) {
81906             var diagnostic = diagnostics_2[_i];
81907             output += formatDiagnostic(diagnostic, host);
81908         }
81909         return output;
81910     }
81911     ts.formatDiagnostics = formatDiagnostics;
81912     function formatDiagnostic(diagnostic, host) {
81913         var errorMessage = ts.diagnosticCategoryName(diagnostic) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine();
81914         if (diagnostic.file) {
81915             var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character;
81916             var fileName = diagnostic.file.fileName;
81917             var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); });
81918             return relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): " + errorMessage;
81919         }
81920         return errorMessage;
81921     }
81922     ts.formatDiagnostic = formatDiagnostic;
81923     var ForegroundColorEscapeSequences;
81924     (function (ForegroundColorEscapeSequences) {
81925         ForegroundColorEscapeSequences["Grey"] = "\u001B[90m";
81926         ForegroundColorEscapeSequences["Red"] = "\u001B[91m";
81927         ForegroundColorEscapeSequences["Yellow"] = "\u001B[93m";
81928         ForegroundColorEscapeSequences["Blue"] = "\u001B[94m";
81929         ForegroundColorEscapeSequences["Cyan"] = "\u001B[96m";
81930     })(ForegroundColorEscapeSequences = ts.ForegroundColorEscapeSequences || (ts.ForegroundColorEscapeSequences = {}));
81931     var gutterStyleSequence = "\u001b[7m";
81932     var gutterSeparator = " ";
81933     var resetEscapeSequence = "\u001b[0m";
81934     var ellipsis = "...";
81935     var halfIndent = "  ";
81936     var indent = "    ";
81937     function getCategoryFormat(category) {
81938         switch (category) {
81939             case ts.DiagnosticCategory.Error: return ForegroundColorEscapeSequences.Red;
81940             case ts.DiagnosticCategory.Warning: return ForegroundColorEscapeSequences.Yellow;
81941             case ts.DiagnosticCategory.Suggestion: return ts.Debug.fail("Should never get an Info diagnostic on the command line.");
81942             case ts.DiagnosticCategory.Message: return ForegroundColorEscapeSequences.Blue;
81943         }
81944     }
81945     function formatColorAndReset(text, formatStyle) {
81946         return formatStyle + text + resetEscapeSequence;
81947     }
81948     ts.formatColorAndReset = formatColorAndReset;
81949     function formatCodeSpan(file, start, length, indent, squiggleColor, host) {
81950         var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character;
81951         var _b = ts.getLineAndCharacterOfPosition(file, start + length), lastLine = _b.line, lastLineChar = _b.character;
81952         var lastLineInFile = ts.getLineAndCharacterOfPosition(file, file.text.length).line;
81953         var hasMoreThanFiveLines = (lastLine - firstLine) >= 4;
81954         var gutterWidth = (lastLine + 1 + "").length;
81955         if (hasMoreThanFiveLines) {
81956             gutterWidth = Math.max(ellipsis.length, gutterWidth);
81957         }
81958         var context = "";
81959         for (var i = firstLine; i <= lastLine; i++) {
81960             context += host.getNewLine();
81961             if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) {
81962                 context += indent + formatColorAndReset(ts.padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine();
81963                 i = lastLine - 1;
81964             }
81965             var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0);
81966             var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length;
81967             var lineContent = file.text.slice(lineStart, lineEnd);
81968             lineContent = lineContent.replace(/\s+$/g, "");
81969             lineContent = lineContent.replace("\t", " ");
81970             context += indent + formatColorAndReset(ts.padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator;
81971             context += lineContent + host.getNewLine();
81972             context += indent + formatColorAndReset(ts.padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator;
81973             context += squiggleColor;
81974             if (i === firstLine) {
81975                 var lastCharForLine = i === lastLine ? lastLineChar : undefined;
81976                 context += lineContent.slice(0, firstLineChar).replace(/\S/g, " ");
81977                 context += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~");
81978             }
81979             else if (i === lastLine) {
81980                 context += lineContent.slice(0, lastLineChar).replace(/./g, "~");
81981             }
81982             else {
81983                 context += lineContent.replace(/./g, "~");
81984             }
81985             context += resetEscapeSequence;
81986         }
81987         return context;
81988     }
81989     function formatLocation(file, start, host, color) {
81990         if (color === void 0) { color = formatColorAndReset; }
81991         var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character;
81992         var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName;
81993         var output = "";
81994         output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan);
81995         output += ":";
81996         output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow);
81997         output += ":";
81998         output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow);
81999         return output;
82000     }
82001     ts.formatLocation = formatLocation;
82002     function formatDiagnosticsWithColorAndContext(diagnostics, host) {
82003         var output = "";
82004         for (var _i = 0, diagnostics_3 = diagnostics; _i < diagnostics_3.length; _i++) {
82005             var diagnostic = diagnostics_3[_i];
82006             if (diagnostic.file) {
82007                 var file = diagnostic.file, start = diagnostic.start;
82008                 output += formatLocation(file, start, host);
82009                 output += " - ";
82010             }
82011             output += formatColorAndReset(ts.diagnosticCategoryName(diagnostic), getCategoryFormat(diagnostic.category));
82012             output += formatColorAndReset(" TS" + diagnostic.code + ": ", ForegroundColorEscapeSequences.Grey);
82013             output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine());
82014             if (diagnostic.file) {
82015                 output += host.getNewLine();
82016                 output += formatCodeSpan(diagnostic.file, diagnostic.start, diagnostic.length, "", getCategoryFormat(diagnostic.category), host);
82017                 if (diagnostic.relatedInformation) {
82018                     output += host.getNewLine();
82019                     for (var _a = 0, _b = diagnostic.relatedInformation; _a < _b.length; _a++) {
82020                         var _c = _b[_a], file = _c.file, start = _c.start, length_8 = _c.length, messageText = _c.messageText;
82021                         if (file) {
82022                             output += host.getNewLine();
82023                             output += halfIndent + formatLocation(file, start, host);
82024                             output += formatCodeSpan(file, start, length_8, indent, ForegroundColorEscapeSequences.Cyan, host);
82025                         }
82026                         output += host.getNewLine();
82027                         output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine());
82028                     }
82029                 }
82030             }
82031             output += host.getNewLine();
82032         }
82033         return output;
82034     }
82035     ts.formatDiagnosticsWithColorAndContext = formatDiagnosticsWithColorAndContext;
82036     function flattenDiagnosticMessageText(diag, newLine, indent) {
82037         if (indent === void 0) { indent = 0; }
82038         if (ts.isString(diag)) {
82039             return diag;
82040         }
82041         else if (diag === undefined) {
82042             return "";
82043         }
82044         var result = "";
82045         if (indent) {
82046             result += newLine;
82047             for (var i = 0; i < indent; i++) {
82048                 result += "  ";
82049             }
82050         }
82051         result += diag.messageText;
82052         indent++;
82053         if (diag.next) {
82054             for (var _i = 0, _a = diag.next; _i < _a.length; _i++) {
82055                 var kid = _a[_i];
82056                 result += flattenDiagnosticMessageText(kid, newLine, indent);
82057             }
82058         }
82059         return result;
82060     }
82061     ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText;
82062     function loadWithLocalCache(names, containingFile, redirectedReference, loader) {
82063         if (names.length === 0) {
82064             return [];
82065         }
82066         var resolutions = [];
82067         var cache = ts.createMap();
82068         for (var _i = 0, names_2 = names; _i < names_2.length; _i++) {
82069             var name = names_2[_i];
82070             var result = void 0;
82071             if (cache.has(name)) {
82072                 result = cache.get(name);
82073             }
82074             else {
82075                 cache.set(name, result = loader(name, containingFile, redirectedReference));
82076             }
82077             resolutions.push(result);
82078         }
82079         return resolutions;
82080     }
82081     ts.loadWithLocalCache = loadWithLocalCache;
82082     ts.inferredTypesContainingFile = "__inferred type names__.ts";
82083     function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences) {
82084         if (!program || hasChangedAutomaticTypeDirectiveNames) {
82085             return false;
82086         }
82087         if (!ts.arrayIsEqualTo(program.getRootFileNames(), rootFileNames)) {
82088             return false;
82089         }
82090         var seenResolvedRefs;
82091         if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) {
82092             return false;
82093         }
82094         if (program.getSourceFiles().some(sourceFileNotUptoDate)) {
82095             return false;
82096         }
82097         if (program.getMissingFilePaths().some(fileExists)) {
82098             return false;
82099         }
82100         var currentOptions = program.getCompilerOptions();
82101         if (!ts.compareDataObjects(currentOptions, newOptions)) {
82102             return false;
82103         }
82104         if (currentOptions.configFile && newOptions.configFile) {
82105             return currentOptions.configFile.text === newOptions.configFile.text;
82106         }
82107         return true;
82108         function sourceFileNotUptoDate(sourceFile) {
82109             return !sourceFileVersionUptoDate(sourceFile) ||
82110                 hasInvalidatedResolution(sourceFile.path);
82111         }
82112         function sourceFileVersionUptoDate(sourceFile) {
82113             return sourceFile.version === getSourceVersion(sourceFile.resolvedPath, sourceFile.fileName);
82114         }
82115         function projectReferenceUptoDate(oldRef, newRef, index) {
82116             if (!ts.projectReferenceIsEqualTo(oldRef, newRef)) {
82117                 return false;
82118             }
82119             return resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef);
82120         }
82121         function resolvedProjectReferenceUptoDate(oldResolvedRef, oldRef) {
82122             if (oldResolvedRef) {
82123                 if (ts.contains(seenResolvedRefs, oldResolvedRef)) {
82124                     return true;
82125                 }
82126                 if (!sourceFileVersionUptoDate(oldResolvedRef.sourceFile)) {
82127                     return false;
82128                 }
82129                 (seenResolvedRefs || (seenResolvedRefs = [])).push(oldResolvedRef);
82130                 return !ts.forEach(oldResolvedRef.references, function (childResolvedRef, index) {
82131                     return !resolvedProjectReferenceUptoDate(childResolvedRef, oldResolvedRef.commandLine.projectReferences[index]);
82132                 });
82133             }
82134             return !fileExists(resolveProjectReferencePath(oldRef));
82135         }
82136     }
82137     ts.isProgramUptoDate = isProgramUptoDate;
82138     function getConfigFileParsingDiagnostics(configFileParseResult) {
82139         return configFileParseResult.options.configFile ? __spreadArrays(configFileParseResult.options.configFile.parseDiagnostics, configFileParseResult.errors) :
82140             configFileParseResult.errors;
82141     }
82142     ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics;
82143     function shouldProgramCreateNewSourceFiles(program, newOptions) {
82144         if (!program)
82145             return false;
82146         var oldOptions = program.getCompilerOptions();
82147         return !!ts.sourceFileAffectingCompilerOptions.some(function (option) {
82148             return !ts.isJsonEqual(ts.getCompilerOptionValue(oldOptions, option), ts.getCompilerOptionValue(newOptions, option));
82149         });
82150     }
82151     function createCreateProgramOptions(rootNames, options, host, oldProgram, configFileParsingDiagnostics) {
82152         return {
82153             rootNames: rootNames,
82154             options: options,
82155             host: host,
82156             oldProgram: oldProgram,
82157             configFileParsingDiagnostics: configFileParsingDiagnostics
82158         };
82159     }
82160     function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
82161         var _a;
82162         var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions;
82163         var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences;
82164         var oldProgram = createProgramOptions.oldProgram;
82165         var processingDefaultLibFiles;
82166         var processingOtherFiles;
82167         var files;
82168         var symlinks;
82169         var commonSourceDirectory;
82170         var diagnosticsProducingTypeChecker;
82171         var noDiagnosticsTypeChecker;
82172         var classifiableNames;
82173         var ambientModuleNameToUnmodifiedFileName = ts.createMap();
82174         var refFileMap;
82175         var cachedBindAndCheckDiagnosticsForFile = {};
82176         var cachedDeclarationDiagnosticsForFile = {};
82177         var resolvedTypeReferenceDirectives = ts.createMap();
82178         var fileProcessingDiagnostics = ts.createDiagnosticCollection();
82179         var maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
82180         var currentNodeModulesDepth = 0;
82181         var modulesWithElidedImports = ts.createMap();
82182         var sourceFilesFoundSearchingNodeModules = ts.createMap();
82183         ts.performance.mark("beforeProgram");
82184         var host = createProgramOptions.host || createCompilerHost(options);
82185         var configParsingHost = parseConfigHostFromCompilerHostLike(host);
82186         var skipDefaultLib = options.noLib;
82187         var getDefaultLibraryFileName = ts.memoize(function () { return host.getDefaultLibFileName(options); });
82188         var defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : ts.getDirectoryPath(getDefaultLibraryFileName());
82189         var programDiagnostics = ts.createDiagnosticCollection();
82190         var currentDirectory = host.getCurrentDirectory();
82191         var supportedExtensions = ts.getSupportedExtensions(options);
82192         var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
82193         var hasEmitBlockingDiagnostics = ts.createMap();
82194         var _compilerOptionsObjectLiteralSyntax;
82195         var moduleResolutionCache;
82196         var actualResolveModuleNamesWorker;
82197         var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
82198         if (host.resolveModuleNames) {
82199             actualResolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).map(function (resolved) {
82200                 if (!resolved || resolved.extension !== undefined) {
82201                     return resolved;
82202                 }
82203                 var withExtension = ts.clone(resolved);
82204                 withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName);
82205                 return withExtension;
82206             }); };
82207         }
82208         else {
82209             moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }, options);
82210             var loader_1 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule; };
82211             actualResolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_1); };
82212         }
82213         var actualResolveTypeReferenceDirectiveNamesWorker;
82214         if (host.resolveTypeReferenceDirectives) {
82215             actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); };
82216         }
82217         else {
82218             var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; };
82219             actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_2); };
82220         }
82221         var packageIdToSourceFile = ts.createMap();
82222         var sourceFileToPackageName = ts.createMap();
82223         var redirectTargetsMap = ts.createMultiMap();
82224         var filesByName = ts.createMap();
82225         var missingFilePaths;
82226         var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createMap() : undefined;
82227         var resolvedProjectReferences;
82228         var projectReferenceRedirects;
82229         var mapFromFileToProjectReferenceRedirects;
82230         var mapFromToProjectReferenceRedirectSource;
82231         var useSourceOfProjectReferenceRedirect = !!((_a = host.useSourceOfProjectReferenceRedirect) === null || _a === void 0 ? void 0 : _a.call(host)) &&
82232             !options.disableSourceOfProjectReferenceRedirect;
82233         var _b = updateHostForUseSourceOfProjectReferenceRedirect({
82234             compilerHost: host,
82235             useSourceOfProjectReferenceRedirect: useSourceOfProjectReferenceRedirect,
82236             toPath: toPath,
82237             getResolvedProjectReferences: getResolvedProjectReferences,
82238             getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
82239             forEachResolvedProjectReference: forEachResolvedProjectReference
82240         }), onProgramCreateComplete = _b.onProgramCreateComplete, fileExists = _b.fileExists;
82241         var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
82242         var structuralIsReused;
82243         structuralIsReused = tryReuseStructureFromOldProgram();
82244         if (structuralIsReused !== 2) {
82245             processingDefaultLibFiles = [];
82246             processingOtherFiles = [];
82247             if (projectReferences) {
82248                 if (!resolvedProjectReferences) {
82249                     resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile);
82250                 }
82251                 if (rootNames.length) {
82252                     for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) {
82253                         var parsedRef = resolvedProjectReferences_1[_i];
82254                         if (!parsedRef)
82255                             continue;
82256                         var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out;
82257                         if (useSourceOfProjectReferenceRedirect) {
82258                             if (out || ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) {
82259                                 for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) {
82260                                     var fileName = _d[_c];
82261                                     processSourceFile(fileName, false, false, undefined);
82262                                 }
82263                             }
82264                         }
82265                         else {
82266                             if (out) {
82267                                 processSourceFile(ts.changeExtension(out, ".d.ts"), false, false, undefined);
82268                             }
82269                             else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) {
82270                                 for (var _e = 0, _f = parsedRef.commandLine.fileNames; _e < _f.length; _e++) {
82271                                     var fileName = _f[_e];
82272                                     if (!ts.fileExtensionIs(fileName, ".d.ts") && !ts.fileExtensionIs(fileName, ".json")) {
82273                                         processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), false, false, undefined);
82274                                     }
82275                                 }
82276                             }
82277                         }
82278                     }
82279                 }
82280             }
82281             ts.forEach(rootNames, function (name) { return processRootFile(name, false, false); });
82282             var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray;
82283             if (typeReferences.length) {
82284                 var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
82285                 var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
82286                 var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
82287                 for (var i = 0; i < typeReferences.length; i++) {
82288                     processTypeReferenceDirective(typeReferences[i], resolutions[i]);
82289                 }
82290             }
82291             if (rootNames.length && !skipDefaultLib) {
82292                 var defaultLibraryFileName = getDefaultLibraryFileName();
82293                 if (!options.lib && defaultLibraryFileName) {
82294                     processRootFile(defaultLibraryFileName, true, false);
82295                 }
82296                 else {
82297                     ts.forEach(options.lib, function (libFileName) {
82298                         processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), true, false);
82299                     });
82300                 }
82301             }
82302             missingFilePaths = ts.arrayFrom(ts.mapDefinedIterator(filesByName.entries(), function (_a) {
82303                 var path = _a[0], file = _a[1];
82304                 return file === undefined ? path : undefined;
82305             }));
82306             files = ts.stableSort(processingDefaultLibFiles, compareDefaultLibFiles).concat(processingOtherFiles);
82307             processingDefaultLibFiles = undefined;
82308             processingOtherFiles = undefined;
82309         }
82310         ts.Debug.assert(!!missingFilePaths);
82311         if (oldProgram && host.onReleaseOldSourceFile) {
82312             var oldSourceFiles = oldProgram.getSourceFiles();
82313             for (var _g = 0, oldSourceFiles_1 = oldSourceFiles; _g < oldSourceFiles_1.length; _g++) {
82314                 var oldSourceFile = oldSourceFiles_1[_g];
82315                 var newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
82316                 if (shouldCreateNewSourceFile || !newFile ||
82317                     (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) {
82318                     host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
82319                 }
82320             }
82321             oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference, resolvedProjectReferencePath) {
82322                 if (resolvedProjectReference && !getResolvedProjectReferenceByPath(resolvedProjectReferencePath)) {
82323                     host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), false);
82324                 }
82325             });
82326         }
82327         oldProgram = undefined;
82328         var program = {
82329             getRootFileNames: function () { return rootNames; },
82330             getSourceFile: getSourceFile,
82331             getSourceFileByPath: getSourceFileByPath,
82332             getSourceFiles: function () { return files; },
82333             getMissingFilePaths: function () { return missingFilePaths; },
82334             getRefFileMap: function () { return refFileMap; },
82335             getFilesByNameMap: function () { return filesByName; },
82336             getCompilerOptions: function () { return options; },
82337             getSyntacticDiagnostics: getSyntacticDiagnostics,
82338             getOptionsDiagnostics: getOptionsDiagnostics,
82339             getGlobalDiagnostics: getGlobalDiagnostics,
82340             getSemanticDiagnostics: getSemanticDiagnostics,
82341             getSuggestionDiagnostics: getSuggestionDiagnostics,
82342             getDeclarationDiagnostics: getDeclarationDiagnostics,
82343             getBindAndCheckDiagnostics: getBindAndCheckDiagnostics,
82344             getProgramDiagnostics: getProgramDiagnostics,
82345             getTypeChecker: getTypeChecker,
82346             getClassifiableNames: getClassifiableNames,
82347             getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker,
82348             getCommonSourceDirectory: getCommonSourceDirectory,
82349             emit: emit,
82350             getCurrentDirectory: function () { return currentDirectory; },
82351             getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); },
82352             getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); },
82353             getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); },
82354             getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); },
82355             getInstantiationCount: function () { return getDiagnosticsProducingTypeChecker().getInstantiationCount(); },
82356             getRelationCacheSizes: function () { return getDiagnosticsProducingTypeChecker().getRelationCacheSizes(); },
82357             getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
82358             getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
82359             isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
82360             isSourceFileDefaultLibrary: isSourceFileDefaultLibrary,
82361             dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker,
82362             getSourceFileFromReference: getSourceFileFromReference,
82363             getLibFileFromReference: getLibFileFromReference,
82364             sourceFileToPackageName: sourceFileToPackageName,
82365             redirectTargetsMap: redirectTargetsMap,
82366             isEmittedFile: isEmittedFile,
82367             getConfigFileParsingDiagnostics: getConfigFileParsingDiagnostics,
82368             getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
82369             getProjectReferences: getProjectReferences,
82370             getResolvedProjectReferences: getResolvedProjectReferences,
82371             getProjectReferenceRedirect: getProjectReferenceRedirect,
82372             getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
82373             getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath,
82374             forEachResolvedProjectReference: forEachResolvedProjectReference,
82375             isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
82376             emitBuildInfo: emitBuildInfo,
82377             fileExists: fileExists,
82378             getProbableSymlinks: getProbableSymlinks,
82379             useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
82380         };
82381         onProgramCreateComplete();
82382         verifyCompilerOptions();
82383         ts.performance.mark("afterProgram");
82384         ts.performance.measure("Program", "beforeProgram", "afterProgram");
82385         return program;
82386         function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames, redirectedReference) {
82387             ts.performance.mark("beforeResolveModule");
82388             var result = actualResolveModuleNamesWorker(moduleNames, containingFile, reusedNames, redirectedReference);
82389             ts.performance.mark("afterResolveModule");
82390             ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
82391             return result;
82392         }
82393         function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, redirectedReference) {
82394             ts.performance.mark("beforeResolveTypeReference");
82395             var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, redirectedReference);
82396             ts.performance.mark("afterResolveTypeReference");
82397             ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
82398             return result;
82399         }
82400         function compareDefaultLibFiles(a, b) {
82401             return ts.compareValues(getDefaultLibFilePriority(a), getDefaultLibFilePriority(b));
82402         }
82403         function getDefaultLibFilePriority(a) {
82404             if (ts.containsPath(defaultLibraryPath, a.fileName, false)) {
82405                 var basename = ts.getBaseFileName(a.fileName);
82406                 if (basename === "lib.d.ts" || basename === "lib.es6.d.ts")
82407                     return 0;
82408                 var name = ts.removeSuffix(ts.removePrefix(basename, "lib."), ".d.ts");
82409                 var index = ts.libs.indexOf(name);
82410                 if (index !== -1)
82411                     return index + 1;
82412             }
82413             return ts.libs.length + 2;
82414         }
82415         function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) {
82416             return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache);
82417         }
82418         function toPath(fileName) {
82419             return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
82420         }
82421         function getCommonSourceDirectory() {
82422             if (commonSourceDirectory === undefined) {
82423                 var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, program); });
82424                 if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) {
82425                     commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory);
82426                 }
82427                 else if (options.composite && options.configFilePath) {
82428                     commonSourceDirectory = ts.getDirectoryPath(ts.normalizeSlashes(options.configFilePath));
82429                     checkSourceFilesBelongToPath(emittedFiles, commonSourceDirectory);
82430                 }
82431                 else {
82432                     commonSourceDirectory = computeCommonSourceDirectory(emittedFiles);
82433                 }
82434                 if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) {
82435                     commonSourceDirectory += ts.directorySeparator;
82436                 }
82437             }
82438             return commonSourceDirectory;
82439         }
82440         function getClassifiableNames() {
82441             if (!classifiableNames) {
82442                 getTypeChecker();
82443                 classifiableNames = ts.createUnderscoreEscapedMap();
82444                 for (var _i = 0, files_2 = files; _i < files_2.length; _i++) {
82445                     var sourceFile = files_2[_i];
82446                     ts.copyEntries(sourceFile.classifiableNames, classifiableNames);
82447                 }
82448             }
82449             return classifiableNames;
82450         }
82451         function resolveModuleNamesReusingOldState(moduleNames, containingFile, file) {
82452             if (structuralIsReused === 0 && !file.ambientModuleNames.length) {
82453                 return resolveModuleNamesWorker(moduleNames, containingFile, undefined, getResolvedProjectReferenceToRedirect(file.originalFileName));
82454             }
82455             var oldSourceFile = oldProgram && oldProgram.getSourceFile(containingFile);
82456             if (oldSourceFile !== file && file.resolvedModules) {
82457                 var result_11 = [];
82458                 for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
82459                     var moduleName = moduleNames_1[_i];
82460                     var resolvedModule = file.resolvedModules.get(moduleName);
82461                     result_11.push(resolvedModule);
82462                 }
82463                 return result_11;
82464             }
82465             var unknownModuleNames;
82466             var result;
82467             var reusedNames;
82468             var predictedToResolveToAmbientModuleMarker = {};
82469             for (var i = 0; i < moduleNames.length; i++) {
82470                 var moduleName = moduleNames[i];
82471                 if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
82472                     var oldResolvedModule = oldSourceFile && oldSourceFile.resolvedModules.get(moduleName);
82473                     if (oldResolvedModule) {
82474                         if (ts.isTraceEnabled(options, host)) {
82475                             ts.trace(host, ts.Diagnostics.Reusing_resolution_of_module_0_to_file_1_from_old_program, moduleName, containingFile);
82476                         }
82477                         (result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule;
82478                         (reusedNames || (reusedNames = [])).push(moduleName);
82479                         continue;
82480                     }
82481                 }
82482                 var resolvesToAmbientModuleInNonModifiedFile = false;
82483                 if (ts.contains(file.ambientModuleNames, moduleName)) {
82484                     resolvesToAmbientModuleInNonModifiedFile = true;
82485                     if (ts.isTraceEnabled(options, host)) {
82486                         ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1, moduleName, containingFile);
82487                     }
82488                 }
82489                 else {
82490                     resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName);
82491                 }
82492                 if (resolvesToAmbientModuleInNonModifiedFile) {
82493                     (result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
82494                 }
82495                 else {
82496                     (unknownModuleNames || (unknownModuleNames = [])).push(moduleName);
82497                 }
82498             }
82499             var resolutions = unknownModuleNames && unknownModuleNames.length
82500                 ? resolveModuleNamesWorker(unknownModuleNames, containingFile, reusedNames, getResolvedProjectReferenceToRedirect(file.originalFileName))
82501                 : ts.emptyArray;
82502             if (!result) {
82503                 ts.Debug.assert(resolutions.length === moduleNames.length);
82504                 return resolutions;
82505             }
82506             var j = 0;
82507             for (var i = 0; i < result.length; i++) {
82508                 if (result[i]) {
82509                     if (result[i] === predictedToResolveToAmbientModuleMarker) {
82510                         result[i] = undefined;
82511                     }
82512                 }
82513                 else {
82514                     result[i] = resolutions[j];
82515                     j++;
82516                 }
82517             }
82518             ts.Debug.assert(j === resolutions.length);
82519             return result;
82520             function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName) {
82521                 var resolutionToFile = ts.getResolvedModule(oldSourceFile, moduleName);
82522                 var resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName);
82523                 if (resolutionToFile && resolvedFile) {
82524                     return false;
82525                 }
82526                 var unmodifiedFile = ambientModuleNameToUnmodifiedFileName.get(moduleName);
82527                 if (!unmodifiedFile) {
82528                     return false;
82529                 }
82530                 if (ts.isTraceEnabled(options, host)) {
82531                     ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, unmodifiedFile);
82532                 }
82533                 return true;
82534             }
82535         }
82536         function canReuseProjectReferences() {
82537             return !forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, index, parent) {
82538                 var newRef = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
82539                 var newResolvedRef = parseProjectReferenceConfigFile(newRef);
82540                 if (oldResolvedRef) {
82541                     return !newResolvedRef || newResolvedRef.sourceFile !== oldResolvedRef.sourceFile;
82542                 }
82543                 else {
82544                     return newResolvedRef !== undefined;
82545                 }
82546             }, function (oldProjectReferences, parent) {
82547                 var newReferences = parent ? getResolvedProjectReferenceByPath(parent.sourceFile.path).commandLine.projectReferences : projectReferences;
82548                 return !ts.arrayIsEqualTo(oldProjectReferences, newReferences, ts.projectReferenceIsEqualTo);
82549             });
82550         }
82551         function tryReuseStructureFromOldProgram() {
82552             if (!oldProgram) {
82553                 return 0;
82554             }
82555             var oldOptions = oldProgram.getCompilerOptions();
82556             if (ts.changesAffectModuleResolution(oldOptions, options)) {
82557                 return oldProgram.structureIsReused = 0;
82558             }
82559             ts.Debug.assert(!(oldProgram.structureIsReused & (2 | 1)));
82560             var oldRootNames = oldProgram.getRootFileNames();
82561             if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) {
82562                 return oldProgram.structureIsReused = 0;
82563             }
82564             if (!ts.arrayIsEqualTo(options.types, oldOptions.types)) {
82565                 return oldProgram.structureIsReused = 0;
82566             }
82567             if (!canReuseProjectReferences()) {
82568                 return oldProgram.structureIsReused = 0;
82569             }
82570             if (projectReferences) {
82571                 resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile);
82572             }
82573             var newSourceFiles = [];
82574             var modifiedSourceFiles = [];
82575             oldProgram.structureIsReused = 2;
82576             if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) {
82577                 return oldProgram.structureIsReused = 0;
82578             }
82579             var oldSourceFiles = oldProgram.getSourceFiles();
82580             var seenPackageNames = ts.createMap();
82581             for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
82582                 var oldSourceFile = oldSourceFiles_2[_i];
82583                 var newSourceFile = host.getSourceFileByPath
82584                     ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, options.target, undefined, shouldCreateNewSourceFile)
82585                     : host.getSourceFile(oldSourceFile.fileName, options.target, undefined, shouldCreateNewSourceFile);
82586                 if (!newSourceFile) {
82587                     return oldProgram.structureIsReused = 0;
82588                 }
82589                 ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`");
82590                 var fileChanged = void 0;
82591                 if (oldSourceFile.redirectInfo) {
82592                     if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) {
82593                         return oldProgram.structureIsReused = 0;
82594                     }
82595                     fileChanged = false;
82596                     newSourceFile = oldSourceFile;
82597                 }
82598                 else if (oldProgram.redirectTargetsMap.has(oldSourceFile.path)) {
82599                     if (newSourceFile !== oldSourceFile) {
82600                         return oldProgram.structureIsReused = 0;
82601                     }
82602                     fileChanged = false;
82603                 }
82604                 else {
82605                     fileChanged = newSourceFile !== oldSourceFile;
82606                 }
82607                 newSourceFile.path = oldSourceFile.path;
82608                 newSourceFile.originalFileName = oldSourceFile.originalFileName;
82609                 newSourceFile.resolvedPath = oldSourceFile.resolvedPath;
82610                 newSourceFile.fileName = oldSourceFile.fileName;
82611                 var packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path);
82612                 if (packageName !== undefined) {
82613                     var prevKind = seenPackageNames.get(packageName);
82614                     var newKind = fileChanged ? 1 : 0;
82615                     if ((prevKind !== undefined && newKind === 1) || prevKind === 1) {
82616                         return oldProgram.structureIsReused = 0;
82617                     }
82618                     seenPackageNames.set(packageName, newKind);
82619                 }
82620                 if (fileChanged) {
82621                     if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
82622                         return oldProgram.structureIsReused = 0;
82623                     }
82624                     if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
82625                         oldProgram.structureIsReused = 1;
82626                     }
82627                     if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
82628                         oldProgram.structureIsReused = 1;
82629                     }
82630                     collectExternalModuleReferences(newSourceFile);
82631                     if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
82632                         oldProgram.structureIsReused = 1;
82633                     }
82634                     if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
82635                         oldProgram.structureIsReused = 1;
82636                     }
82637                     if ((oldSourceFile.flags & 3145728) !== (newSourceFile.flags & 3145728)) {
82638                         oldProgram.structureIsReused = 1;
82639                     }
82640                     if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
82641                         oldProgram.structureIsReused = 1;
82642                     }
82643                     modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
82644                 }
82645                 else if (hasInvalidatedResolution(oldSourceFile.path)) {
82646                     oldProgram.structureIsReused = 1;
82647                     modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
82648                 }
82649                 newSourceFiles.push(newSourceFile);
82650             }
82651             if (oldProgram.structureIsReused !== 2) {
82652                 return oldProgram.structureIsReused;
82653             }
82654             var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
82655             for (var _a = 0, oldSourceFiles_3 = oldSourceFiles; _a < oldSourceFiles_3.length; _a++) {
82656                 var oldFile = oldSourceFiles_3[_a];
82657                 if (!ts.contains(modifiedFiles, oldFile)) {
82658                     for (var _b = 0, _c = oldFile.ambientModuleNames; _b < _c.length; _b++) {
82659                         var moduleName = _c[_b];
82660                         ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
82661                     }
82662                 }
82663             }
82664             for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) {
82665                 var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile;
82666                 var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.originalFileName, currentDirectory);
82667                 var moduleNames = getModuleNames(newSourceFile);
82668                 var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile);
82669                 var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo);
82670                 if (resolutionsChanged) {
82671                     oldProgram.structureIsReused = 1;
82672                     newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions);
82673                 }
82674                 else {
82675                     newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
82676                 }
82677                 if (resolveTypeReferenceDirectiveNamesWorker) {
82678                     var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
82679                     var resolutions_1 = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName));
82680                     var resolutionsChanged_1 = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions_1, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo);
82681                     if (resolutionsChanged_1) {
82682                         oldProgram.structureIsReused = 1;
82683                         newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions_1);
82684                     }
82685                     else {
82686                         newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
82687                     }
82688                 }
82689             }
82690             if (oldProgram.structureIsReused !== 2) {
82691                 return oldProgram.structureIsReused;
82692             }
82693             if (host.hasChangedAutomaticTypeDirectiveNames) {
82694                 return oldProgram.structureIsReused = 1;
82695             }
82696             missingFilePaths = oldProgram.getMissingFilePaths();
82697             refFileMap = oldProgram.getRefFileMap();
82698             ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
82699             for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) {
82700                 var newSourceFile = newSourceFiles_1[_f];
82701                 filesByName.set(newSourceFile.path, newSourceFile);
82702             }
82703             var oldFilesByNameMap = oldProgram.getFilesByNameMap();
82704             oldFilesByNameMap.forEach(function (oldFile, path) {
82705                 if (!oldFile) {
82706                     filesByName.set(path, oldFile);
82707                     return;
82708                 }
82709                 if (oldFile.path === path) {
82710                     if (oldProgram.isSourceFileFromExternalLibrary(oldFile)) {
82711                         sourceFilesFoundSearchingNodeModules.set(oldFile.path, true);
82712                     }
82713                     return;
82714                 }
82715                 filesByName.set(path, filesByName.get(oldFile.path));
82716             });
82717             files = newSourceFiles;
82718             fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
82719             for (var _g = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _g < modifiedSourceFiles_2.length; _g++) {
82720                 var modifiedFile = modifiedSourceFiles_2[_g];
82721                 fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile);
82722             }
82723             resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
82724             sourceFileToPackageName = oldProgram.sourceFileToPackageName;
82725             redirectTargetsMap = oldProgram.redirectTargetsMap;
82726             return oldProgram.structureIsReused = 2;
82727         }
82728         function getEmitHost(writeFileCallback) {
82729             return {
82730                 getPrependNodes: getPrependNodes,
82731                 getCanonicalFileName: getCanonicalFileName,
82732                 getCommonSourceDirectory: program.getCommonSourceDirectory,
82733                 getCompilerOptions: program.getCompilerOptions,
82734                 getCurrentDirectory: function () { return currentDirectory; },
82735                 getNewLine: function () { return host.getNewLine(); },
82736                 getSourceFile: program.getSourceFile,
82737                 getSourceFileByPath: program.getSourceFileByPath,
82738                 getSourceFiles: program.getSourceFiles,
82739                 getLibFileFromReference: program.getLibFileFromReference,
82740                 isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
82741                 getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
82742                 getProjectReferenceRedirect: getProjectReferenceRedirect,
82743                 isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
82744                 getProbableSymlinks: getProbableSymlinks,
82745                 writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }),
82746                 isEmitBlocked: isEmitBlocked,
82747                 readFile: function (f) { return host.readFile(f); },
82748                 fileExists: function (f) {
82749                     var path = toPath(f);
82750                     if (getSourceFileByPath(path))
82751                         return true;
82752                     if (ts.contains(missingFilePaths, path))
82753                         return false;
82754                     return host.fileExists(f);
82755                 },
82756                 useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
82757                 getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); },
82758                 getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); },
82759                 redirectTargetsMap: redirectTargetsMap,
82760             };
82761         }
82762         function emitBuildInfo(writeFileCallback) {
82763             ts.Debug.assert(!options.out && !options.outFile);
82764             ts.performance.mark("beforeEmit");
82765             var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), undefined, ts.noTransformers, false, true);
82766             ts.performance.mark("afterEmit");
82767             ts.performance.measure("Emit", "beforeEmit", "afterEmit");
82768             return emitResult;
82769         }
82770         function getResolvedProjectReferences() {
82771             return resolvedProjectReferences;
82772         }
82773         function getProjectReferences() {
82774             return projectReferences;
82775         }
82776         function getPrependNodes() {
82777             return createPrependNodes(projectReferences, function (_ref, index) { return resolvedProjectReferences[index].commandLine; }, function (fileName) {
82778                 var path = toPath(fileName);
82779                 var sourceFile = getSourceFileByPath(path);
82780                 return sourceFile ? sourceFile.text : filesByName.has(path) ? undefined : host.readFile(path);
82781             });
82782         }
82783         function isSourceFileFromExternalLibrary(file) {
82784             return !!sourceFilesFoundSearchingNodeModules.get(file.path);
82785         }
82786         function isSourceFileDefaultLibrary(file) {
82787             if (file.hasNoDefaultLib) {
82788                 return true;
82789             }
82790             if (!options.noLib) {
82791                 return false;
82792             }
82793             var equalityComparer = host.useCaseSensitiveFileNames() ? ts.equateStringsCaseSensitive : ts.equateStringsCaseInsensitive;
82794             if (!options.lib) {
82795                 return equalityComparer(file.fileName, getDefaultLibraryFileName());
82796             }
82797             else {
82798                 return ts.some(options.lib, function (libFileName) { return equalityComparer(file.fileName, ts.combinePaths(defaultLibraryPath, libFileName)); });
82799             }
82800         }
82801         function getDiagnosticsProducingTypeChecker() {
82802             return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true));
82803         }
82804         function dropDiagnosticsProducingTypeChecker() {
82805             diagnosticsProducingTypeChecker = undefined;
82806         }
82807         function getTypeChecker() {
82808             return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false));
82809         }
82810         function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) {
82811             return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); });
82812         }
82813         function isEmitBlocked(emitFileName) {
82814             return hasEmitBlockingDiagnostics.has(toPath(emitFileName));
82815         }
82816         function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) {
82817             if (!forceDtsEmit) {
82818                 var result = handleNoEmitOptions(program, sourceFile, cancellationToken);
82819                 if (result)
82820                     return result;
82821             }
82822             var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken);
82823             ts.performance.mark("beforeEmit");
82824             var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, false, forceDtsEmit);
82825             ts.performance.mark("afterEmit");
82826             ts.performance.measure("Emit", "beforeEmit", "afterEmit");
82827             return emitResult;
82828         }
82829         function getSourceFile(fileName) {
82830             return getSourceFileByPath(toPath(fileName));
82831         }
82832         function getSourceFileByPath(path) {
82833             return filesByName.get(path) || undefined;
82834         }
82835         function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) {
82836             if (sourceFile) {
82837                 return getDiagnostics(sourceFile, cancellationToken);
82838             }
82839             return ts.sortAndDeduplicateDiagnostics(ts.flatMap(program.getSourceFiles(), function (sourceFile) {
82840                 if (cancellationToken) {
82841                     cancellationToken.throwIfCancellationRequested();
82842                 }
82843                 return getDiagnostics(sourceFile, cancellationToken);
82844             }));
82845         }
82846         function getSyntacticDiagnostics(sourceFile, cancellationToken) {
82847             return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken);
82848         }
82849         function getSemanticDiagnostics(sourceFile, cancellationToken) {
82850             return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken);
82851         }
82852         function getBindAndCheckDiagnostics(sourceFile, cancellationToken) {
82853             return getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken);
82854         }
82855         function getProgramDiagnostics(sourceFile) {
82856             if (ts.skipTypeChecking(sourceFile, options, program)) {
82857                 return ts.emptyArray;
82858             }
82859             var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName);
82860             var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
82861             return getMergedProgramDiagnostics(sourceFile, fileProcessingDiagnosticsInFile, programDiagnosticsInFile);
82862         }
82863         function getMergedProgramDiagnostics(sourceFile) {
82864             var _a;
82865             var allDiagnostics = [];
82866             for (var _i = 1; _i < arguments.length; _i++) {
82867                 allDiagnostics[_i - 1] = arguments[_i];
82868             }
82869             var flatDiagnostics = ts.flatten(allDiagnostics);
82870             if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) {
82871                 return flatDiagnostics;
82872             }
82873             return getDiagnosticsWithPrecedingDirectives(sourceFile, sourceFile.commentDirectives, flatDiagnostics).diagnostics;
82874         }
82875         function getDeclarationDiagnostics(sourceFile, cancellationToken) {
82876             var options = program.getCompilerOptions();
82877             if (!sourceFile || options.out || options.outFile) {
82878                 return getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
82879             }
82880             else {
82881                 return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken);
82882             }
82883         }
82884         function getSyntacticDiagnosticsForFile(sourceFile) {
82885             if (ts.isSourceFileJS(sourceFile)) {
82886                 if (!sourceFile.additionalSyntacticDiagnostics) {
82887                     sourceFile.additionalSyntacticDiagnostics = getJSSyntacticDiagnosticsForFile(sourceFile);
82888                 }
82889                 return ts.concatenate(sourceFile.additionalSyntacticDiagnostics, sourceFile.parseDiagnostics);
82890             }
82891             return sourceFile.parseDiagnostics;
82892         }
82893         function runWithCancellationToken(func) {
82894             try {
82895                 return func();
82896             }
82897             catch (e) {
82898                 if (e instanceof ts.OperationCanceledException) {
82899                     noDiagnosticsTypeChecker = undefined;
82900                     diagnosticsProducingTypeChecker = undefined;
82901                 }
82902                 throw e;
82903             }
82904         }
82905         function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) {
82906             return ts.concatenate(getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken), getProgramDiagnostics(sourceFile));
82907         }
82908         function getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken) {
82909             return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedBindAndCheckDiagnosticsForFile, getBindAndCheckDiagnosticsForFileNoCache);
82910         }
82911         function getBindAndCheckDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
82912             return runWithCancellationToken(function () {
82913                 if (ts.skipTypeChecking(sourceFile, options, program)) {
82914                     return ts.emptyArray;
82915                 }
82916                 var typeChecker = getDiagnosticsProducingTypeChecker();
82917                 ts.Debug.assert(!!sourceFile.bindDiagnostics);
82918                 var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options);
82919                 var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
82920                 var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 || sourceFile.scriptKind === 4 ||
82921                     sourceFile.scriptKind === 5 || isCheckJs || sourceFile.scriptKind === 7);
82922                 var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray;
82923                 var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray;
82924                 return getMergedBindAndCheckDiagnostics(sourceFile, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined);
82925             });
82926         }
82927         function getMergedBindAndCheckDiagnostics(sourceFile) {
82928             var _a;
82929             var allDiagnostics = [];
82930             for (var _i = 1; _i < arguments.length; _i++) {
82931                 allDiagnostics[_i - 1] = arguments[_i];
82932             }
82933             var flatDiagnostics = ts.flatten(allDiagnostics);
82934             if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) {
82935                 return flatDiagnostics;
82936             }
82937             var _b = getDiagnosticsWithPrecedingDirectives(sourceFile, sourceFile.commentDirectives, flatDiagnostics), diagnostics = _b.diagnostics, directives = _b.directives;
82938             for (var _c = 0, _d = directives.getUnusedExpectations(); _c < _d.length; _c++) {
82939                 var errorExpectation = _d[_c];
82940                 diagnostics.push(ts.createDiagnosticForRange(sourceFile, errorExpectation.range, ts.Diagnostics.Unused_ts_expect_error_directive));
82941             }
82942             return diagnostics;
82943         }
82944         function getDiagnosticsWithPrecedingDirectives(sourceFile, commentDirectives, flatDiagnostics) {
82945             var directives = ts.createCommentDirectivesMap(sourceFile, commentDirectives);
82946             var diagnostics = flatDiagnostics.filter(function (diagnostic) { return markPrecedingCommentDirectiveLine(diagnostic, directives) === -1; });
82947             return { diagnostics: diagnostics, directives: directives };
82948         }
82949         function getSuggestionDiagnostics(sourceFile, cancellationToken) {
82950             return runWithCancellationToken(function () {
82951                 return getDiagnosticsProducingTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken);
82952             });
82953         }
82954         function markPrecedingCommentDirectiveLine(diagnostic, directives) {
82955             var file = diagnostic.file, start = diagnostic.start;
82956             if (!file) {
82957                 return -1;
82958             }
82959             var lineStarts = ts.getLineStarts(file);
82960             var line = ts.computeLineAndCharacterOfPosition(lineStarts, start).line - 1;
82961             while (line >= 0) {
82962                 if (directives.markUsed(line)) {
82963                     return line;
82964                 }
82965                 var lineText = file.text.slice(lineStarts[line], lineStarts[line + 1]).trim();
82966                 if (lineText !== "" && !/^(\s*)\/\/(.*)$/.test(lineText)) {
82967                     return -1;
82968                 }
82969                 line--;
82970             }
82971             return -1;
82972         }
82973         function getJSSyntacticDiagnosticsForFile(sourceFile) {
82974             return runWithCancellationToken(function () {
82975                 var diagnostics = [];
82976                 walk(sourceFile, sourceFile);
82977                 ts.forEachChildRecursively(sourceFile, walk, walkArray);
82978                 return diagnostics;
82979                 function walk(node, parent) {
82980                     switch (parent.kind) {
82981                         case 156:
82982                         case 159:
82983                         case 161:
82984                             if (parent.questionToken === node) {
82985                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?"));
82986                                 return "skip";
82987                             }
82988                         case 160:
82989                         case 162:
82990                         case 163:
82991                         case 164:
82992                         case 201:
82993                         case 244:
82994                         case 202:
82995                         case 242:
82996                             if (parent.type === node) {
82997                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files));
82998                                 return "skip";
82999                             }
83000                     }
83001                     switch (node.kind) {
83002                         case 255:
83003                             if (node.isTypeOnly) {
83004                                 diagnostics.push(createDiagnosticForNode(node.parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type"));
83005                                 return "skip";
83006                             }
83007                             break;
83008                         case 260:
83009                             if (node.isTypeOnly) {
83010                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "export type"));
83011                                 return "skip";
83012                             }
83013                             break;
83014                         case 253:
83015                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files));
83016                             return "skip";
83017                         case 259:
83018                             if (node.isExportEquals) {
83019                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files));
83020                                 return "skip";
83021                             }
83022                             break;
83023                         case 279:
83024                             var heritageClause = node;
83025                             if (heritageClause.token === 113) {
83026                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files));
83027                                 return "skip";
83028                             }
83029                             break;
83030                         case 246:
83031                             var interfaceKeyword = ts.tokenToString(114);
83032                             ts.Debug.assertIsDefined(interfaceKeyword);
83033                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword));
83034                             return "skip";
83035                         case 249:
83036                             var moduleKeyword = node.flags & 16 ? ts.tokenToString(136) : ts.tokenToString(135);
83037                             ts.Debug.assertIsDefined(moduleKeyword);
83038                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword));
83039                             return "skip";
83040                         case 247:
83041                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files));
83042                             return "skip";
83043                         case 248:
83044                             var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(88));
83045                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword));
83046                             return "skip";
83047                         case 218:
83048                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files));
83049                             return "skip";
83050                         case 217:
83051                             diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files));
83052                             return "skip";
83053                         case 199:
83054                             ts.Debug.fail();
83055                     }
83056                 }
83057                 function walkArray(nodes, parent) {
83058                     if (parent.decorators === nodes && !options.experimentalDecorators) {
83059                         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));
83060                     }
83061                     switch (parent.kind) {
83062                         case 245:
83063                         case 214:
83064                         case 161:
83065                         case 162:
83066                         case 163:
83067                         case 164:
83068                         case 201:
83069                         case 244:
83070                         case 202:
83071                             if (nodes === parent.typeParameters) {
83072                                 diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files));
83073                                 return "skip";
83074                             }
83075                         case 225:
83076                             if (nodes === parent.modifiers) {
83077                                 checkModifiers(parent.modifiers, parent.kind === 225);
83078                                 return "skip";
83079                             }
83080                             break;
83081                         case 159:
83082                             if (nodes === parent.modifiers) {
83083                                 for (var _i = 0, _a = nodes; _i < _a.length; _i++) {
83084                                     var modifier = _a[_i];
83085                                     if (modifier.kind !== 120) {
83086                                         diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind)));
83087                                     }
83088                                 }
83089                                 return "skip";
83090                             }
83091                             break;
83092                         case 156:
83093                             if (nodes === parent.modifiers) {
83094                                 diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files));
83095                                 return "skip";
83096                             }
83097                             break;
83098                         case 196:
83099                         case 197:
83100                         case 216:
83101                         case 267:
83102                         case 268:
83103                         case 198:
83104                             if (nodes === parent.typeArguments) {
83105                                 diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files));
83106                                 return "skip";
83107                             }
83108                             break;
83109                     }
83110                 }
83111                 function checkModifiers(modifiers, isConstValid) {
83112                     for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) {
83113                         var modifier = modifiers_1[_i];
83114                         switch (modifier.kind) {
83115                             case 81:
83116                                 if (isConstValid) {
83117                                     continue;
83118                                 }
83119                             case 119:
83120                             case 117:
83121                             case 118:
83122                             case 138:
83123                             case 130:
83124                             case 122:
83125                                 diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind)));
83126                                 break;
83127                             case 120:
83128                             case 89:
83129                             case 84:
83130                         }
83131                     }
83132                 }
83133                 function createDiagnosticForNodeArray(nodes, message, arg0, arg1, arg2) {
83134                     var start = nodes.pos;
83135                     return ts.createFileDiagnostic(sourceFile, start, nodes.end - start, message, arg0, arg1, arg2);
83136                 }
83137                 function createDiagnosticForNode(node, message, arg0, arg1, arg2) {
83138                     return ts.createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2);
83139                 }
83140             });
83141         }
83142         function getDeclarationDiagnosticsWorker(sourceFile, cancellationToken) {
83143             return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedDeclarationDiagnosticsForFile, getDeclarationDiagnosticsForFileNoCache);
83144         }
83145         function getDeclarationDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
83146             return runWithCancellationToken(function () {
83147                 var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken);
83148                 return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile) || ts.emptyArray;
83149             });
83150         }
83151         function getAndCacheDiagnostics(sourceFile, cancellationToken, cache, getDiagnostics) {
83152             var cachedResult = sourceFile
83153                 ? cache.perFile && cache.perFile.get(sourceFile.path)
83154                 : cache.allDiagnostics;
83155             if (cachedResult) {
83156                 return cachedResult;
83157             }
83158             var result = getDiagnostics(sourceFile, cancellationToken);
83159             if (sourceFile) {
83160                 if (!cache.perFile) {
83161                     cache.perFile = ts.createMap();
83162                 }
83163                 cache.perFile.set(sourceFile.path, result);
83164             }
83165             else {
83166                 cache.allDiagnostics = result;
83167             }
83168             return result;
83169         }
83170         function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) {
83171             return sourceFile.isDeclarationFile ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
83172         }
83173         function getOptionsDiagnostics() {
83174             return ts.sortAndDeduplicateDiagnostics(ts.concatenate(fileProcessingDiagnostics.getGlobalDiagnostics(), ts.concatenate(programDiagnostics.getGlobalDiagnostics(), getOptionsDiagnosticsOfConfigFile())));
83175         }
83176         function getOptionsDiagnosticsOfConfigFile() {
83177             if (!options.configFile) {
83178                 return ts.emptyArray;
83179             }
83180             var diagnostics = programDiagnostics.getDiagnostics(options.configFile.fileName);
83181             forEachResolvedProjectReference(function (resolvedRef) {
83182                 if (resolvedRef) {
83183                     diagnostics = ts.concatenate(diagnostics, programDiagnostics.getDiagnostics(resolvedRef.sourceFile.fileName));
83184                 }
83185             });
83186             return diagnostics;
83187         }
83188         function getGlobalDiagnostics() {
83189             return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray;
83190         }
83191         function getConfigFileParsingDiagnostics() {
83192             return configFileParsingDiagnostics || ts.emptyArray;
83193         }
83194         function processRootFile(fileName, isDefaultLib, ignoreNoDefaultLib) {
83195             processSourceFile(ts.normalizePath(fileName), isDefaultLib, ignoreNoDefaultLib, undefined);
83196         }
83197         function fileReferenceIsEqualTo(a, b) {
83198             return a.fileName === b.fileName;
83199         }
83200         function moduleNameIsEqualTo(a, b) {
83201             return a.kind === 75
83202                 ? b.kind === 75 && a.escapedText === b.escapedText
83203                 : b.kind === 10 && a.text === b.text;
83204         }
83205         function collectExternalModuleReferences(file) {
83206             if (file.imports) {
83207                 return;
83208             }
83209             var isJavaScriptFile = ts.isSourceFileJS(file);
83210             var isExternalModuleFile = ts.isExternalModule(file);
83211             var imports;
83212             var moduleAugmentations;
83213             var ambientModules;
83214             if (options.importHelpers
83215                 && (options.isolatedModules || isExternalModuleFile)
83216                 && !file.isDeclarationFile) {
83217                 var externalHelpersModuleReference = ts.createLiteral(ts.externalHelpersModuleNameText);
83218                 var importDecl = ts.createImportDeclaration(undefined, undefined, undefined, externalHelpersModuleReference);
83219                 ts.addEmitFlags(importDecl, 67108864);
83220                 externalHelpersModuleReference.parent = importDecl;
83221                 importDecl.parent = file;
83222                 imports = [externalHelpersModuleReference];
83223             }
83224             for (var _i = 0, _a = file.statements; _i < _a.length; _i++) {
83225                 var node = _a[_i];
83226                 collectModuleReferences(node, false);
83227             }
83228             if ((file.flags & 1048576) || isJavaScriptFile) {
83229                 collectDynamicImportOrRequireCalls(file);
83230             }
83231             file.imports = imports || ts.emptyArray;
83232             file.moduleAugmentations = moduleAugmentations || ts.emptyArray;
83233             file.ambientModuleNames = ambientModules || ts.emptyArray;
83234             return;
83235             function collectModuleReferences(node, inAmbientModule) {
83236                 if (ts.isAnyImportOrReExport(node)) {
83237                     var moduleNameExpr = ts.getExternalModuleName(node);
83238                     if (moduleNameExpr && ts.isStringLiteral(moduleNameExpr) && moduleNameExpr.text && (!inAmbientModule || !ts.isExternalModuleNameRelative(moduleNameExpr.text))) {
83239                         imports = ts.append(imports, moduleNameExpr);
83240                     }
83241                 }
83242                 else if (ts.isModuleDeclaration(node)) {
83243                     if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || file.isDeclarationFile)) {
83244                         var nameText = ts.getTextOfIdentifierOrLiteral(node.name);
83245                         if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(nameText))) {
83246                             (moduleAugmentations || (moduleAugmentations = [])).push(node.name);
83247                         }
83248                         else if (!inAmbientModule) {
83249                             if (file.isDeclarationFile) {
83250                                 (ambientModules || (ambientModules = [])).push(nameText);
83251                             }
83252                             var body = node.body;
83253                             if (body) {
83254                                 for (var _i = 0, _a = body.statements; _i < _a.length; _i++) {
83255                                     var statement = _a[_i];
83256                                     collectModuleReferences(statement, true);
83257                                 }
83258                             }
83259                         }
83260                     }
83261                 }
83262             }
83263             function collectDynamicImportOrRequireCalls(file) {
83264                 var r = /import|require/g;
83265                 while (r.exec(file.text) !== null) {
83266                     var node = getNodeAtPosition(file, r.lastIndex);
83267                     if (ts.isRequireCall(node, true)) {
83268                         imports = ts.append(imports, node.arguments[0]);
83269                     }
83270                     else if (ts.isImportCall(node) && node.arguments.length === 1 && ts.isStringLiteralLike(node.arguments[0])) {
83271                         imports = ts.append(imports, node.arguments[0]);
83272                     }
83273                     else if (ts.isLiteralImportTypeNode(node)) {
83274                         imports = ts.append(imports, node.argument.literal);
83275                     }
83276                 }
83277             }
83278             function getNodeAtPosition(sourceFile, position) {
83279                 var current = sourceFile;
83280                 var getContainingChild = function (child) {
83281                     if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1)))) {
83282                         return child;
83283                     }
83284                 };
83285                 while (true) {
83286                     var child = isJavaScriptFile && ts.hasJSDocNodes(current) && ts.forEach(current.jsDoc, getContainingChild) || ts.forEachChild(current, getContainingChild);
83287                     if (!child) {
83288                         return current;
83289                     }
83290                     current = child;
83291                 }
83292             }
83293         }
83294         function getLibFileFromReference(ref) {
83295             var libName = ts.toFileNameLowerCase(ref.fileName);
83296             var libFileName = ts.libMap.get(libName);
83297             if (libFileName) {
83298                 return getSourceFile(ts.combinePaths(defaultLibraryPath, libFileName));
83299             }
83300         }
83301         function getSourceFileFromReference(referencingFile, ref) {
83302             return getSourceFileFromReferenceWorker(resolveTripleslashReference(ref.fileName, referencingFile.fileName), function (fileName) { return filesByName.get(toPath(fileName)) || undefined; });
83303         }
83304         function getSourceFileFromReferenceWorker(fileName, getSourceFile, fail, refFile) {
83305             if (ts.hasExtension(fileName)) {
83306                 var canonicalFileName_1 = host.getCanonicalFileName(fileName);
83307                 if (!options.allowNonTsExtensions && !ts.forEach(supportedExtensionsWithJsonIfResolveJsonModule, function (extension) { return ts.fileExtensionIs(canonicalFileName_1, extension); })) {
83308                     if (fail) {
83309                         if (ts.hasJSFileExtension(canonicalFileName_1)) {
83310                             fail(ts.Diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option, fileName);
83311                         }
83312                         else {
83313                             fail(ts.Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + supportedExtensions.join("', '") + "'");
83314                         }
83315                     }
83316                     return undefined;
83317                 }
83318                 var sourceFile = getSourceFile(fileName);
83319                 if (fail) {
83320                     if (!sourceFile) {
83321                         var redirect = getProjectReferenceRedirect(fileName);
83322                         if (redirect) {
83323                             fail(ts.Diagnostics.Output_file_0_has_not_been_built_from_source_file_1, redirect, fileName);
83324                         }
83325                         else {
83326                             fail(ts.Diagnostics.File_0_not_found, fileName);
83327                         }
83328                     }
83329                     else if (refFile && canonicalFileName_1 === host.getCanonicalFileName(refFile.fileName)) {
83330                         fail(ts.Diagnostics.A_file_cannot_have_a_reference_to_itself);
83331                     }
83332                 }
83333                 return sourceFile;
83334             }
83335             else {
83336                 var sourceFileNoExtension = options.allowNonTsExtensions && getSourceFile(fileName);
83337                 if (sourceFileNoExtension)
83338                     return sourceFileNoExtension;
83339                 if (fail && options.allowNonTsExtensions) {
83340                     fail(ts.Diagnostics.File_0_not_found, fileName);
83341                     return undefined;
83342                 }
83343                 var sourceFileWithAddedExtension = ts.forEach(supportedExtensions, function (extension) { return getSourceFile(fileName + extension); });
83344                 if (fail && !sourceFileWithAddedExtension)
83345                     fail(ts.Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + supportedExtensions.join("', '") + "'");
83346                 return sourceFileWithAddedExtension;
83347             }
83348         }
83349         function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) {
83350             getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, function (diagnostic) {
83351                 var args = [];
83352                 for (var _i = 1; _i < arguments.length; _i++) {
83353                     args[_i - 1] = arguments[_i];
83354                 }
83355                 return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args)));
83356             }, refFile && refFile.file);
83357         }
83358         function reportFileNamesDifferOnlyInCasingError(fileName, existingFile, refFile) {
83359             var refs = !refFile ? refFileMap && refFileMap.get(existingFile.path) : undefined;
83360             var refToReportErrorOn = refs && ts.find(refs, function (ref) { return ref.referencedFileName === existingFile.fileName; });
83361             fileProcessingDiagnostics.add(refToReportErrorOn ?
83362                 createFileDiagnosticAtReference(refToReportErrorOn, ts.Diagnostics.Already_included_file_name_0_differs_from_file_name_1_only_in_casing, existingFile.fileName, fileName) :
83363                 createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFile.fileName));
83364         }
83365         function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) {
83366             var redirect = Object.create(redirectTarget);
83367             redirect.fileName = fileName;
83368             redirect.path = path;
83369             redirect.resolvedPath = resolvedPath;
83370             redirect.originalFileName = originalFileName;
83371             redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected };
83372             sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
83373             Object.defineProperties(redirect, {
83374                 id: {
83375                     get: function () { return this.redirectInfo.redirectTarget.id; },
83376                     set: function (value) { this.redirectInfo.redirectTarget.id = value; },
83377                 },
83378                 symbol: {
83379                     get: function () { return this.redirectInfo.redirectTarget.symbol; },
83380                     set: function (value) { this.redirectInfo.redirectTarget.symbol = value; },
83381                 },
83382             });
83383             return redirect;
83384         }
83385         function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) {
83386             if (useSourceOfProjectReferenceRedirect) {
83387                 var source = getSourceOfProjectReferenceRedirect(fileName);
83388                 if (!source &&
83389                     host.realpath &&
83390                     options.preserveSymlinks &&
83391                     ts.isDeclarationFileName(fileName) &&
83392                     ts.stringContains(fileName, ts.nodeModulesPathPart)) {
83393                     var realPath = host.realpath(fileName);
83394                     if (realPath !== fileName)
83395                         source = getSourceOfProjectReferenceRedirect(realPath);
83396                 }
83397                 if (source) {
83398                     var file_1 = ts.isString(source) ?
83399                         findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, refFile, packageId) :
83400                         undefined;
83401                     if (file_1)
83402                         addFileToFilesByName(file_1, path, undefined);
83403                     return file_1;
83404                 }
83405             }
83406             var originalFileName = fileName;
83407             if (filesByName.has(path)) {
83408                 var file_2 = filesByName.get(path);
83409                 addFileToRefFileMap(fileName, file_2 || undefined, refFile);
83410                 if (file_2 && options.forceConsistentCasingInFileNames) {
83411                     var checkedName = file_2.fileName;
83412                     var isRedirect = toPath(checkedName) !== toPath(fileName);
83413                     if (isRedirect) {
83414                         fileName = getProjectReferenceRedirect(fileName) || fileName;
83415                     }
83416                     var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory);
83417                     var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory);
83418                     if (checkedAbsolutePath !== inputAbsolutePath) {
83419                         reportFileNamesDifferOnlyInCasingError(fileName, file_2, refFile);
83420                     }
83421                 }
83422                 if (file_2 && sourceFilesFoundSearchingNodeModules.get(file_2.path) && currentNodeModulesDepth === 0) {
83423                     sourceFilesFoundSearchingNodeModules.set(file_2.path, false);
83424                     if (!options.noResolve) {
83425                         processReferencedFiles(file_2, isDefaultLib);
83426                         processTypeReferenceDirectives(file_2);
83427                     }
83428                     if (!options.noLib) {
83429                         processLibReferenceDirectives(file_2);
83430                     }
83431                     modulesWithElidedImports.set(file_2.path, false);
83432                     processImportedModules(file_2);
83433                 }
83434                 else if (file_2 && modulesWithElidedImports.get(file_2.path)) {
83435                     if (currentNodeModulesDepth < maxNodeModuleJsDepth) {
83436                         modulesWithElidedImports.set(file_2.path, false);
83437                         processImportedModules(file_2);
83438                     }
83439                 }
83440                 return file_2 || undefined;
83441             }
83442             var redirectedPath;
83443             if (refFile && !useSourceOfProjectReferenceRedirect) {
83444                 var redirectProject = getProjectReferenceRedirectProject(fileName);
83445                 if (redirectProject) {
83446                     if (redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out) {
83447                         return undefined;
83448                     }
83449                     var redirect = getProjectReferenceOutputName(redirectProject, fileName);
83450                     fileName = redirect;
83451                     redirectedPath = toPath(redirect);
83452                 }
83453             }
83454             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);
83455             if (packageId) {
83456                 var packageIdKey = ts.packageIdToString(packageId);
83457                 var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
83458                 if (fileFromPackageId) {
83459                     var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName);
83460                     redirectTargetsMap.add(fileFromPackageId.path, fileName);
83461                     addFileToFilesByName(dupFile, path, redirectedPath);
83462                     sourceFileToPackageName.set(path, packageId.name);
83463                     processingOtherFiles.push(dupFile);
83464                     return dupFile;
83465                 }
83466                 else if (file) {
83467                     packageIdToSourceFile.set(packageIdKey, file);
83468                     sourceFileToPackageName.set(path, packageId.name);
83469                 }
83470             }
83471             addFileToFilesByName(file, path, redirectedPath);
83472             if (file) {
83473                 sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
83474                 file.fileName = fileName;
83475                 file.path = path;
83476                 file.resolvedPath = toPath(fileName);
83477                 file.originalFileName = originalFileName;
83478                 addFileToRefFileMap(fileName, file, refFile);
83479                 if (host.useCaseSensitiveFileNames()) {
83480                     var pathLowerCase = ts.toFileNameLowerCase(path);
83481                     var existingFile = filesByNameIgnoreCase.get(pathLowerCase);
83482                     if (existingFile) {
83483                         reportFileNamesDifferOnlyInCasingError(fileName, existingFile, refFile);
83484                     }
83485                     else {
83486                         filesByNameIgnoreCase.set(pathLowerCase, file);
83487                     }
83488                 }
83489                 skipDefaultLib = skipDefaultLib || (file.hasNoDefaultLib && !ignoreNoDefaultLib);
83490                 if (!options.noResolve) {
83491                     processReferencedFiles(file, isDefaultLib);
83492                     processTypeReferenceDirectives(file);
83493                 }
83494                 if (!options.noLib) {
83495                     processLibReferenceDirectives(file);
83496                 }
83497                 processImportedModules(file);
83498                 if (isDefaultLib) {
83499                     processingDefaultLibFiles.push(file);
83500                 }
83501                 else {
83502                     processingOtherFiles.push(file);
83503                 }
83504             }
83505             return file;
83506         }
83507         function addFileToRefFileMap(referencedFileName, file, refFile) {
83508             if (refFile && file) {
83509                 (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, {
83510                     referencedFileName: referencedFileName,
83511                     kind: refFile.kind,
83512                     index: refFile.index,
83513                     file: refFile.file.path
83514                 });
83515             }
83516         }
83517         function addFileToFilesByName(file, path, redirectedPath) {
83518             if (redirectedPath) {
83519                 filesByName.set(redirectedPath, file);
83520                 filesByName.set(path, file || false);
83521             }
83522             else {
83523                 filesByName.set(path, file);
83524             }
83525         }
83526         function getProjectReferenceRedirect(fileName) {
83527             var referencedProject = getProjectReferenceRedirectProject(fileName);
83528             return referencedProject && getProjectReferenceOutputName(referencedProject, fileName);
83529         }
83530         function getProjectReferenceRedirectProject(fileName) {
83531             if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts") || ts.fileExtensionIs(fileName, ".json")) {
83532                 return undefined;
83533             }
83534             return getResolvedProjectReferenceToRedirect(fileName);
83535         }
83536         function getProjectReferenceOutputName(referencedProject, fileName) {
83537             var out = referencedProject.commandLine.options.outFile || referencedProject.commandLine.options.out;
83538             return out ?
83539                 ts.changeExtension(out, ".d.ts") :
83540                 ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine, !host.useCaseSensitiveFileNames());
83541         }
83542         function getResolvedProjectReferenceToRedirect(fileName) {
83543             if (mapFromFileToProjectReferenceRedirects === undefined) {
83544                 mapFromFileToProjectReferenceRedirects = ts.createMap();
83545                 forEachResolvedProjectReference(function (referencedProject, referenceProjectPath) {
83546                     if (referencedProject &&
83547                         toPath(options.configFilePath) !== referenceProjectPath) {
83548                         referencedProject.commandLine.fileNames.forEach(function (f) {
83549                             return mapFromFileToProjectReferenceRedirects.set(toPath(f), referenceProjectPath);
83550                         });
83551                     }
83552                 });
83553             }
83554             var referencedProjectPath = mapFromFileToProjectReferenceRedirects.get(toPath(fileName));
83555             return referencedProjectPath && getResolvedProjectReferenceByPath(referencedProjectPath);
83556         }
83557         function forEachResolvedProjectReference(cb) {
83558             return forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) {
83559                 var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
83560                 var resolvedRefPath = toPath(resolveProjectReferencePath(ref));
83561                 return cb(resolvedRef, resolvedRefPath);
83562             });
83563         }
83564         function getSourceOfProjectReferenceRedirect(file) {
83565             if (!ts.isDeclarationFileName(file))
83566                 return undefined;
83567             if (mapFromToProjectReferenceRedirectSource === undefined) {
83568                 mapFromToProjectReferenceRedirectSource = ts.createMap();
83569                 forEachResolvedProjectReference(function (resolvedRef) {
83570                     if (resolvedRef) {
83571                         var out = resolvedRef.commandLine.options.outFile || resolvedRef.commandLine.options.out;
83572                         if (out) {
83573                             var outputDts = ts.changeExtension(out, ".d.ts");
83574                             mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true);
83575                         }
83576                         else {
83577                             ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) {
83578                                 if (!ts.fileExtensionIs(fileName, ".d.ts") && !ts.fileExtensionIs(fileName, ".json")) {
83579                                     var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames());
83580                                     mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName);
83581                                 }
83582                             });
83583                         }
83584                     }
83585                 });
83586             }
83587             return mapFromToProjectReferenceRedirectSource.get(toPath(file));
83588         }
83589         function isSourceOfProjectReferenceRedirect(fileName) {
83590             return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName);
83591         }
83592         function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) {
83593             var seenResolvedRefs;
83594             return worker(projectReferences, resolvedProjectReferences, undefined, cbResolvedRef, cbRef);
83595             function worker(projectReferences, resolvedProjectReferences, parent, cbResolvedRef, cbRef) {
83596                 if (cbRef) {
83597                     var result = cbRef(projectReferences, parent);
83598                     if (result) {
83599                         return result;
83600                     }
83601                 }
83602                 return ts.forEach(resolvedProjectReferences, function (resolvedRef, index) {
83603                     if (ts.contains(seenResolvedRefs, resolvedRef)) {
83604                         return undefined;
83605                     }
83606                     var result = cbResolvedRef(resolvedRef, index, parent);
83607                     if (result) {
83608                         return result;
83609                     }
83610                     if (!resolvedRef)
83611                         return undefined;
83612                     (seenResolvedRefs || (seenResolvedRefs = [])).push(resolvedRef);
83613                     return worker(resolvedRef.commandLine.projectReferences, resolvedRef.references, resolvedRef, cbResolvedRef, cbRef);
83614                 });
83615             }
83616         }
83617         function getResolvedProjectReferenceByPath(projectReferencePath) {
83618             if (!projectReferenceRedirects) {
83619                 return undefined;
83620             }
83621             return projectReferenceRedirects.get(projectReferencePath) || undefined;
83622         }
83623         function processReferencedFiles(file, isDefaultLib) {
83624             ts.forEach(file.referencedFiles, function (ref, index) {
83625                 var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName);
83626                 processSourceFile(referencedFileName, isDefaultLib, false, undefined, {
83627                     kind: ts.RefFileKind.ReferenceFile,
83628                     index: index,
83629                     file: file,
83630                     pos: ref.pos,
83631                     end: ref.end
83632                 });
83633             });
83634         }
83635         function processTypeReferenceDirectives(file) {
83636             var typeDirectives = ts.map(file.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
83637             if (!typeDirectives) {
83638                 return;
83639             }
83640             var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.originalFileName, getResolvedProjectReferenceToRedirect(file.originalFileName));
83641             for (var i = 0; i < typeDirectives.length; i++) {
83642                 var ref = file.typeReferenceDirectives[i];
83643                 var resolvedTypeReferenceDirective = resolutions[i];
83644                 var fileName = ts.toFileNameLowerCase(ref.fileName);
83645                 ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
83646                 processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, {
83647                     kind: ts.RefFileKind.TypeReferenceDirective,
83648                     index: i,
83649                     file: file,
83650                     pos: ref.pos,
83651                     end: ref.end
83652                 });
83653             }
83654         }
83655         function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) {
83656             var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective);
83657             if (previousResolution && previousResolution.primary) {
83658                 return;
83659             }
83660             var saveResolution = true;
83661             if (resolvedTypeReferenceDirective) {
83662                 if (resolvedTypeReferenceDirective.isExternalLibraryImport)
83663                     currentNodeModulesDepth++;
83664                 if (resolvedTypeReferenceDirective.primary) {
83665                     processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile);
83666                 }
83667                 else {
83668                     if (previousResolution) {
83669                         if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) {
83670                             var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName);
83671                             var existingFile_1 = getSourceFile(previousResolution.resolvedFileName);
83672                             if (otherFileText !== existingFile_1.text) {
83673                                 var refs = !refFile ? refFileMap && refFileMap.get(existingFile_1.path) : undefined;
83674                                 var refToReportErrorOn = refs && ts.find(refs, function (ref) { return ref.referencedFileName === existingFile_1.fileName; });
83675                                 fileProcessingDiagnostics.add(refToReportErrorOn ?
83676                                     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) :
83677                                     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));
83678                             }
83679                         }
83680                         saveResolution = false;
83681                     }
83682                     else {
83683                         processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile);
83684                     }
83685                 }
83686                 if (resolvedTypeReferenceDirective.isExternalLibraryImport)
83687                     currentNodeModulesDepth--;
83688             }
83689             else {
83690                 fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective));
83691             }
83692             if (saveResolution) {
83693                 resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective);
83694             }
83695         }
83696         function processLibReferenceDirectives(file) {
83697             ts.forEach(file.libReferenceDirectives, function (libReference) {
83698                 var libName = ts.toFileNameLowerCase(libReference.fileName);
83699                 var libFileName = ts.libMap.get(libName);
83700                 if (libFileName) {
83701                     processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), true, true);
83702                 }
83703                 else {
83704                     var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts");
83705                     var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity);
83706                     var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0;
83707                     fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion));
83708                 }
83709             });
83710         }
83711         function createRefFileDiagnostic(refFile, message) {
83712             var args = [];
83713             for (var _i = 2; _i < arguments.length; _i++) {
83714                 args[_i - 2] = arguments[_i];
83715             }
83716             if (!refFile) {
83717                 return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args));
83718             }
83719             else {
83720                 return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args));
83721             }
83722         }
83723         function getCanonicalFileName(fileName) {
83724             return host.getCanonicalFileName(fileName);
83725         }
83726         function processImportedModules(file) {
83727             collectExternalModuleReferences(file);
83728             if (file.imports.length || file.moduleAugmentations.length) {
83729                 var moduleNames = getModuleNames(file);
83730                 var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), file);
83731                 ts.Debug.assert(resolutions.length === moduleNames.length);
83732                 for (var i = 0; i < moduleNames.length; i++) {
83733                     var resolution = resolutions[i];
83734                     ts.setResolvedModule(file, moduleNames[i], resolution);
83735                     if (!resolution) {
83736                         continue;
83737                     }
83738                     var isFromNodeModulesSearch = resolution.isExternalLibraryImport;
83739                     var isJsFile = !ts.resolutionExtensionIsTSOrJson(resolution.extension);
83740                     var isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile;
83741                     var resolvedFileName = resolution.resolvedFileName;
83742                     if (isFromNodeModulesSearch) {
83743                         currentNodeModulesDepth++;
83744                     }
83745                     var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth;
83746                     var shouldAddFile = resolvedFileName
83747                         && !getResolutionDiagnostic(options, resolution)
83748                         && !options.noResolve
83749                         && i < file.imports.length
83750                         && !elideImport
83751                         && !(isJsFile && !options.allowJs)
83752                         && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 4194304));
83753                     if (elideImport) {
83754                         modulesWithElidedImports.set(file.path, true);
83755                     }
83756                     else if (shouldAddFile) {
83757                         var path = toPath(resolvedFileName);
83758                         var pos = ts.skipTrivia(file.text, file.imports[i].pos);
83759                         findSourceFile(resolvedFileName, path, false, false, {
83760                             kind: ts.RefFileKind.Import,
83761                             index: i,
83762                             file: file,
83763                             pos: pos,
83764                             end: file.imports[i].end
83765                         }, resolution.packageId);
83766                     }
83767                     if (isFromNodeModulesSearch) {
83768                         currentNodeModulesDepth--;
83769                     }
83770                 }
83771             }
83772             else {
83773                 file.resolvedModules = undefined;
83774             }
83775         }
83776         function computeCommonSourceDirectory(sourceFiles) {
83777             var fileNames = ts.mapDefined(sourceFiles, function (file) { return file.isDeclarationFile ? undefined : file.fileName; });
83778             return computeCommonSourceDirectoryOfFilenames(fileNames, currentDirectory, getCanonicalFileName);
83779         }
83780         function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) {
83781             var allFilesBelongToPath = true;
83782             var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory));
83783             var rootPaths;
83784             for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) {
83785                 var sourceFile = sourceFiles_2[_i];
83786                 if (!sourceFile.isDeclarationFile) {
83787                     var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
83788                     if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
83789                         if (!rootPaths)
83790                             rootPaths = ts.arrayToSet(rootNames, toPath);
83791                         addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory);
83792                         allFilesBelongToPath = false;
83793                     }
83794                 }
83795             }
83796             return allFilesBelongToPath;
83797         }
83798         function parseProjectReferenceConfigFile(ref) {
83799             if (!projectReferenceRedirects) {
83800                 projectReferenceRedirects = ts.createMap();
83801             }
83802             var refPath = resolveProjectReferencePath(ref);
83803             var sourceFilePath = toPath(refPath);
83804             var fromCache = projectReferenceRedirects.get(sourceFilePath);
83805             if (fromCache !== undefined) {
83806                 return fromCache || undefined;
83807             }
83808             var commandLine;
83809             var sourceFile;
83810             if (host.getParsedCommandLine) {
83811                 commandLine = host.getParsedCommandLine(refPath);
83812                 if (!commandLine) {
83813                     addFileToFilesByName(undefined, sourceFilePath, undefined);
83814                     projectReferenceRedirects.set(sourceFilePath, false);
83815                     return undefined;
83816                 }
83817                 sourceFile = ts.Debug.checkDefined(commandLine.options.configFile);
83818                 ts.Debug.assert(!sourceFile.path || sourceFile.path === sourceFilePath);
83819                 addFileToFilesByName(sourceFile, sourceFilePath, undefined);
83820             }
83821             else {
83822                 var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory());
83823                 sourceFile = host.getSourceFile(refPath, 100);
83824                 addFileToFilesByName(sourceFile, sourceFilePath, undefined);
83825                 if (sourceFile === undefined) {
83826                     projectReferenceRedirects.set(sourceFilePath, false);
83827                     return undefined;
83828                 }
83829                 commandLine = ts.parseJsonSourceFileConfigFileContent(sourceFile, configParsingHost, basePath, undefined, refPath);
83830             }
83831             sourceFile.fileName = refPath;
83832             sourceFile.path = sourceFilePath;
83833             sourceFile.resolvedPath = sourceFilePath;
83834             sourceFile.originalFileName = refPath;
83835             var resolvedRef = { commandLine: commandLine, sourceFile: sourceFile };
83836             projectReferenceRedirects.set(sourceFilePath, resolvedRef);
83837             if (commandLine.projectReferences) {
83838                 resolvedRef.references = commandLine.projectReferences.map(parseProjectReferenceConfigFile);
83839             }
83840             return resolvedRef;
83841         }
83842         function verifyCompilerOptions() {
83843             if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) {
83844                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks");
83845             }
83846             if (options.isolatedModules) {
83847                 if (options.out) {
83848                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules");
83849                 }
83850                 if (options.outFile) {
83851                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules");
83852                 }
83853             }
83854             if (options.inlineSourceMap) {
83855                 if (options.sourceMap) {
83856                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap");
83857                 }
83858                 if (options.mapRoot) {
83859                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap");
83860                 }
83861             }
83862             if (options.paths && options.baseUrl === undefined) {
83863                 createDiagnosticForOptionName(ts.Diagnostics.Option_paths_cannot_be_used_without_specifying_baseUrl_option, "paths");
83864             }
83865             if (options.composite) {
83866                 if (options.declaration === false) {
83867                     createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_declaration_emit, "declaration");
83868                 }
83869                 if (options.incremental === false) {
83870                     createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_incremental_compilation, "declaration");
83871                 }
83872             }
83873             if (options.tsBuildInfoFile) {
83874                 if (!ts.isIncrementalCompilation(options)) {
83875                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "tsBuildInfoFile", "incremental", "composite");
83876                 }
83877             }
83878             else if (options.incremental && !options.outFile && !options.out && !options.configFilePath) {
83879                 programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified));
83880             }
83881             if (!options.listFilesOnly && options.noEmit && ts.isIncrementalCompilation(options)) {
83882                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", options.incremental ? "incremental" : "composite");
83883             }
83884             verifyProjectReferences();
83885             if (options.composite) {
83886                 var rootPaths = ts.arrayToSet(rootNames, toPath);
83887                 for (var _i = 0, files_3 = files; _i < files_3.length; _i++) {
83888                     var file = files_3[_i];
83889                     if (ts.sourceFileMayBeEmitted(file, program) && !rootPaths.has(file.path)) {
83890                         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 || "");
83891                     }
83892                 }
83893             }
83894             if (options.paths) {
83895                 for (var key in options.paths) {
83896                     if (!ts.hasProperty(options.paths, key)) {
83897                         continue;
83898                     }
83899                     if (!ts.hasZeroOrOneAsteriskCharacter(key)) {
83900                         createDiagnosticForOptionPaths(true, key, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, key);
83901                     }
83902                     if (ts.isArray(options.paths[key])) {
83903                         var len = options.paths[key].length;
83904                         if (len === 0) {
83905                             createDiagnosticForOptionPaths(false, key, ts.Diagnostics.Substitutions_for_pattern_0_shouldn_t_be_an_empty_array, key);
83906                         }
83907                         for (var i = 0; i < len; i++) {
83908                             var subst = options.paths[key][i];
83909                             var typeOfSubst = typeof subst;
83910                             if (typeOfSubst === "string") {
83911                                 if (!ts.hasZeroOrOneAsteriskCharacter(subst)) {
83912                                     createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character, subst, key);
83913                                 }
83914                             }
83915                             else {
83916                                 createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2, subst, key, typeOfSubst);
83917                             }
83918                         }
83919                     }
83920                     else {
83921                         createDiagnosticForOptionPaths(false, key, ts.Diagnostics.Substitutions_for_pattern_0_should_be_an_array, key);
83922                     }
83923                 }
83924             }
83925             if (!options.sourceMap && !options.inlineSourceMap) {
83926                 if (options.inlineSources) {
83927                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided, "inlineSources");
83928                 }
83929                 if (options.sourceRoot) {
83930                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided, "sourceRoot");
83931                 }
83932             }
83933             if (options.out && options.outFile) {
83934                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile");
83935             }
83936             if (options.mapRoot && !(options.sourceMap || options.declarationMap)) {
83937                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "mapRoot", "sourceMap", "declarationMap");
83938             }
83939             if (options.declarationDir) {
83940                 if (!ts.getEmitDeclarations(options)) {
83941                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "declarationDir", "declaration", "composite");
83942                 }
83943                 if (options.out || options.outFile) {
83944                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declarationDir", options.out ? "out" : "outFile");
83945                 }
83946             }
83947             if (options.declarationMap && !ts.getEmitDeclarations(options)) {
83948                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "declarationMap", "declaration", "composite");
83949             }
83950             if (options.lib && options.noLib) {
83951                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib");
83952             }
83953             if (options.noImplicitUseStrict && ts.getStrictOptionValue(options, "alwaysStrict")) {
83954                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict");
83955             }
83956             var languageVersion = options.target || 0;
83957             var outFile = options.outFile || options.out;
83958             var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; });
83959             if (options.isolatedModules) {
83960                 if (options.module === ts.ModuleKind.None && languageVersion < 2) {
83961                     createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target");
83962                 }
83963                 var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6; });
83964                 if (firstNonExternalModuleSourceFile) {
83965                     var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
83966                     programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.All_files_must_be_modules_when_the_isolatedModules_flag_is_provided));
83967                 }
83968             }
83969             else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 && options.module === ts.ModuleKind.None) {
83970                 var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
83971                 programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
83972             }
83973             if (outFile && !options.emitDeclarationOnly) {
83974                 if (options.module && !(options.module === ts.ModuleKind.AMD || options.module === ts.ModuleKind.System)) {
83975                     createDiagnosticForOptionName(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile", "module");
83976                 }
83977                 else if (options.module === undefined && firstNonAmbientExternalModuleSourceFile) {
83978                     var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
83979                     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"));
83980                 }
83981             }
83982             if (options.resolveJsonModule) {
83983                 if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs) {
83984                     createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule");
83985                 }
83986                 else if (!ts.hasJsonModuleEmitEnabled(options)) {
83987                     createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext, "resolveJsonModule", "module");
83988                 }
83989             }
83990             if (options.outDir ||
83991                 options.sourceRoot ||
83992                 options.mapRoot) {
83993                 var dir = getCommonSourceDirectory();
83994                 if (options.outDir && dir === "" && files.some(function (file) { return ts.getRootLength(file.fileName) > 1; })) {
83995                     createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir");
83996                 }
83997             }
83998             if (options.useDefineForClassFields && languageVersion === 0) {
83999                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields");
84000             }
84001             if (options.checkJs && !options.allowJs) {
84002                 programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs"));
84003             }
84004             if (options.emitDeclarationOnly) {
84005                 if (!ts.getEmitDeclarations(options)) {
84006                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "emitDeclarationOnly", "declaration", "composite");
84007                 }
84008                 if (options.noEmit) {
84009                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "emitDeclarationOnly", "noEmit");
84010                 }
84011             }
84012             if (options.emitDecoratorMetadata &&
84013                 !options.experimentalDecorators) {
84014                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators");
84015             }
84016             if (options.jsxFactory) {
84017                 if (options.reactNamespace) {
84018                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory");
84019                 }
84020                 if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) {
84021                     createOptionValueDiagnostic("jsxFactory", ts.Diagnostics.Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name, options.jsxFactory);
84022                 }
84023             }
84024             else if (options.reactNamespace && !ts.isIdentifierText(options.reactNamespace, languageVersion)) {
84025                 createOptionValueDiagnostic("reactNamespace", ts.Diagnostics.Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace);
84026             }
84027             if (!options.noEmit && !options.suppressOutputPathCheck) {
84028                 var emitHost = getEmitHost();
84029                 var emitFilesSeen_1 = ts.createMap();
84030                 ts.forEachEmittedFile(emitHost, function (emitFileNames) {
84031                     if (!options.emitDeclarationOnly) {
84032                         verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1);
84033                     }
84034                     verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1);
84035                 });
84036             }
84037             function verifyEmitFilePath(emitFileName, emitFilesSeen) {
84038                 if (emitFileName) {
84039                     var emitFilePath = toPath(emitFileName);
84040                     if (filesByName.has(emitFilePath)) {
84041                         var chain = void 0;
84042                         if (!options.configFilePath) {
84043                             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);
84044                         }
84045                         chain = ts.chainDiagnosticMessages(chain, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName);
84046                         blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain));
84047                     }
84048                     var emitFileKey = !host.useCaseSensitiveFileNames() ? ts.toFileNameLowerCase(emitFilePath) : emitFilePath;
84049                     if (emitFilesSeen.has(emitFileKey)) {
84050                         blockEmittingOfFile(emitFileName, ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName));
84051                     }
84052                     else {
84053                         emitFilesSeen.set(emitFileKey, true);
84054                     }
84055                 }
84056             }
84057         }
84058         function createFileDiagnosticAtReference(refPathToReportErrorOn, message) {
84059             var _a, _b;
84060             var args = [];
84061             for (var _i = 2; _i < arguments.length; _i++) {
84062                 args[_i - 2] = arguments[_i];
84063             }
84064             var refFile = ts.Debug.checkDefined(getSourceFileByPath(refPathToReportErrorOn.file));
84065             var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index;
84066             var pos, end;
84067             switch (kind) {
84068                 case ts.RefFileKind.Import:
84069                     pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos);
84070                     end = refFile.imports[index].end;
84071                     break;
84072                 case ts.RefFileKind.ReferenceFile:
84073                     (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end);
84074                     break;
84075                 case ts.RefFileKind.TypeReferenceDirective:
84076                     (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
84077                     break;
84078                 default:
84079                     return ts.Debug.assertNever(kind);
84080             }
84081             return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args));
84082         }
84083         function addProgramDiagnosticAtRefPath(file, rootPaths, message) {
84084             var args = [];
84085             for (var _i = 3; _i < arguments.length; _i++) {
84086                 args[_i - 3] = arguments[_i];
84087             }
84088             var refPaths = refFileMap && refFileMap.get(file.path);
84089             var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) ||
84090                 ts.elementAt(refPaths, 0);
84091             programDiagnostics.add(refPathToReportErrorOn ? createFileDiagnosticAtReference.apply(void 0, __spreadArrays([refPathToReportErrorOn, message], args)) : ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)));
84092         }
84093         function verifyProjectReferences() {
84094             var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getTsBuildInfoEmitOutputFilePath(options) : undefined;
84095             forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) {
84096                 var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
84097                 var parentFile = parent && parent.sourceFile;
84098                 if (!resolvedRef) {
84099                     createDiagnosticForReference(parentFile, index, ts.Diagnostics.File_0_not_found, ref.path);
84100                     return;
84101                 }
84102                 var options = resolvedRef.commandLine.options;
84103                 if (!options.composite) {
84104                     var inputs = parent ? parent.commandLine.fileNames : rootNames;
84105                     if (inputs.length) {
84106                         createDiagnosticForReference(parentFile, index, ts.Diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.path);
84107                     }
84108                 }
84109                 if (ref.prepend) {
84110                     var out = options.outFile || options.out;
84111                     if (out) {
84112                         if (!host.fileExists(out)) {
84113                             createDiagnosticForReference(parentFile, index, ts.Diagnostics.Output_file_0_from_project_1_does_not_exist, out, ref.path);
84114                         }
84115                     }
84116                     else {
84117                         createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path);
84118                     }
84119                 }
84120                 if (!parent && buildInfoPath && buildInfoPath === ts.getTsBuildInfoEmitOutputFilePath(options)) {
84121                     createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path);
84122                     hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true);
84123                 }
84124             });
84125         }
84126         function createDiagnosticForOptionPathKeyValue(key, valueIndex, message, arg0, arg1, arg2) {
84127             var needCompilerDiagnostic = true;
84128             var pathsSyntax = getOptionPathsSyntax();
84129             for (var _i = 0, pathsSyntax_1 = pathsSyntax; _i < pathsSyntax_1.length; _i++) {
84130                 var pathProp = pathsSyntax_1[_i];
84131                 if (ts.isObjectLiteralExpression(pathProp.initializer)) {
84132                     for (var _a = 0, _b = ts.getPropertyAssignment(pathProp.initializer, key); _a < _b.length; _a++) {
84133                         var keyProps = _b[_a];
84134                         var initializer = keyProps.initializer;
84135                         if (ts.isArrayLiteralExpression(initializer) && initializer.elements.length > valueIndex) {
84136                             programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, initializer.elements[valueIndex], message, arg0, arg1, arg2));
84137                             needCompilerDiagnostic = false;
84138                         }
84139                     }
84140                 }
84141             }
84142             if (needCompilerDiagnostic) {
84143                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1, arg2));
84144             }
84145         }
84146         function createDiagnosticForOptionPaths(onKey, key, message, arg0) {
84147             var needCompilerDiagnostic = true;
84148             var pathsSyntax = getOptionPathsSyntax();
84149             for (var _i = 0, pathsSyntax_2 = pathsSyntax; _i < pathsSyntax_2.length; _i++) {
84150                 var pathProp = pathsSyntax_2[_i];
84151                 if (ts.isObjectLiteralExpression(pathProp.initializer) &&
84152                     createOptionDiagnosticInObjectLiteralSyntax(pathProp.initializer, onKey, key, undefined, message, arg0)) {
84153                     needCompilerDiagnostic = false;
84154                 }
84155             }
84156             if (needCompilerDiagnostic) {
84157                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0));
84158             }
84159         }
84160         function getOptionsSyntaxByName(name) {
84161             var compilerOptionsObjectLiteralSyntax = getCompilerOptionsObjectLiteralSyntax();
84162             if (compilerOptionsObjectLiteralSyntax) {
84163                 return ts.getPropertyAssignment(compilerOptionsObjectLiteralSyntax, name);
84164             }
84165             return undefined;
84166         }
84167         function getOptionPathsSyntax() {
84168             return getOptionsSyntaxByName("paths") || ts.emptyArray;
84169         }
84170         function createDiagnosticForOptionName(message, option1, option2, option3) {
84171             createDiagnosticForOption(true, option1, option2, message, option1, option2, option3);
84172         }
84173         function createOptionValueDiagnostic(option1, message, arg0) {
84174             createDiagnosticForOption(false, option1, undefined, message, arg0);
84175         }
84176         function createDiagnosticForReference(sourceFile, index, message, arg0, arg1) {
84177             var referencesSyntax = ts.firstDefined(ts.getTsConfigPropArray(sourceFile || options.configFile, "references"), function (property) { return ts.isArrayLiteralExpression(property.initializer) ? property.initializer : undefined; });
84178             if (referencesSyntax && referencesSyntax.elements.length > index) {
84179                 programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(sourceFile || options.configFile, referencesSyntax.elements[index], message, arg0, arg1));
84180             }
84181             else {
84182                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1));
84183             }
84184         }
84185         function createDiagnosticForOption(onKey, option1, option2, message, arg0, arg1, arg2) {
84186             var compilerOptionsObjectLiteralSyntax = getCompilerOptionsObjectLiteralSyntax();
84187             var needCompilerDiagnostic = !compilerOptionsObjectLiteralSyntax ||
84188                 !createOptionDiagnosticInObjectLiteralSyntax(compilerOptionsObjectLiteralSyntax, onKey, option1, option2, message, arg0, arg1, arg2);
84189             if (needCompilerDiagnostic) {
84190                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1, arg2));
84191             }
84192         }
84193         function getCompilerOptionsObjectLiteralSyntax() {
84194             if (_compilerOptionsObjectLiteralSyntax === undefined) {
84195                 _compilerOptionsObjectLiteralSyntax = null;
84196                 var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile);
84197                 if (jsonObjectLiteral) {
84198                     for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "compilerOptions"); _i < _a.length; _i++) {
84199                         var prop = _a[_i];
84200                         if (ts.isObjectLiteralExpression(prop.initializer)) {
84201                             _compilerOptionsObjectLiteralSyntax = prop.initializer;
84202                             break;
84203                         }
84204                     }
84205                 }
84206             }
84207             return _compilerOptionsObjectLiteralSyntax;
84208         }
84209         function createOptionDiagnosticInObjectLiteralSyntax(objectLiteral, onKey, key1, key2, message, arg0, arg1, arg2) {
84210             var props = ts.getPropertyAssignment(objectLiteral, key1, key2);
84211             for (var _i = 0, props_3 = props; _i < props_3.length; _i++) {
84212                 var prop = props_3[_i];
84213                 programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, onKey ? prop.name : prop.initializer, message, arg0, arg1, arg2));
84214             }
84215             return !!props.length;
84216         }
84217         function blockEmittingOfFile(emitFileName, diag) {
84218             hasEmitBlockingDiagnostics.set(toPath(emitFileName), true);
84219             programDiagnostics.add(diag);
84220         }
84221         function isEmittedFile(file) {
84222             if (options.noEmit) {
84223                 return false;
84224             }
84225             var filePath = toPath(file);
84226             if (getSourceFileByPath(filePath)) {
84227                 return false;
84228             }
84229             var out = options.outFile || options.out;
84230             if (out) {
84231                 return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts");
84232             }
84233             if (options.declarationDir && ts.containsPath(options.declarationDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames())) {
84234                 return true;
84235             }
84236             if (options.outDir) {
84237                 return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
84238             }
84239             if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensions) || ts.fileExtensionIs(filePath, ".d.ts")) {
84240                 var filePathWithoutExtension = ts.removeFileExtension(filePath);
84241                 return !!getSourceFileByPath((filePathWithoutExtension + ".ts")) ||
84242                     !!getSourceFileByPath((filePathWithoutExtension + ".tsx"));
84243             }
84244             return false;
84245         }
84246         function isSameFile(file1, file2) {
84247             return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0;
84248         }
84249         function getProbableSymlinks() {
84250             if (host.getSymlinks) {
84251                 return host.getSymlinks();
84252             }
84253             return symlinks || (symlinks = ts.discoverProbableSymlinks(files, getCanonicalFileName, host.getCurrentDirectory()));
84254         }
84255     }
84256     ts.createProgram = createProgram;
84257     function updateHostForUseSourceOfProjectReferenceRedirect(host) {
84258         var mapOfDeclarationDirectories;
84259         var symlinkedDirectories;
84260         var symlinkedFiles;
84261         var originalFileExists = host.compilerHost.fileExists;
84262         var originalDirectoryExists = host.compilerHost.directoryExists;
84263         var originalGetDirectories = host.compilerHost.getDirectories;
84264         var originalRealpath = host.compilerHost.realpath;
84265         if (!host.useSourceOfProjectReferenceRedirect)
84266             return { onProgramCreateComplete: ts.noop, fileExists: fileExists };
84267         host.compilerHost.fileExists = fileExists;
84268         if (originalDirectoryExists) {
84269             host.compilerHost.directoryExists = function (path) {
84270                 if (originalDirectoryExists.call(host.compilerHost, path)) {
84271                     handleDirectoryCouldBeSymlink(path);
84272                     return true;
84273                 }
84274                 if (!host.getResolvedProjectReferences())
84275                     return false;
84276                 if (!mapOfDeclarationDirectories) {
84277                     mapOfDeclarationDirectories = ts.createMap();
84278                     host.forEachResolvedProjectReference(function (ref) {
84279                         if (!ref)
84280                             return;
84281                         var out = ref.commandLine.options.outFile || ref.commandLine.options.out;
84282                         if (out) {
84283                             mapOfDeclarationDirectories.set(ts.getDirectoryPath(host.toPath(out)), true);
84284                         }
84285                         else {
84286                             var declarationDir = ref.commandLine.options.declarationDir || ref.commandLine.options.outDir;
84287                             if (declarationDir) {
84288                                 mapOfDeclarationDirectories.set(host.toPath(declarationDir), true);
84289                             }
84290                         }
84291                     });
84292                 }
84293                 return fileOrDirectoryExistsUsingSource(path, false);
84294             };
84295         }
84296         if (originalGetDirectories) {
84297             host.compilerHost.getDirectories = function (path) {
84298                 return !host.getResolvedProjectReferences() || (originalDirectoryExists && originalDirectoryExists.call(host.compilerHost, path)) ?
84299                     originalGetDirectories.call(host.compilerHost, path) :
84300                     [];
84301             };
84302         }
84303         if (originalRealpath) {
84304             host.compilerHost.realpath = function (s) {
84305                 return (symlinkedFiles === null || symlinkedFiles === void 0 ? void 0 : symlinkedFiles.get(host.toPath(s))) ||
84306                     originalRealpath.call(host.compilerHost, s);
84307             };
84308         }
84309         return { onProgramCreateComplete: onProgramCreateComplete, fileExists: fileExists };
84310         function onProgramCreateComplete() {
84311             host.compilerHost.fileExists = originalFileExists;
84312             host.compilerHost.directoryExists = originalDirectoryExists;
84313             host.compilerHost.getDirectories = originalGetDirectories;
84314         }
84315         function fileExists(file) {
84316             if (originalFileExists.call(host.compilerHost, file))
84317                 return true;
84318             if (!host.getResolvedProjectReferences())
84319                 return false;
84320             if (!ts.isDeclarationFileName(file))
84321                 return false;
84322             return fileOrDirectoryExistsUsingSource(file, true);
84323         }
84324         function fileExistsIfProjectReferenceDts(file) {
84325             var source = host.getSourceOfProjectReferenceRedirect(file);
84326             return source !== undefined ?
84327                 ts.isString(source) ? originalFileExists.call(host.compilerHost, source) : true :
84328                 undefined;
84329         }
84330         function directoryExistsIfProjectReferenceDeclDir(dir) {
84331             var dirPath = host.toPath(dir);
84332             var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator;
84333             return ts.forEachKey(mapOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath ||
84334                 ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) ||
84335                 ts.startsWith(dirPath, declDirPath + "/"); });
84336         }
84337         function handleDirectoryCouldBeSymlink(directory) {
84338             if (!host.getResolvedProjectReferences())
84339                 return;
84340             if (!originalRealpath || !ts.stringContains(directory, ts.nodeModulesPathPart))
84341                 return;
84342             if (!symlinkedDirectories)
84343                 symlinkedDirectories = ts.createMap();
84344             var directoryPath = ts.ensureTrailingDirectorySeparator(host.toPath(directory));
84345             if (symlinkedDirectories.has(directoryPath))
84346                 return;
84347             var real = ts.normalizePath(originalRealpath.call(host.compilerHost, directory));
84348             var realPath;
84349             if (real === directory ||
84350                 (realPath = ts.ensureTrailingDirectorySeparator(host.toPath(real))) === directoryPath) {
84351                 symlinkedDirectories.set(directoryPath, false);
84352                 return;
84353             }
84354             symlinkedDirectories.set(directoryPath, {
84355                 real: ts.ensureTrailingDirectorySeparator(real),
84356                 realPath: realPath
84357             });
84358         }
84359         function fileOrDirectoryExistsUsingSource(fileOrDirectory, isFile) {
84360             var fileOrDirectoryExistsUsingSource = isFile ?
84361                 function (file) { return fileExistsIfProjectReferenceDts(file); } :
84362                 function (dir) { return directoryExistsIfProjectReferenceDeclDir(dir); };
84363             var result = fileOrDirectoryExistsUsingSource(fileOrDirectory);
84364             if (result !== undefined)
84365                 return result;
84366             if (!symlinkedDirectories)
84367                 return false;
84368             var fileOrDirectoryPath = host.toPath(fileOrDirectory);
84369             if (!ts.stringContains(fileOrDirectoryPath, ts.nodeModulesPathPart))
84370                 return false;
84371             if (isFile && symlinkedFiles && symlinkedFiles.has(fileOrDirectoryPath))
84372                 return true;
84373             return ts.firstDefinedIterator(symlinkedDirectories.entries(), function (_a) {
84374                 var directoryPath = _a[0], symlinkedDirectory = _a[1];
84375                 if (!symlinkedDirectory || !ts.startsWith(fileOrDirectoryPath, directoryPath))
84376                     return undefined;
84377                 var result = fileOrDirectoryExistsUsingSource(fileOrDirectoryPath.replace(directoryPath, symlinkedDirectory.realPath));
84378                 if (isFile && result) {
84379                     if (!symlinkedFiles)
84380                         symlinkedFiles = ts.createMap();
84381                     var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, host.compilerHost.getCurrentDirectory());
84382                     symlinkedFiles.set(fileOrDirectoryPath, "" + symlinkedDirectory.real + absolutePath.replace(new RegExp(directoryPath, "i"), ""));
84383                 }
84384                 return result;
84385             }) || false;
84386         }
84387     }
84388     function handleNoEmitOptions(program, sourceFile, cancellationToken) {
84389         var options = program.getCompilerOptions();
84390         if (options.noEmit) {
84391             return { diagnostics: ts.emptyArray, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true };
84392         }
84393         if (!options.noEmitOnError)
84394             return undefined;
84395         var diagnostics = __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken));
84396         if (diagnostics.length === 0 && ts.getEmitDeclarations(program.getCompilerOptions())) {
84397             diagnostics = program.getDeclarationDiagnostics(undefined, cancellationToken);
84398         }
84399         return diagnostics.length > 0 ?
84400             { diagnostics: diagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true } :
84401             undefined;
84402     }
84403     ts.handleNoEmitOptions = handleNoEmitOptions;
84404     function parseConfigHostFromCompilerHostLike(host, directoryStructureHost) {
84405         if (directoryStructureHost === void 0) { directoryStructureHost = host; }
84406         return {
84407             fileExists: function (f) { return directoryStructureHost.fileExists(f); },
84408             readDirectory: function (root, extensions, excludes, includes, depth) {
84409                 ts.Debug.assertIsDefined(directoryStructureHost.readDirectory, "'CompilerHost.readDirectory' must be implemented to correctly process 'projectReferences'");
84410                 return directoryStructureHost.readDirectory(root, extensions, excludes, includes, depth);
84411             },
84412             readFile: function (f) { return directoryStructureHost.readFile(f); },
84413             useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(),
84414             getCurrentDirectory: function () { return host.getCurrentDirectory(); },
84415             onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic || ts.returnUndefined,
84416             trace: host.trace ? function (s) { return host.trace(s); } : undefined
84417         };
84418     }
84419     ts.parseConfigHostFromCompilerHostLike = parseConfigHostFromCompilerHostLike;
84420     function createPrependNodes(projectReferences, getCommandLine, readFile) {
84421         if (!projectReferences)
84422             return ts.emptyArray;
84423         var nodes;
84424         for (var i = 0; i < projectReferences.length; i++) {
84425             var ref = projectReferences[i];
84426             var resolvedRefOpts = getCommandLine(ref, i);
84427             if (ref.prepend && resolvedRefOpts && resolvedRefOpts.options) {
84428                 var out = resolvedRefOpts.options.outFile || resolvedRefOpts.options.out;
84429                 if (!out)
84430                     continue;
84431                 var _a = ts.getOutputPathsForBundle(resolvedRefOpts.options, true), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
84432                 var node = ts.createInputFiles(readFile, jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath);
84433                 (nodes || (nodes = [])).push(node);
84434             }
84435         }
84436         return nodes || ts.emptyArray;
84437     }
84438     ts.createPrependNodes = createPrependNodes;
84439     function resolveProjectReferencePath(hostOrRef, ref) {
84440         var passedInRef = ref ? ref : hostOrRef;
84441         return ts.resolveConfigFileProjectName(passedInRef.path);
84442     }
84443     ts.resolveProjectReferencePath = resolveProjectReferencePath;
84444     function getResolutionDiagnostic(options, _a) {
84445         var extension = _a.extension;
84446         switch (extension) {
84447             case ".ts":
84448             case ".d.ts":
84449                 return undefined;
84450             case ".tsx":
84451                 return needJsx();
84452             case ".jsx":
84453                 return needJsx() || needAllowJs();
84454             case ".js":
84455                 return needAllowJs();
84456             case ".json":
84457                 return needResolveJsonModule();
84458         }
84459         function needJsx() {
84460             return options.jsx ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set;
84461         }
84462         function needAllowJs() {
84463             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;
84464         }
84465         function needResolveJsonModule() {
84466             return options.resolveJsonModule ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used;
84467         }
84468     }
84469     ts.getResolutionDiagnostic = getResolutionDiagnostic;
84470     function getModuleNames(_a) {
84471         var imports = _a.imports, moduleAugmentations = _a.moduleAugmentations;
84472         var res = imports.map(function (i) { return i.text; });
84473         for (var _i = 0, moduleAugmentations_1 = moduleAugmentations; _i < moduleAugmentations_1.length; _i++) {
84474             var aug = moduleAugmentations_1[_i];
84475             if (aug.kind === 10) {
84476                 res.push(aug.text);
84477             }
84478         }
84479         return res;
84480     }
84481 })(ts || (ts = {}));
84482 var ts;
84483 (function (ts) {
84484     function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) {
84485         var outputFiles = [];
84486         var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics, exportedModulesFromDeclarationEmit = _a.exportedModulesFromDeclarationEmit;
84487         return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics, exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit };
84488         function writeFile(fileName, text, writeByteOrderMark) {
84489             outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text });
84490         }
84491     }
84492     ts.getFileEmitOutput = getFileEmitOutput;
84493     var BuilderState;
84494     (function (BuilderState) {
84495         function getReferencedFileFromImportedModuleSymbol(symbol) {
84496             if (symbol.declarations && symbol.declarations[0]) {
84497                 var declarationSourceFile = ts.getSourceFileOfNode(symbol.declarations[0]);
84498                 return declarationSourceFile && declarationSourceFile.resolvedPath;
84499             }
84500         }
84501         function getReferencedFileFromImportLiteral(checker, importName) {
84502             var symbol = checker.getSymbolAtLocation(importName);
84503             return symbol && getReferencedFileFromImportedModuleSymbol(symbol);
84504         }
84505         function getReferencedFileFromFileName(program, fileName, sourceFileDirectory, getCanonicalFileName) {
84506             return ts.toPath(program.getProjectReferenceRedirect(fileName) || fileName, sourceFileDirectory, getCanonicalFileName);
84507         }
84508         function getReferencedFiles(program, sourceFile, getCanonicalFileName) {
84509             var referencedFiles;
84510             if (sourceFile.imports && sourceFile.imports.length > 0) {
84511                 var checker = program.getTypeChecker();
84512                 for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) {
84513                     var importName = _a[_i];
84514                     var declarationSourceFilePath = getReferencedFileFromImportLiteral(checker, importName);
84515                     if (declarationSourceFilePath) {
84516                         addReferencedFile(declarationSourceFilePath);
84517                     }
84518                 }
84519             }
84520             var sourceFileDirectory = ts.getDirectoryPath(sourceFile.resolvedPath);
84521             if (sourceFile.referencedFiles && sourceFile.referencedFiles.length > 0) {
84522                 for (var _b = 0, _c = sourceFile.referencedFiles; _b < _c.length; _b++) {
84523                     var referencedFile = _c[_b];
84524                     var referencedPath = getReferencedFileFromFileName(program, referencedFile.fileName, sourceFileDirectory, getCanonicalFileName);
84525                     addReferencedFile(referencedPath);
84526                 }
84527             }
84528             if (sourceFile.resolvedTypeReferenceDirectiveNames) {
84529                 sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (resolvedTypeReferenceDirective) {
84530                     if (!resolvedTypeReferenceDirective) {
84531                         return;
84532                     }
84533                     var fileName = resolvedTypeReferenceDirective.resolvedFileName;
84534                     var typeFilePath = getReferencedFileFromFileName(program, fileName, sourceFileDirectory, getCanonicalFileName);
84535                     addReferencedFile(typeFilePath);
84536                 });
84537             }
84538             if (sourceFile.moduleAugmentations.length) {
84539                 var checker = program.getTypeChecker();
84540                 for (var _d = 0, _e = sourceFile.moduleAugmentations; _d < _e.length; _d++) {
84541                     var moduleName = _e[_d];
84542                     if (!ts.isStringLiteral(moduleName)) {
84543                         continue;
84544                     }
84545                     var symbol = checker.getSymbolAtLocation(moduleName);
84546                     if (!symbol) {
84547                         continue;
84548                     }
84549                     addReferenceFromAmbientModule(symbol);
84550                 }
84551             }
84552             for (var _f = 0, _g = program.getTypeChecker().getAmbientModules(); _f < _g.length; _f++) {
84553                 var ambientModule = _g[_f];
84554                 if (ambientModule.declarations.length > 1) {
84555                     addReferenceFromAmbientModule(ambientModule);
84556                 }
84557             }
84558             return referencedFiles;
84559             function addReferenceFromAmbientModule(symbol) {
84560                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
84561                     var declaration = _a[_i];
84562                     var declarationSourceFile = ts.getSourceFileOfNode(declaration);
84563                     if (declarationSourceFile &&
84564                         declarationSourceFile !== sourceFile) {
84565                         addReferencedFile(declarationSourceFile.resolvedPath);
84566                     }
84567                 }
84568             }
84569             function addReferencedFile(referencedPath) {
84570                 if (!referencedFiles) {
84571                     referencedFiles = ts.createMap();
84572                 }
84573                 referencedFiles.set(referencedPath, true);
84574             }
84575         }
84576         function canReuseOldState(newReferencedMap, oldState) {
84577             return oldState && !oldState.referencedMap === !newReferencedMap;
84578         }
84579         BuilderState.canReuseOldState = canReuseOldState;
84580         function create(newProgram, getCanonicalFileName, oldState) {
84581             var fileInfos = ts.createMap();
84582             var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? ts.createMap() : undefined;
84583             var exportedModulesMap = referencedMap ? ts.createMap() : undefined;
84584             var hasCalledUpdateShapeSignature = ts.createMap();
84585             var useOldState = canReuseOldState(referencedMap, oldState);
84586             for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
84587                 var sourceFile = _a[_i];
84588                 var version_1 = ts.Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set");
84589                 var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.resolvedPath) : undefined;
84590                 if (referencedMap) {
84591                     var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName);
84592                     if (newReferences) {
84593                         referencedMap.set(sourceFile.resolvedPath, newReferences);
84594                     }
84595                     if (useOldState) {
84596                         var exportedModules = oldState.exportedModulesMap.get(sourceFile.resolvedPath);
84597                         if (exportedModules) {
84598                             exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
84599                         }
84600                     }
84601                 }
84602                 fileInfos.set(sourceFile.resolvedPath, { version: version_1, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) });
84603             }
84604             return {
84605                 fileInfos: fileInfos,
84606                 referencedMap: referencedMap,
84607                 exportedModulesMap: exportedModulesMap,
84608                 hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature
84609             };
84610         }
84611         BuilderState.create = create;
84612         function releaseCache(state) {
84613             state.allFilesExcludingDefaultLibraryFile = undefined;
84614             state.allFileNames = undefined;
84615         }
84616         BuilderState.releaseCache = releaseCache;
84617         function clone(state) {
84618             var fileInfos = ts.createMap();
84619             state.fileInfos.forEach(function (value, key) {
84620                 fileInfos.set(key, __assign({}, value));
84621             });
84622             return {
84623                 fileInfos: fileInfos,
84624                 referencedMap: cloneMapOrUndefined(state.referencedMap),
84625                 exportedModulesMap: cloneMapOrUndefined(state.exportedModulesMap),
84626                 hasCalledUpdateShapeSignature: ts.cloneMap(state.hasCalledUpdateShapeSignature),
84627             };
84628         }
84629         BuilderState.clone = clone;
84630         function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, cacheToUpdateSignature, exportedModulesMapCache) {
84631             var signatureCache = cacheToUpdateSignature || ts.createMap();
84632             var sourceFile = programOfThisState.getSourceFileByPath(path);
84633             if (!sourceFile) {
84634                 return ts.emptyArray;
84635             }
84636             if (!updateShapeSignature(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache)) {
84637                 return [sourceFile];
84638             }
84639             var result = (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache);
84640             if (!cacheToUpdateSignature) {
84641                 updateSignaturesFromCache(state, signatureCache);
84642             }
84643             return result;
84644         }
84645         BuilderState.getFilesAffectedBy = getFilesAffectedBy;
84646         function updateSignaturesFromCache(state, signatureCache) {
84647             signatureCache.forEach(function (signature, path) { return updateSignatureOfFile(state, signature, path); });
84648         }
84649         BuilderState.updateSignaturesFromCache = updateSignaturesFromCache;
84650         function updateSignatureOfFile(state, signature, path) {
84651             state.fileInfos.get(path).signature = signature;
84652             state.hasCalledUpdateShapeSignature.set(path, true);
84653         }
84654         BuilderState.updateSignatureOfFile = updateSignatureOfFile;
84655         function updateShapeSignature(state, programOfThisState, sourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
84656             ts.Debug.assert(!!sourceFile);
84657             ts.Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state");
84658             if (state.hasCalledUpdateShapeSignature.has(sourceFile.resolvedPath) || cacheToUpdateSignature.has(sourceFile.resolvedPath)) {
84659                 return false;
84660             }
84661             var info = state.fileInfos.get(sourceFile.resolvedPath);
84662             if (!info)
84663                 return ts.Debug.fail();
84664             var prevSignature = info.signature;
84665             var latestSignature;
84666             if (sourceFile.isDeclarationFile) {
84667                 latestSignature = sourceFile.version;
84668                 if (exportedModulesMapCache && latestSignature !== prevSignature) {
84669                     var references = state.referencedMap ? state.referencedMap.get(sourceFile.resolvedPath) : undefined;
84670                     exportedModulesMapCache.set(sourceFile.resolvedPath, references || false);
84671                 }
84672             }
84673             else {
84674                 var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile, true, cancellationToken, undefined, true);
84675                 var firstDts_1 = emitOutput_1.outputFiles &&
84676                     programOfThisState.getCompilerOptions().declarationMap ?
84677                     emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined :
84678                     emitOutput_1.outputFiles.length > 0 ? emitOutput_1.outputFiles[0] : undefined;
84679                 if (firstDts_1) {
84680                     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; })); });
84681                     latestSignature = computeHash(firstDts_1.text);
84682                     if (exportedModulesMapCache && latestSignature !== prevSignature) {
84683                         updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
84684                     }
84685                 }
84686                 else {
84687                     latestSignature = prevSignature;
84688                 }
84689             }
84690             cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature);
84691             return !prevSignature || latestSignature !== prevSignature;
84692         }
84693         BuilderState.updateShapeSignature = updateShapeSignature;
84694         function updateExportedModules(sourceFile, exportedModulesFromDeclarationEmit, exportedModulesMapCache) {
84695             if (!exportedModulesFromDeclarationEmit) {
84696                 exportedModulesMapCache.set(sourceFile.resolvedPath, false);
84697                 return;
84698             }
84699             var exportedModules;
84700             exportedModulesFromDeclarationEmit.forEach(function (symbol) { return addExportedModule(getReferencedFileFromImportedModuleSymbol(symbol)); });
84701             exportedModulesMapCache.set(sourceFile.resolvedPath, exportedModules || false);
84702             function addExportedModule(exportedModulePath) {
84703                 if (exportedModulePath) {
84704                     if (!exportedModules) {
84705                         exportedModules = ts.createMap();
84706                     }
84707                     exportedModules.set(exportedModulePath, true);
84708                 }
84709             }
84710         }
84711         function updateExportedFilesMapFromCache(state, exportedModulesMapCache) {
84712             if (exportedModulesMapCache) {
84713                 ts.Debug.assert(!!state.exportedModulesMap);
84714                 exportedModulesMapCache.forEach(function (exportedModules, path) {
84715                     if (exportedModules) {
84716                         state.exportedModulesMap.set(path, exportedModules);
84717                     }
84718                     else {
84719                         state.exportedModulesMap.delete(path);
84720                     }
84721                 });
84722             }
84723         }
84724         BuilderState.updateExportedFilesMapFromCache = updateExportedFilesMapFromCache;
84725         function getAllDependencies(state, programOfThisState, sourceFile) {
84726             var compilerOptions = programOfThisState.getCompilerOptions();
84727             if (compilerOptions.outFile || compilerOptions.out) {
84728                 return getAllFileNames(state, programOfThisState);
84729             }
84730             if (!state.referencedMap || isFileAffectingGlobalScope(sourceFile)) {
84731                 return getAllFileNames(state, programOfThisState);
84732             }
84733             var seenMap = ts.createMap();
84734             var queue = [sourceFile.resolvedPath];
84735             while (queue.length) {
84736                 var path = queue.pop();
84737                 if (!seenMap.has(path)) {
84738                     seenMap.set(path, true);
84739                     var references = state.referencedMap.get(path);
84740                     if (references) {
84741                         var iterator = references.keys();
84742                         for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
84743                             queue.push(iterResult.value);
84744                         }
84745                     }
84746                 }
84747             }
84748             return ts.arrayFrom(ts.mapDefinedIterator(seenMap.keys(), function (path) {
84749                 var file = programOfThisState.getSourceFileByPath(path);
84750                 return file ? file.fileName : path;
84751             }));
84752         }
84753         BuilderState.getAllDependencies = getAllDependencies;
84754         function getAllFileNames(state, programOfThisState) {
84755             if (!state.allFileNames) {
84756                 var sourceFiles = programOfThisState.getSourceFiles();
84757                 state.allFileNames = sourceFiles === ts.emptyArray ? ts.emptyArray : sourceFiles.map(function (file) { return file.fileName; });
84758             }
84759             return state.allFileNames;
84760         }
84761         function getReferencedByPaths(state, referencedFilePath) {
84762             return ts.arrayFrom(ts.mapDefinedIterator(state.referencedMap.entries(), function (_a) {
84763                 var filePath = _a[0], referencesInFile = _a[1];
84764                 return referencesInFile.has(referencedFilePath) ? filePath : undefined;
84765             }));
84766         }
84767         BuilderState.getReferencedByPaths = getReferencedByPaths;
84768         function containsOnlyAmbientModules(sourceFile) {
84769             for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
84770                 var statement = _a[_i];
84771                 if (!ts.isModuleWithStringLiteralName(statement)) {
84772                     return false;
84773                 }
84774             }
84775             return true;
84776         }
84777         function containsGlobalScopeAugmentation(sourceFile) {
84778             return ts.some(sourceFile.moduleAugmentations, function (augmentation) { return ts.isGlobalScopeAugmentation(augmentation.parent); });
84779         }
84780         function isFileAffectingGlobalScope(sourceFile) {
84781             return containsGlobalScopeAugmentation(sourceFile) ||
84782                 !ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile);
84783         }
84784         function getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, firstSourceFile) {
84785             if (state.allFilesExcludingDefaultLibraryFile) {
84786                 return state.allFilesExcludingDefaultLibraryFile;
84787             }
84788             var result;
84789             if (firstSourceFile)
84790                 addSourceFile(firstSourceFile);
84791             for (var _i = 0, _a = programOfThisState.getSourceFiles(); _i < _a.length; _i++) {
84792                 var sourceFile = _a[_i];
84793                 if (sourceFile !== firstSourceFile) {
84794                     addSourceFile(sourceFile);
84795                 }
84796             }
84797             state.allFilesExcludingDefaultLibraryFile = result || ts.emptyArray;
84798             return state.allFilesExcludingDefaultLibraryFile;
84799             function addSourceFile(sourceFile) {
84800                 if (!programOfThisState.isSourceFileDefaultLibrary(sourceFile)) {
84801                     (result || (result = [])).push(sourceFile);
84802                 }
84803             }
84804         }
84805         BuilderState.getAllFilesExcludingDefaultLibraryFile = getAllFilesExcludingDefaultLibraryFile;
84806         function getFilesAffectedByUpdatedShapeWhenNonModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape) {
84807             var compilerOptions = programOfThisState.getCompilerOptions();
84808             if (compilerOptions && (compilerOptions.out || compilerOptions.outFile)) {
84809                 return [sourceFileWithUpdatedShape];
84810             }
84811             return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
84812         }
84813         function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
84814             if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
84815                 return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
84816             }
84817             var compilerOptions = programOfThisState.getCompilerOptions();
84818             if (compilerOptions && (compilerOptions.isolatedModules || compilerOptions.out || compilerOptions.outFile)) {
84819                 return [sourceFileWithUpdatedShape];
84820             }
84821             var seenFileNamesMap = ts.createMap();
84822             seenFileNamesMap.set(sourceFileWithUpdatedShape.resolvedPath, sourceFileWithUpdatedShape);
84823             var queue = getReferencedByPaths(state, sourceFileWithUpdatedShape.resolvedPath);
84824             while (queue.length > 0) {
84825                 var currentPath = queue.pop();
84826                 if (!seenFileNamesMap.has(currentPath)) {
84827                     var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
84828                     seenFileNamesMap.set(currentPath, currentSourceFile);
84829                     if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache)) {
84830                         queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
84831                     }
84832                 }
84833             }
84834             return ts.arrayFrom(ts.mapDefinedIterator(seenFileNamesMap.values(), function (value) { return value; }));
84835         }
84836     })(BuilderState = ts.BuilderState || (ts.BuilderState = {}));
84837     function cloneMapOrUndefined(map) {
84838         return map ? ts.cloneMap(map) : undefined;
84839     }
84840     ts.cloneMapOrUndefined = cloneMapOrUndefined;
84841 })(ts || (ts = {}));
84842 var ts;
84843 (function (ts) {
84844     function hasSameKeys(map1, map2) {
84845         return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); });
84846     }
84847     function createBuilderProgramState(newProgram, getCanonicalFileName, oldState) {
84848         var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState);
84849         state.program = newProgram;
84850         var compilerOptions = newProgram.getCompilerOptions();
84851         state.compilerOptions = compilerOptions;
84852         if (!compilerOptions.outFile && !compilerOptions.out) {
84853             state.semanticDiagnosticsPerFile = ts.createMap();
84854         }
84855         state.changedFilesSet = ts.createMap();
84856         var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState);
84857         var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
84858         var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
84859             !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
84860         if (useOldState) {
84861             if (!oldState.currentChangedFilePath) {
84862                 var affectedSignatures = oldState.currentAffectedFilesSignatures;
84863                 ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated");
84864             }
84865             var changedFilesSet = oldState.changedFilesSet;
84866             if (canCopySemanticDiagnostics) {
84867                 ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files");
84868             }
84869             if (changedFilesSet) {
84870                 ts.copyEntries(changedFilesSet, state.changedFilesSet);
84871             }
84872             if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) {
84873                 state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice();
84874                 state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind);
84875                 state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex;
84876                 state.seenAffectedFiles = ts.createMap();
84877             }
84878         }
84879         var referencedMap = state.referencedMap;
84880         var oldReferencedMap = useOldState ? oldState.referencedMap : undefined;
84881         var copyDeclarationFileDiagnostics = canCopySemanticDiagnostics && !compilerOptions.skipLibCheck === !oldCompilerOptions.skipLibCheck;
84882         var copyLibFileDiagnostics = copyDeclarationFileDiagnostics && !compilerOptions.skipDefaultLibCheck === !oldCompilerOptions.skipDefaultLibCheck;
84883         state.fileInfos.forEach(function (info, sourceFilePath) {
84884             var oldInfo;
84885             var newReferences;
84886             if (!useOldState ||
84887                 !(oldInfo = oldState.fileInfos.get(sourceFilePath)) ||
84888                 oldInfo.version !== info.version ||
84889                 !hasSameKeys(newReferences = referencedMap && referencedMap.get(sourceFilePath), oldReferencedMap && oldReferencedMap.get(sourceFilePath)) ||
84890                 newReferences && ts.forEachKey(newReferences, function (path) { return !state.fileInfos.has(path) && oldState.fileInfos.has(path); })) {
84891                 state.changedFilesSet.set(sourceFilePath, true);
84892             }
84893             else if (canCopySemanticDiagnostics) {
84894                 var sourceFile = newProgram.getSourceFileByPath(sourceFilePath);
84895                 if (sourceFile.isDeclarationFile && !copyDeclarationFileDiagnostics) {
84896                     return;
84897                 }
84898                 if (sourceFile.hasNoDefaultLib && !copyLibFileDiagnostics) {
84899                     return;
84900                 }
84901                 var diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath);
84902                 if (diagnostics) {
84903                     state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) : diagnostics);
84904                     if (!state.semanticDiagnosticsFromOldState) {
84905                         state.semanticDiagnosticsFromOldState = ts.createMap();
84906                     }
84907                     state.semanticDiagnosticsFromOldState.set(sourceFilePath, true);
84908                 }
84909             }
84910         });
84911         if (useOldState && ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) { return info.affectsGlobalScope && !state.fileInfos.has(sourceFilePath); })) {
84912             ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, undefined)
84913                 .forEach(function (file) { return state.changedFilesSet.set(file.resolvedPath, true); });
84914         }
84915         else if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
84916             newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1); });
84917             ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
84918             state.seenAffectedFiles = state.seenAffectedFiles || ts.createMap();
84919         }
84920         state.emittedBuildInfo = !state.changedFilesSet.size && !state.affectedFilesPendingEmit;
84921         return state;
84922     }
84923     function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
84924         if (!diagnostics.length)
84925             return ts.emptyArray;
84926         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory()));
84927         return diagnostics.map(function (diagnostic) {
84928             var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath);
84929             result.reportsUnnecessary = diagnostic.reportsUnnecessary;
84930             result.source = diagnostic.source;
84931             var relatedInformation = diagnostic.relatedInformation;
84932             result.relatedInformation = relatedInformation ?
84933                 relatedInformation.length ?
84934                     relatedInformation.map(function (r) { return convertToDiagnosticRelatedInformation(r, newProgram, toPath); }) :
84935                     ts.emptyArray :
84936                 undefined;
84937             return result;
84938         });
84939         function toPath(path) {
84940             return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
84941         }
84942     }
84943     function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) {
84944         var file = diagnostic.file;
84945         return __assign(__assign({}, diagnostic), { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined });
84946     }
84947     function releaseCache(state) {
84948         ts.BuilderState.releaseCache(state);
84949         state.program = undefined;
84950     }
84951     function cloneBuilderProgramState(state) {
84952         var newState = ts.BuilderState.clone(state);
84953         newState.semanticDiagnosticsPerFile = ts.cloneMapOrUndefined(state.semanticDiagnosticsPerFile);
84954         newState.changedFilesSet = ts.cloneMap(state.changedFilesSet);
84955         newState.affectedFiles = state.affectedFiles;
84956         newState.affectedFilesIndex = state.affectedFilesIndex;
84957         newState.currentChangedFilePath = state.currentChangedFilePath;
84958         newState.currentAffectedFilesSignatures = ts.cloneMapOrUndefined(state.currentAffectedFilesSignatures);
84959         newState.currentAffectedFilesExportedModulesMap = ts.cloneMapOrUndefined(state.currentAffectedFilesExportedModulesMap);
84960         newState.seenAffectedFiles = ts.cloneMapOrUndefined(state.seenAffectedFiles);
84961         newState.cleanedDiagnosticsOfLibFiles = state.cleanedDiagnosticsOfLibFiles;
84962         newState.semanticDiagnosticsFromOldState = ts.cloneMapOrUndefined(state.semanticDiagnosticsFromOldState);
84963         newState.program = state.program;
84964         newState.compilerOptions = state.compilerOptions;
84965         newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
84966         newState.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(state.affectedFilesPendingEmitKind);
84967         newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
84968         newState.seenEmittedFiles = ts.cloneMapOrUndefined(state.seenEmittedFiles);
84969         newState.programEmitComplete = state.programEmitComplete;
84970         return newState;
84971     }
84972     function assertSourceFileOkWithoutNextAffectedCall(state, sourceFile) {
84973         ts.Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[state.affectedFilesIndex - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath));
84974     }
84975     function getNextAffectedFile(state, cancellationToken, computeHash) {
84976         while (true) {
84977             var affectedFiles = state.affectedFiles;
84978             if (affectedFiles) {
84979                 var seenAffectedFiles = state.seenAffectedFiles;
84980                 var affectedFilesIndex = state.affectedFilesIndex;
84981                 while (affectedFilesIndex < affectedFiles.length) {
84982                     var affectedFile = affectedFiles[affectedFilesIndex];
84983                     if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
84984                         state.affectedFilesIndex = affectedFilesIndex;
84985                         handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash);
84986                         return affectedFile;
84987                     }
84988                     affectedFilesIndex++;
84989                 }
84990                 state.changedFilesSet.delete(state.currentChangedFilePath);
84991                 state.currentChangedFilePath = undefined;
84992                 ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures);
84993                 state.currentAffectedFilesSignatures.clear();
84994                 ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
84995                 state.affectedFiles = undefined;
84996             }
84997             var nextKey = state.changedFilesSet.keys().next();
84998             if (nextKey.done) {
84999                 return undefined;
85000             }
85001             var program = ts.Debug.checkDefined(state.program);
85002             var compilerOptions = program.getCompilerOptions();
85003             if (compilerOptions.outFile || compilerOptions.out) {
85004                 ts.Debug.assert(!state.semanticDiagnosticsPerFile);
85005                 return program;
85006             }
85007             state.currentAffectedFilesSignatures = state.currentAffectedFilesSignatures || ts.createMap();
85008             if (state.exportedModulesMap) {
85009                 state.currentAffectedFilesExportedModulesMap = state.currentAffectedFilesExportedModulesMap || ts.createMap();
85010             }
85011             state.affectedFiles = ts.BuilderState.getFilesAffectedBy(state, program, nextKey.value, cancellationToken, computeHash, state.currentAffectedFilesSignatures, state.currentAffectedFilesExportedModulesMap);
85012             state.currentChangedFilePath = nextKey.value;
85013             state.affectedFilesIndex = 0;
85014             state.seenAffectedFiles = state.seenAffectedFiles || ts.createMap();
85015         }
85016     }
85017     function getNextAffectedFilePendingEmit(state) {
85018         var affectedFilesPendingEmit = state.affectedFilesPendingEmit;
85019         if (affectedFilesPendingEmit) {
85020             var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap());
85021             for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) {
85022                 var affectedFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]);
85023                 if (affectedFile) {
85024                     var seenKind = seenEmittedFiles.get(affectedFile.resolvedPath);
85025                     var emitKind = ts.Debug.checkDefined(ts.Debug.checkDefined(state.affectedFilesPendingEmitKind).get(affectedFile.resolvedPath));
85026                     if (seenKind === undefined || seenKind < emitKind) {
85027                         state.affectedFilesPendingEmitIndex = i;
85028                         return { affectedFile: affectedFile, emitKind: emitKind };
85029                     }
85030                 }
85031             }
85032             state.affectedFilesPendingEmit = undefined;
85033             state.affectedFilesPendingEmitKind = undefined;
85034             state.affectedFilesPendingEmitIndex = undefined;
85035         }
85036         return undefined;
85037     }
85038     function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) {
85039         removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
85040         if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
85041             if (!state.cleanedDiagnosticsOfLibFiles) {
85042                 state.cleanedDiagnosticsOfLibFiles = true;
85043                 var program_1 = ts.Debug.checkDefined(state.program);
85044                 var options_2 = program_1.getCompilerOptions();
85045                 ts.forEach(program_1.getSourceFiles(), function (f) {
85046                     return program_1.isSourceFileDefaultLibrary(f) &&
85047                         !ts.skipTypeChecking(f, options_2, program_1) &&
85048                         removeSemanticDiagnosticsOf(state, f.resolvedPath);
85049                 });
85050             }
85051             return;
85052         }
85053         if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
85054             forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); });
85055         }
85056     }
85057     function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) {
85058         removeSemanticDiagnosticsOf(state, path);
85059         if (!state.changedFilesSet.has(path)) {
85060             var program = ts.Debug.checkDefined(state.program);
85061             var sourceFile = program.getSourceFileByPath(path);
85062             if (sourceFile) {
85063                 ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
85064                 if (ts.getEmitDeclarations(state.compilerOptions)) {
85065                     addToAffectedFilesPendingEmit(state, path, 0);
85066                 }
85067             }
85068         }
85069         return false;
85070     }
85071     function removeSemanticDiagnosticsOf(state, path) {
85072         if (!state.semanticDiagnosticsFromOldState) {
85073             return true;
85074         }
85075         state.semanticDiagnosticsFromOldState.delete(path);
85076         state.semanticDiagnosticsPerFile.delete(path);
85077         return !state.semanticDiagnosticsFromOldState.size;
85078     }
85079     function isChangedSignagure(state, path) {
85080         var newSignature = ts.Debug.checkDefined(state.currentAffectedFilesSignatures).get(path);
85081         var oldSignagure = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
85082         return newSignature !== oldSignagure;
85083     }
85084     function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) {
85085         if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) {
85086             return;
85087         }
85088         if (!isChangedSignagure(state, affectedFile.resolvedPath))
85089             return;
85090         if (state.compilerOptions.isolatedModules) {
85091             var seenFileNamesMap = ts.createMap();
85092             seenFileNamesMap.set(affectedFile.resolvedPath, true);
85093             var queue = ts.BuilderState.getReferencedByPaths(state, affectedFile.resolvedPath);
85094             while (queue.length > 0) {
85095                 var currentPath = queue.pop();
85096                 if (!seenFileNamesMap.has(currentPath)) {
85097                     seenFileNamesMap.set(currentPath, true);
85098                     var result = fn(state, currentPath);
85099                     if (result && isChangedSignagure(state, currentPath)) {
85100                         var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
85101                         queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
85102                     }
85103                 }
85104             }
85105         }
85106         ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
85107         var seenFileAndExportsOfFile = ts.createMap();
85108         if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) {
85109             return exportedModules &&
85110                 exportedModules.has(affectedFile.resolvedPath) &&
85111                 forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
85112         })) {
85113             return;
85114         }
85115         ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) {
85116             return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) &&
85117                 exportedModules.has(affectedFile.resolvedPath) &&
85118                 forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
85119         });
85120     }
85121     function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) {
85122         return ts.forEachEntry(state.referencedMap, function (referencesInFile, filePath) {
85123             return referencesInFile.has(referencedPath) && forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn);
85124         });
85125     }
85126     function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) {
85127         if (!ts.addToSeen(seenFileAndExportsOfFile, filePath)) {
85128             return false;
85129         }
85130         if (fn(state, filePath)) {
85131             return true;
85132         }
85133         ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
85134         if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) {
85135             return exportedModules &&
85136                 exportedModules.has(filePath) &&
85137                 forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
85138         })) {
85139             return true;
85140         }
85141         if (ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) {
85142             return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) &&
85143                 exportedModules.has(filePath) &&
85144                 forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
85145         })) {
85146             return true;
85147         }
85148         return !!ts.forEachEntry(state.referencedMap, function (referencesInFile, referencingFilePath) {
85149             return referencesInFile.has(filePath) &&
85150                 !seenFileAndExportsOfFile.has(referencingFilePath) &&
85151                 fn(state, referencingFilePath);
85152         });
85153     }
85154     function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) {
85155         if (isBuildInfoEmit) {
85156             state.emittedBuildInfo = true;
85157         }
85158         else if (affected === state.program) {
85159             state.changedFilesSet.clear();
85160             state.programEmitComplete = true;
85161         }
85162         else {
85163             state.seenAffectedFiles.set(affected.resolvedPath, true);
85164             if (emitKind !== undefined) {
85165                 (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.resolvedPath, emitKind);
85166             }
85167             if (isPendingEmit) {
85168                 state.affectedFilesPendingEmitIndex++;
85169             }
85170             else {
85171                 state.affectedFilesIndex++;
85172             }
85173         }
85174     }
85175     function toAffectedFileResult(state, result, affected) {
85176         doneWithAffectedFile(state, affected);
85177         return { result: result, affected: affected };
85178     }
85179     function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) {
85180         doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit);
85181         return { result: result, affected: affected };
85182     }
85183     function getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken) {
85184         return ts.concatenate(getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken), ts.Debug.checkDefined(state.program).getProgramDiagnostics(sourceFile));
85185     }
85186     function getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken) {
85187         var path = sourceFile.resolvedPath;
85188         if (state.semanticDiagnosticsPerFile) {
85189             var cachedDiagnostics = state.semanticDiagnosticsPerFile.get(path);
85190             if (cachedDiagnostics) {
85191                 return cachedDiagnostics;
85192             }
85193         }
85194         var diagnostics = ts.Debug.checkDefined(state.program).getBindAndCheckDiagnostics(sourceFile, cancellationToken);
85195         if (state.semanticDiagnosticsPerFile) {
85196             state.semanticDiagnosticsPerFile.set(path, diagnostics);
85197         }
85198         return diagnostics;
85199     }
85200     function getProgramBuildInfo(state, getCanonicalFileName) {
85201         if (state.compilerOptions.outFile || state.compilerOptions.out)
85202             return undefined;
85203         var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
85204         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
85205         var fileInfos = {};
85206         state.fileInfos.forEach(function (value, key) {
85207             var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
85208             fileInfos[relativeToBuildInfo(key)] = signature === undefined ? value : { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope };
85209         });
85210         var result = {
85211             fileInfos: fileInfos,
85212             options: convertToReusableCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath)
85213         };
85214         if (state.referencedMap) {
85215             var referencedMap = {};
85216             for (var _i = 0, _a = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
85217                 var key = _a[_i];
85218                 referencedMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.referencedMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
85219             }
85220             result.referencedMap = referencedMap;
85221         }
85222         if (state.exportedModulesMap) {
85223             var exportedModulesMap = {};
85224             for (var _b = 0, _c = ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) {
85225                 var key = _c[_b];
85226                 var newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key);
85227                 if (newValue === undefined)
85228                     exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.exportedModulesMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
85229                 else if (newValue)
85230                     exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(newValue.keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
85231             }
85232             result.exportedModulesMap = exportedModulesMap;
85233         }
85234         if (state.semanticDiagnosticsPerFile) {
85235             var semanticDiagnosticsPerFile = [];
85236             for (var _d = 0, _e = ts.arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) {
85237                 var key = _e[_d];
85238                 var value = state.semanticDiagnosticsPerFile.get(key);
85239                 semanticDiagnosticsPerFile.push(value.length ?
85240                     [
85241                         relativeToBuildInfo(key),
85242                         state.hasReusableDiagnostic ?
85243                             value :
85244                             convertToReusableDiagnostics(value, relativeToBuildInfo)
85245                     ] :
85246                     relativeToBuildInfo(key));
85247             }
85248             result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile;
85249         }
85250         return result;
85251         function relativeToBuildInfoEnsuringAbsolutePath(path) {
85252             return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory));
85253         }
85254         function relativeToBuildInfo(path) {
85255             return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, getCanonicalFileName));
85256         }
85257     }
85258     function convertToReusableCompilerOptions(options, relativeToBuildInfo) {
85259         var result = {};
85260         var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
85261         for (var name in options) {
85262             if (ts.hasProperty(options, name)) {
85263                 result[name] = convertToReusableCompilerOptionValue(optionsNameMap.get(name.toLowerCase()), options[name], relativeToBuildInfo);
85264             }
85265         }
85266         if (result.configFilePath) {
85267             result.configFilePath = relativeToBuildInfo(result.configFilePath);
85268         }
85269         return result;
85270     }
85271     function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
85272         if (option) {
85273             if (option.type === "list") {
85274                 var values = value;
85275                 if (option.element.isFilePath && values.length) {
85276                     return values.map(relativeToBuildInfo);
85277                 }
85278             }
85279             else if (option.isFilePath) {
85280                 return relativeToBuildInfo(value);
85281             }
85282         }
85283         return value;
85284     }
85285     function convertToReusableDiagnostics(diagnostics, relativeToBuildInfo) {
85286         ts.Debug.assert(!!diagnostics.length);
85287         return diagnostics.map(function (diagnostic) {
85288             var result = convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo);
85289             result.reportsUnnecessary = diagnostic.reportsUnnecessary;
85290             result.source = diagnostic.source;
85291             var relatedInformation = diagnostic.relatedInformation;
85292             result.relatedInformation = relatedInformation ?
85293                 relatedInformation.length ?
85294                     relatedInformation.map(function (r) { return convertToReusableDiagnosticRelatedInformation(r, relativeToBuildInfo); }) :
85295                     ts.emptyArray :
85296                 undefined;
85297             return result;
85298         });
85299     }
85300     function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) {
85301         var file = diagnostic.file;
85302         return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.resolvedPath) : undefined });
85303     }
85304     var BuilderProgramKind;
85305     (function (BuilderProgramKind) {
85306         BuilderProgramKind[BuilderProgramKind["SemanticDiagnosticsBuilderProgram"] = 0] = "SemanticDiagnosticsBuilderProgram";
85307         BuilderProgramKind[BuilderProgramKind["EmitAndSemanticDiagnosticsBuilderProgram"] = 1] = "EmitAndSemanticDiagnosticsBuilderProgram";
85308     })(BuilderProgramKind = ts.BuilderProgramKind || (ts.BuilderProgramKind = {}));
85309     function getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
85310         var host;
85311         var newProgram;
85312         var oldProgram;
85313         if (newProgramOrRootNames === undefined) {
85314             ts.Debug.assert(hostOrOptions === undefined);
85315             host = oldProgramOrHost;
85316             oldProgram = configFileParsingDiagnosticsOrOldProgram;
85317             ts.Debug.assert(!!oldProgram);
85318             newProgram = oldProgram.getProgram();
85319         }
85320         else if (ts.isArray(newProgramOrRootNames)) {
85321             oldProgram = configFileParsingDiagnosticsOrOldProgram;
85322             newProgram = ts.createProgram({
85323                 rootNames: newProgramOrRootNames,
85324                 options: hostOrOptions,
85325                 host: oldProgramOrHost,
85326                 oldProgram: oldProgram && oldProgram.getProgramOrUndefined(),
85327                 configFileParsingDiagnostics: configFileParsingDiagnostics,
85328                 projectReferences: projectReferences
85329             });
85330             host = oldProgramOrHost;
85331         }
85332         else {
85333             newProgram = newProgramOrRootNames;
85334             host = hostOrOptions;
85335             oldProgram = oldProgramOrHost;
85336             configFileParsingDiagnostics = configFileParsingDiagnosticsOrOldProgram;
85337         }
85338         return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray };
85339     }
85340     ts.getBuilderCreationParameters = getBuilderCreationParameters;
85341     function createBuilderProgram(kind, _a) {
85342         var newProgram = _a.newProgram, host = _a.host, oldProgram = _a.oldProgram, configFileParsingDiagnostics = _a.configFileParsingDiagnostics;
85343         var oldState = oldProgram && oldProgram.getState();
85344         if (oldState && newProgram === oldState.program && configFileParsingDiagnostics === newProgram.getConfigFileParsingDiagnostics()) {
85345             newProgram = undefined;
85346             oldState = undefined;
85347             return oldProgram;
85348         }
85349         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
85350         var computeHash = host.createHash || ts.generateDjb2Hash;
85351         var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState);
85352         var backupState;
85353         newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
85354         newProgram = undefined;
85355         oldProgram = undefined;
85356         oldState = undefined;
85357         var builderProgram = createRedirectedBuilderProgram(state, configFileParsingDiagnostics);
85358         builderProgram.getState = function () { return state; };
85359         builderProgram.backupState = function () {
85360             ts.Debug.assert(backupState === undefined);
85361             backupState = cloneBuilderProgramState(state);
85362         };
85363         builderProgram.restoreState = function () {
85364             state = ts.Debug.checkDefined(backupState);
85365             backupState = undefined;
85366         };
85367         builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); };
85368         builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
85369         builderProgram.emit = emit;
85370         builderProgram.releaseProgram = function () {
85371             releaseCache(state);
85372             backupState = undefined;
85373         };
85374         if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
85375             builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
85376         }
85377         else if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
85378             builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
85379             builderProgram.emitNextAffectedFile = emitNextAffectedFile;
85380         }
85381         else {
85382             ts.notImplemented();
85383         }
85384         return builderProgram;
85385         function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
85386             var affected = getNextAffectedFile(state, cancellationToken, computeHash);
85387             var emitKind = 1;
85388             var isPendingEmitFile = false;
85389             if (!affected) {
85390                 if (!state.compilerOptions.out && !state.compilerOptions.outFile) {
85391                     var pendingAffectedFile = getNextAffectedFilePendingEmit(state);
85392                     if (!pendingAffectedFile) {
85393                         if (state.emittedBuildInfo) {
85394                             return undefined;
85395                         }
85396                         var affected_1 = ts.Debug.checkDefined(state.program);
85397                         return toAffectedFileEmitResult(state, affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1, false, true);
85398                     }
85399                     (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind);
85400                     isPendingEmitFile = true;
85401                 }
85402                 else {
85403                     var program = ts.Debug.checkDefined(state.program);
85404                     if (state.programEmitComplete)
85405                         return undefined;
85406                     affected = program;
85407                 }
85408             }
85409             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);
85410         }
85411         function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
85412             if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
85413                 assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile);
85414                 var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, cancellationToken);
85415                 if (result)
85416                     return result;
85417                 if (!targetSourceFile) {
85418                     var sourceMaps = [];
85419                     var emitSkipped = false;
85420                     var diagnostics = void 0;
85421                     var emittedFiles = [];
85422                     var affectedEmitResult = void 0;
85423                     while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
85424                         emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
85425                         diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
85426                         emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
85427                         sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
85428                     }
85429                     return {
85430                         emitSkipped: emitSkipped,
85431                         diagnostics: diagnostics || ts.emptyArray,
85432                         emittedFiles: emittedFiles,
85433                         sourceMaps: sourceMaps
85434                     };
85435                 }
85436             }
85437             return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
85438         }
85439         function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
85440             while (true) {
85441                 var affected = getNextAffectedFile(state, cancellationToken, computeHash);
85442                 if (!affected) {
85443                     return undefined;
85444                 }
85445                 else if (affected === state.program) {
85446                     return toAffectedFileResult(state, state.program.getSemanticDiagnostics(undefined, cancellationToken), affected);
85447                 }
85448                 if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
85449                     addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1);
85450                 }
85451                 if (ignoreSourceFile && ignoreSourceFile(affected)) {
85452                     doneWithAffectedFile(state, affected);
85453                     continue;
85454                 }
85455                 return toAffectedFileResult(state, getSemanticDiagnosticsOfFile(state, affected, cancellationToken), affected);
85456             }
85457         }
85458         function getSemanticDiagnostics(sourceFile, cancellationToken) {
85459             assertSourceFileOkWithoutNextAffectedCall(state, sourceFile);
85460             var compilerOptions = ts.Debug.checkDefined(state.program).getCompilerOptions();
85461             if (compilerOptions.outFile || compilerOptions.out) {
85462                 ts.Debug.assert(!state.semanticDiagnosticsPerFile);
85463                 return ts.Debug.checkDefined(state.program).getSemanticDiagnostics(sourceFile, cancellationToken);
85464             }
85465             if (sourceFile) {
85466                 return getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken);
85467             }
85468             while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) {
85469             }
85470             var diagnostics;
85471             for (var _i = 0, _a = ts.Debug.checkDefined(state.program).getSourceFiles(); _i < _a.length; _i++) {
85472                 var sourceFile_1 = _a[_i];
85473                 diagnostics = ts.addRange(diagnostics, getSemanticDiagnosticsOfFile(state, sourceFile_1, cancellationToken));
85474             }
85475             return diagnostics || ts.emptyArray;
85476         }
85477     }
85478     ts.createBuilderProgram = createBuilderProgram;
85479     function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) {
85480         if (!state.affectedFilesPendingEmit)
85481             state.affectedFilesPendingEmit = [];
85482         if (!state.affectedFilesPendingEmitKind)
85483             state.affectedFilesPendingEmitKind = ts.createMap();
85484         var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit);
85485         state.affectedFilesPendingEmit.push(affectedFilePendingEmit);
85486         state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind);
85487         if (state.affectedFilesPendingEmitIndex === undefined) {
85488             state.affectedFilesPendingEmitIndex = 0;
85489         }
85490     }
85491     function getMapOfReferencedSet(mapLike, toPath) {
85492         if (!mapLike)
85493             return undefined;
85494         var map = ts.createMap();
85495         for (var key in mapLike) {
85496             if (ts.hasProperty(mapLike, key)) {
85497                 map.set(toPath(key), ts.arrayToSet(mapLike[key], toPath));
85498             }
85499         }
85500         return map;
85501     }
85502     function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
85503         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
85504         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
85505         var fileInfos = ts.createMap();
85506         for (var key in program.fileInfos) {
85507             if (ts.hasProperty(program.fileInfos, key)) {
85508                 fileInfos.set(toPath(key), program.fileInfos[key]);
85509             }
85510         }
85511         var state = {
85512             fileInfos: fileInfos,
85513             compilerOptions: ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath),
85514             referencedMap: getMapOfReferencedSet(program.referencedMap, toPath),
85515             exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath),
85516             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]; }),
85517             hasReusableDiagnostic: true
85518         };
85519         return {
85520             getState: function () { return state; },
85521             backupState: ts.noop,
85522             restoreState: ts.noop,
85523             getProgram: ts.notImplemented,
85524             getProgramOrUndefined: ts.returnUndefined,
85525             releaseProgram: ts.noop,
85526             getCompilerOptions: function () { return state.compilerOptions; },
85527             getSourceFile: ts.notImplemented,
85528             getSourceFiles: ts.notImplemented,
85529             getOptionsDiagnostics: ts.notImplemented,
85530             getGlobalDiagnostics: ts.notImplemented,
85531             getConfigFileParsingDiagnostics: ts.notImplemented,
85532             getSyntacticDiagnostics: ts.notImplemented,
85533             getDeclarationDiagnostics: ts.notImplemented,
85534             getSemanticDiagnostics: ts.notImplemented,
85535             emit: ts.notImplemented,
85536             getAllDependencies: ts.notImplemented,
85537             getCurrentDirectory: ts.notImplemented,
85538             emitNextAffectedFile: ts.notImplemented,
85539             getSemanticDiagnosticsOfNextAffectedFile: ts.notImplemented,
85540             close: ts.noop,
85541         };
85542         function toPath(path) {
85543             return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
85544         }
85545         function toAbsolutePath(path) {
85546             return ts.getNormalizedAbsolutePath(path, buildInfoDirectory);
85547         }
85548     }
85549     ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo;
85550     function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) {
85551         return {
85552             getState: ts.notImplemented,
85553             backupState: ts.noop,
85554             restoreState: ts.noop,
85555             getProgram: getProgram,
85556             getProgramOrUndefined: function () { return state.program; },
85557             releaseProgram: function () { return state.program = undefined; },
85558             getCompilerOptions: function () { return state.compilerOptions; },
85559             getSourceFile: function (fileName) { return getProgram().getSourceFile(fileName); },
85560             getSourceFiles: function () { return getProgram().getSourceFiles(); },
85561             getOptionsDiagnostics: function (cancellationToken) { return getProgram().getOptionsDiagnostics(cancellationToken); },
85562             getGlobalDiagnostics: function (cancellationToken) { return getProgram().getGlobalDiagnostics(cancellationToken); },
85563             getConfigFileParsingDiagnostics: function () { return configFileParsingDiagnostics; },
85564             getSyntacticDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getSyntacticDiagnostics(sourceFile, cancellationToken); },
85565             getDeclarationDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getDeclarationDiagnostics(sourceFile, cancellationToken); },
85566             getSemanticDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getSemanticDiagnostics(sourceFile, cancellationToken); },
85567             emit: function (sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers) { return getProgram().emit(sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers); },
85568             getAllDependencies: ts.notImplemented,
85569             getCurrentDirectory: function () { return getProgram().getCurrentDirectory(); },
85570             close: ts.noop,
85571         };
85572         function getProgram() {
85573             return ts.Debug.checkDefined(state.program);
85574         }
85575     }
85576     ts.createRedirectedBuilderProgram = createRedirectedBuilderProgram;
85577 })(ts || (ts = {}));
85578 var ts;
85579 (function (ts) {
85580     function createSemanticDiagnosticsBuilderProgram(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
85581         return ts.createBuilderProgram(ts.BuilderProgramKind.SemanticDiagnosticsBuilderProgram, ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
85582     }
85583     ts.createSemanticDiagnosticsBuilderProgram = createSemanticDiagnosticsBuilderProgram;
85584     function createEmitAndSemanticDiagnosticsBuilderProgram(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
85585         return ts.createBuilderProgram(ts.BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram, ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
85586     }
85587     ts.createEmitAndSemanticDiagnosticsBuilderProgram = createEmitAndSemanticDiagnosticsBuilderProgram;
85588     function createAbstractBuilder(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
85589         var _a = ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences), newProgram = _a.newProgram, newConfigFileParsingDiagnostics = _a.configFileParsingDiagnostics;
85590         return ts.createRedirectedBuilderProgram({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }, newConfigFileParsingDiagnostics);
85591     }
85592     ts.createAbstractBuilder = createAbstractBuilder;
85593 })(ts || (ts = {}));
85594 var ts;
85595 (function (ts) {
85596     function removeIgnoredPath(path) {
85597         if (ts.endsWith(path, "/node_modules/.staging")) {
85598             return ts.removeSuffix(path, "/.staging");
85599         }
85600         return ts.some(ts.ignoredPaths, function (searchPath) { return ts.stringContains(path, searchPath); }) ?
85601             undefined :
85602             path;
85603     }
85604     ts.removeIgnoredPath = removeIgnoredPath;
85605     function canWatchDirectory(dirPath) {
85606         var rootLength = ts.getRootLength(dirPath);
85607         if (dirPath.length === rootLength) {
85608             return false;
85609         }
85610         var nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, rootLength);
85611         if (nextDirectorySeparator === -1) {
85612             return false;
85613         }
85614         var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1);
85615         var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47;
85616         if (isNonDirectorySeparatorRoot &&
85617             dirPath.search(/[a-zA-Z]:/) !== 0 &&
85618             pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) {
85619             nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1);
85620             if (nextDirectorySeparator === -1) {
85621                 return false;
85622             }
85623             pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1);
85624         }
85625         if (isNonDirectorySeparatorRoot &&
85626             pathPartForUserCheck.search(/users\//i) !== 0) {
85627             return true;
85628         }
85629         for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) {
85630             searchIndex = dirPath.indexOf(ts.directorySeparator, searchIndex) + 1;
85631             if (searchIndex === 0) {
85632                 return false;
85633             }
85634         }
85635         return true;
85636     }
85637     ts.canWatchDirectory = canWatchDirectory;
85638     function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
85639         var filesWithChangedSetOfUnresolvedImports;
85640         var filesWithInvalidatedResolutions;
85641         var filesWithInvalidatedNonRelativeUnresolvedImports;
85642         var nonRelativeExternalModuleResolutions = ts.createMultiMap();
85643         var resolutionsWithFailedLookups = [];
85644         var resolvedFileToResolution = ts.createMultiMap();
85645         var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); });
85646         var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost();
85647         var resolvedModuleNames = ts.createMap();
85648         var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects();
85649         var nonRelativeModuleNameCache = ts.createCacheWithRedirects();
85650         var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelativeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName);
85651         var resolvedTypeReferenceDirectives = ts.createMap();
85652         var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects();
85653         var failedLookupDefaultExtensions = [".ts", ".tsx", ".js", ".jsx", ".json"];
85654         var customFailedLookupPaths = ts.createMap();
85655         var directoryWatchesOfFailedLookups = ts.createMap();
85656         var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
85657         var rootPath = (rootDir && resolutionHost.toPath(rootDir));
85658         var rootSplitLength = rootPath !== undefined ? rootPath.split(ts.directorySeparator).length : 0;
85659         var typeRootsWatches = ts.createMap();
85660         return {
85661             startRecordingFilesWithChangedResolutions: startRecordingFilesWithChangedResolutions,
85662             finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions,
85663             startCachingPerDirectoryResolution: clearPerDirectoryResolutions,
85664             finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution,
85665             resolveModuleNames: resolveModuleNames,
85666             getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
85667             resolveTypeReferenceDirectives: resolveTypeReferenceDirectives,
85668             removeResolutionsFromProjectReferenceRedirects: removeResolutionsFromProjectReferenceRedirects,
85669             removeResolutionsOfFile: removeResolutionsOfFile,
85670             invalidateResolutionOfFile: invalidateResolutionOfFile,
85671             setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports,
85672             createHasInvalidatedResolution: createHasInvalidatedResolution,
85673             updateTypeRootsWatch: updateTypeRootsWatch,
85674             closeTypeRootsWatch: closeTypeRootsWatch,
85675             clear: clear
85676         };
85677         function getResolvedModule(resolution) {
85678             return resolution.resolvedModule;
85679         }
85680         function getResolvedTypeReferenceDirective(resolution) {
85681             return resolution.resolvedTypeReferenceDirective;
85682         }
85683         function isInDirectoryPath(dir, file) {
85684             if (dir === undefined || file.length <= dir.length) {
85685                 return false;
85686             }
85687             return ts.startsWith(file, dir) && file[dir.length] === ts.directorySeparator;
85688         }
85689         function clear() {
85690             ts.clearMap(directoryWatchesOfFailedLookups, ts.closeFileWatcherOf);
85691             customFailedLookupPaths.clear();
85692             nonRelativeExternalModuleResolutions.clear();
85693             closeTypeRootsWatch();
85694             resolvedModuleNames.clear();
85695             resolvedTypeReferenceDirectives.clear();
85696             resolvedFileToResolution.clear();
85697             resolutionsWithFailedLookups.length = 0;
85698             clearPerDirectoryResolutions();
85699         }
85700         function startRecordingFilesWithChangedResolutions() {
85701             filesWithChangedSetOfUnresolvedImports = [];
85702         }
85703         function finishRecordingFilesWithChangedResolutions() {
85704             var collected = filesWithChangedSetOfUnresolvedImports;
85705             filesWithChangedSetOfUnresolvedImports = undefined;
85706             return collected;
85707         }
85708         function isFileWithInvalidatedNonRelativeUnresolvedImports(path) {
85709             if (!filesWithInvalidatedNonRelativeUnresolvedImports) {
85710                 return false;
85711             }
85712             var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
85713             return !!value && !!value.length;
85714         }
85715         function createHasInvalidatedResolution(forceAllFilesAsInvalidated) {
85716             if (forceAllFilesAsInvalidated) {
85717                 filesWithInvalidatedResolutions = undefined;
85718                 return ts.returnTrue;
85719             }
85720             var collected = filesWithInvalidatedResolutions;
85721             filesWithInvalidatedResolutions = undefined;
85722             return function (path) { return (!!collected && collected.has(path)) ||
85723                 isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
85724         }
85725         function clearPerDirectoryResolutions() {
85726             perDirectoryResolvedModuleNames.clear();
85727             nonRelativeModuleNameCache.clear();
85728             perDirectoryResolvedTypeReferenceDirectives.clear();
85729             nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
85730             nonRelativeExternalModuleResolutions.clear();
85731         }
85732         function finishCachingPerDirectoryResolution() {
85733             filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
85734             clearPerDirectoryResolutions();
85735             directoryWatchesOfFailedLookups.forEach(function (watcher, path) {
85736                 if (watcher.refCount === 0) {
85737                     directoryWatchesOfFailedLookups.delete(path);
85738                     watcher.watcher.close();
85739                 }
85740             });
85741         }
85742         function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) {
85743             var _a;
85744             var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference);
85745             if (!resolutionHost.getGlobalCache) {
85746                 return primaryResult;
85747             }
85748             var globalCache = resolutionHost.getGlobalCache();
85749             if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) {
85750                 var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations;
85751                 if (resolvedModule) {
85752                     primaryResult.resolvedModule = resolvedModule;
85753                     (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
85754                     return primaryResult;
85755                 }
85756             }
85757             return primaryResult;
85758         }
85759         function resolveNamesWithLocalCache(_a) {
85760             var _b;
85761             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;
85762             var path = resolutionHost.toPath(containingFile);
85763             var resolutionsInFile = cache.get(path) || cache.set(path, ts.createMap()).get(path);
85764             var dirPath = ts.getDirectoryPath(path);
85765             var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
85766             var perDirectoryResolution = perDirectoryCache.get(dirPath);
85767             if (!perDirectoryResolution) {
85768                 perDirectoryResolution = ts.createMap();
85769                 perDirectoryCache.set(dirPath, perDirectoryResolution);
85770             }
85771             var resolvedModules = [];
85772             var compilerOptions = resolutionHost.getCompilationSettings();
85773             var hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
85774             var program = resolutionHost.getCurrentProgram();
85775             var oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile);
85776             var unmatchedRedirects = oldRedirect ?
85777                 !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path :
85778                 !!redirectedReference;
85779             var seenNamesInFile = ts.createMap();
85780             for (var _i = 0, names_3 = names; _i < names_3.length; _i++) {
85781                 var name = names_3[_i];
85782                 var resolution = resolutionsInFile.get(name);
85783                 if (!seenNamesInFile.has(name) &&
85784                     unmatchedRedirects || !resolution || resolution.isInvalidated ||
85785                     (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
85786                     var existingResolution = resolution;
85787                     var resolutionInDirectory = perDirectoryResolution.get(name);
85788                     if (resolutionInDirectory) {
85789                         resolution = resolutionInDirectory;
85790                     }
85791                     else {
85792                         resolution = loader(name, containingFile, compilerOptions, ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost, redirectedReference);
85793                         perDirectoryResolution.set(name, resolution);
85794                     }
85795                     resolutionsInFile.set(name, resolution);
85796                     watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
85797                     if (existingResolution) {
85798                         stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
85799                     }
85800                     if (logChanges && filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) {
85801                         filesWithChangedSetOfUnresolvedImports.push(path);
85802                         logChanges = false;
85803                     }
85804                 }
85805                 ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated);
85806                 seenNamesInFile.set(name, true);
85807                 resolvedModules.push(getResolutionWithResolvedFileName(resolution));
85808             }
85809             resolutionsInFile.forEach(function (resolution, name) {
85810                 if (!seenNamesInFile.has(name) && !ts.contains(reusedNames, name)) {
85811                     stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
85812                     resolutionsInFile.delete(name);
85813                 }
85814             });
85815             return resolvedModules;
85816             function resolutionIsEqualTo(oldResolution, newResolution) {
85817                 if (oldResolution === newResolution) {
85818                     return true;
85819                 }
85820                 if (!oldResolution || !newResolution) {
85821                     return false;
85822                 }
85823                 var oldResult = getResolutionWithResolvedFileName(oldResolution);
85824                 var newResult = getResolutionWithResolvedFileName(newResolution);
85825                 if (oldResult === newResult) {
85826                     return true;
85827                 }
85828                 if (!oldResult || !newResult) {
85829                     return false;
85830                 }
85831                 return oldResult.resolvedFileName === newResult.resolvedFileName;
85832             }
85833         }
85834         function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) {
85835             return resolveNamesWithLocalCache({
85836                 names: typeDirectiveNames,
85837                 containingFile: containingFile,
85838                 redirectedReference: redirectedReference,
85839                 cache: resolvedTypeReferenceDirectives,
85840                 perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives,
85841                 loader: ts.resolveTypeReferenceDirective,
85842                 getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
85843                 shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
85844             });
85845         }
85846         function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference) {
85847             return resolveNamesWithLocalCache({
85848                 names: moduleNames,
85849                 containingFile: containingFile,
85850                 redirectedReference: redirectedReference,
85851                 cache: resolvedModuleNames,
85852                 perDirectoryCacheWithRedirects: perDirectoryResolvedModuleNames,
85853                 loader: resolveModuleName,
85854                 getResolutionWithResolvedFileName: getResolvedModule,
85855                 shouldRetryResolution: function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); },
85856                 reusedNames: reusedNames,
85857                 logChanges: logChangesWhenResolvingModule
85858             });
85859         }
85860         function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) {
85861             var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile));
85862             return cache && cache.get(moduleName);
85863         }
85864         function isNodeModulesAtTypesDirectory(dirPath) {
85865             return ts.endsWith(dirPath, "/node_modules/@types");
85866         }
85867         function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath) {
85868             if (isInDirectoryPath(rootPath, failedLookupLocationPath)) {
85869                 failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
85870                 var failedLookupPathSplit = failedLookupLocationPath.split(ts.directorySeparator);
85871                 var failedLookupSplit = failedLookupLocation.split(ts.directorySeparator);
85872                 ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath);
85873                 if (failedLookupPathSplit.length > rootSplitLength + 1) {
85874                     return {
85875                         dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(ts.directorySeparator),
85876                         dirPath: failedLookupPathSplit.slice(0, rootSplitLength + 1).join(ts.directorySeparator)
85877                     };
85878                 }
85879                 else {
85880                     return {
85881                         dir: rootDir,
85882                         dirPath: rootPath,
85883                         nonRecursive: false
85884                     };
85885                 }
85886             }
85887             return getDirectoryToWatchFromFailedLookupLocationDirectory(ts.getDirectoryPath(ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())), ts.getDirectoryPath(failedLookupLocationPath));
85888         }
85889         function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath) {
85890             while (ts.pathContainsNodeModules(dirPath)) {
85891                 dir = ts.getDirectoryPath(dir);
85892                 dirPath = ts.getDirectoryPath(dirPath);
85893             }
85894             if (ts.isNodeModulesDirectory(dirPath)) {
85895                 return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined;
85896             }
85897             var nonRecursive = true;
85898             var subDirectoryPath, subDirectory;
85899             if (rootPath !== undefined) {
85900                 while (!isInDirectoryPath(dirPath, rootPath)) {
85901                     var parentPath = ts.getDirectoryPath(dirPath);
85902                     if (parentPath === dirPath) {
85903                         break;
85904                     }
85905                     nonRecursive = false;
85906                     subDirectoryPath = dirPath;
85907                     subDirectory = dir;
85908                     dirPath = parentPath;
85909                     dir = ts.getDirectoryPath(dir);
85910                 }
85911             }
85912             return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined;
85913         }
85914         function isPathWithDefaultFailedLookupExtension(path) {
85915             return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
85916         }
85917         function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
85918             if (resolution.refCount) {
85919                 resolution.refCount++;
85920                 ts.Debug.assertDefined(resolution.files);
85921             }
85922             else {
85923                 resolution.refCount = 1;
85924                 ts.Debug.assert(resolution.files === undefined);
85925                 if (ts.isExternalModuleNameRelative(name)) {
85926                     watchFailedLookupLocationOfResolution(resolution);
85927                 }
85928                 else {
85929                     nonRelativeExternalModuleResolutions.add(name, resolution);
85930                 }
85931                 var resolved = getResolutionWithResolvedFileName(resolution);
85932                 if (resolved && resolved.resolvedFileName) {
85933                     resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
85934                 }
85935             }
85936             (resolution.files || (resolution.files = [])).push(filePath);
85937         }
85938         function watchFailedLookupLocationOfResolution(resolution) {
85939             ts.Debug.assert(!!resolution.refCount);
85940             var failedLookupLocations = resolution.failedLookupLocations;
85941             if (!failedLookupLocations.length)
85942                 return;
85943             resolutionsWithFailedLookups.push(resolution);
85944             var setAtRoot = false;
85945             for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) {
85946                 var failedLookupLocation = failedLookupLocations_1[_i];
85947                 var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
85948                 var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
85949                 if (toWatch) {
85950                     var dir = toWatch.dir, dirPath = toWatch.dirPath, nonRecursive = toWatch.nonRecursive;
85951                     if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) {
85952                         var refCount = customFailedLookupPaths.get(failedLookupLocationPath) || 0;
85953                         customFailedLookupPaths.set(failedLookupLocationPath, refCount + 1);
85954                     }
85955                     if (dirPath === rootPath) {
85956                         ts.Debug.assert(!nonRecursive);
85957                         setAtRoot = true;
85958                     }
85959                     else {
85960                         setDirectoryWatcher(dir, dirPath, nonRecursive);
85961                     }
85962                 }
85963             }
85964             if (setAtRoot) {
85965                 setDirectoryWatcher(rootDir, rootPath, true);
85966             }
85967         }
85968         function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
85969             var program = resolutionHost.getCurrentProgram();
85970             if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
85971                 resolutions.forEach(watchFailedLookupLocationOfResolution);
85972             }
85973         }
85974         function setDirectoryWatcher(dir, dirPath, nonRecursive) {
85975             var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
85976             if (dirWatcher) {
85977                 ts.Debug.assert(!!nonRecursive === !!dirWatcher.nonRecursive);
85978                 dirWatcher.refCount++;
85979             }
85980             else {
85981                 directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath, nonRecursive), refCount: 1, nonRecursive: nonRecursive });
85982             }
85983         }
85984         function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
85985             ts.unorderedRemoveItem(ts.Debug.assertDefined(resolution.files), filePath);
85986             resolution.refCount--;
85987             if (resolution.refCount) {
85988                 return;
85989             }
85990             var resolved = getResolutionWithResolvedFileName(resolution);
85991             if (resolved && resolved.resolvedFileName) {
85992                 resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
85993             }
85994             if (!ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
85995                 return;
85996             }
85997             var failedLookupLocations = resolution.failedLookupLocations;
85998             var removeAtRoot = false;
85999             for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
86000                 var failedLookupLocation = failedLookupLocations_2[_i];
86001                 var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
86002                 var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
86003                 if (toWatch) {
86004                     var dirPath = toWatch.dirPath;
86005                     var refCount = customFailedLookupPaths.get(failedLookupLocationPath);
86006                     if (refCount) {
86007                         if (refCount === 1) {
86008                             customFailedLookupPaths.delete(failedLookupLocationPath);
86009                         }
86010                         else {
86011                             ts.Debug.assert(refCount > 1);
86012                             customFailedLookupPaths.set(failedLookupLocationPath, refCount - 1);
86013                         }
86014                     }
86015                     if (dirPath === rootPath) {
86016                         removeAtRoot = true;
86017                     }
86018                     else {
86019                         removeDirectoryWatcher(dirPath);
86020                     }
86021                 }
86022             }
86023             if (removeAtRoot) {
86024                 removeDirectoryWatcher(rootPath);
86025             }
86026         }
86027         function removeDirectoryWatcher(dirPath) {
86028             var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
86029             dirWatcher.refCount--;
86030         }
86031         function createDirectoryWatcher(directory, dirPath, nonRecursive) {
86032             return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, function (fileOrDirectory) {
86033                 var fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
86034                 if (cachedDirectoryStructureHost) {
86035                     cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
86036                 }
86037                 if (invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath)) {
86038                     resolutionHost.onInvalidatedResolution();
86039                 }
86040             }, nonRecursive ? 0 : 1);
86041         }
86042         function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) {
86043             var resolutions = cache.get(filePath);
86044             if (resolutions) {
86045                 resolutions.forEach(function (resolution) { return stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName); });
86046                 cache.delete(filePath);
86047             }
86048         }
86049         function removeResolutionsFromProjectReferenceRedirects(filePath) {
86050             if (!ts.fileExtensionIs(filePath, ".json")) {
86051                 return;
86052             }
86053             var program = resolutionHost.getCurrentProgram();
86054             if (!program) {
86055                 return;
86056             }
86057             var resolvedProjectReference = program.getResolvedProjectReferenceByPath(filePath);
86058             if (!resolvedProjectReference) {
86059                 return;
86060             }
86061             resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); });
86062         }
86063         function removeResolutionsOfFile(filePath) {
86064             removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModule);
86065             removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective);
86066         }
86067         function invalidateResolution(resolution) {
86068             resolution.isInvalidated = true;
86069             var changedInAutoTypeReferenced = false;
86070             for (var _i = 0, _a = ts.Debug.assertDefined(resolution.files); _i < _a.length; _i++) {
86071                 var containingFilePath = _a[_i];
86072                 (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = ts.createMap())).set(containingFilePath, true);
86073                 changedInAutoTypeReferenced = changedInAutoTypeReferenced || containingFilePath.endsWith(ts.inferredTypesContainingFile);
86074             }
86075             if (changedInAutoTypeReferenced) {
86076                 resolutionHost.onChangedAutomaticTypeDirectiveNames();
86077             }
86078         }
86079         function invalidateResolutionOfFile(filePath) {
86080             removeResolutionsOfFile(filePath);
86081             ts.forEach(resolvedFileToResolution.get(filePath), invalidateResolution);
86082         }
86083         function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) {
86084             ts.Debug.assert(filesWithInvalidatedNonRelativeUnresolvedImports === filesMap || filesWithInvalidatedNonRelativeUnresolvedImports === undefined);
86085             filesWithInvalidatedNonRelativeUnresolvedImports = filesMap;
86086         }
86087         function invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, isCreatingWatchedDirectory) {
86088             var isChangedFailedLookupLocation;
86089             if (isCreatingWatchedDirectory) {
86090                 isChangedFailedLookupLocation = function (location) { return isInDirectoryPath(fileOrDirectoryPath, resolutionHost.toPath(location)); };
86091             }
86092             else {
86093                 var updatedPath = removeIgnoredPath(fileOrDirectoryPath);
86094                 if (!updatedPath)
86095                     return false;
86096                 fileOrDirectoryPath = updatedPath;
86097                 if (resolutionHost.fileIsOpen(fileOrDirectoryPath)) {
86098                     return false;
86099                 }
86100                 var dirOfFileOrDirectory = ts.getDirectoryPath(fileOrDirectoryPath);
86101                 if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || ts.isNodeModulesDirectory(fileOrDirectoryPath) ||
86102                     isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || ts.isNodeModulesDirectory(dirOfFileOrDirectory)) {
86103                     isChangedFailedLookupLocation = function (location) {
86104                         var locationPath = resolutionHost.toPath(location);
86105                         return locationPath === fileOrDirectoryPath || ts.startsWith(resolutionHost.toPath(location), fileOrDirectoryPath);
86106                     };
86107                 }
86108                 else {
86109                     if (!isPathWithDefaultFailedLookupExtension(fileOrDirectoryPath) && !customFailedLookupPaths.has(fileOrDirectoryPath)) {
86110                         return false;
86111                     }
86112                     if (ts.isEmittedFileOfProgram(resolutionHost.getCurrentProgram(), fileOrDirectoryPath)) {
86113                         return false;
86114                     }
86115                     isChangedFailedLookupLocation = function (location) { return resolutionHost.toPath(location) === fileOrDirectoryPath; };
86116                 }
86117             }
86118             var invalidated = false;
86119             for (var _i = 0, resolutionsWithFailedLookups_1 = resolutionsWithFailedLookups; _i < resolutionsWithFailedLookups_1.length; _i++) {
86120                 var resolution = resolutionsWithFailedLookups_1[_i];
86121                 if (resolution.failedLookupLocations.some(isChangedFailedLookupLocation)) {
86122                     invalidateResolution(resolution);
86123                     invalidated = true;
86124                 }
86125             }
86126             return invalidated;
86127         }
86128         function closeTypeRootsWatch() {
86129             ts.clearMap(typeRootsWatches, ts.closeFileWatcher);
86130         }
86131         function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath) {
86132             if (isInDirectoryPath(rootPath, typeRootPath)) {
86133                 return rootPath;
86134             }
86135             var toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath);
86136             return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : undefined;
86137         }
86138         function createTypeRootsWatch(typeRootPath, typeRoot) {
86139             return resolutionHost.watchTypeRootsDirectory(typeRoot, function (fileOrDirectory) {
86140                 var fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
86141                 if (cachedDirectoryStructureHost) {
86142                     cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
86143                 }
86144                 resolutionHost.onChangedAutomaticTypeDirectiveNames();
86145                 var dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath);
86146                 if (dirPath && invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath)) {
86147                     resolutionHost.onInvalidatedResolution();
86148                 }
86149             }, 1);
86150         }
86151         function updateTypeRootsWatch() {
86152             var options = resolutionHost.getCompilationSettings();
86153             if (options.types) {
86154                 closeTypeRootsWatch();
86155                 return;
86156             }
86157             var typeRoots = ts.getEffectiveTypeRoots(options, { directoryExists: directoryExistsForTypeRootWatch, getCurrentDirectory: getCurrentDirectory });
86158             if (typeRoots) {
86159                 ts.mutateMap(typeRootsWatches, ts.arrayToMap(typeRoots, function (tr) { return resolutionHost.toPath(tr); }), {
86160                     createNewValue: createTypeRootsWatch,
86161                     onDeleteValue: ts.closeFileWatcher
86162                 });
86163             }
86164             else {
86165                 closeTypeRootsWatch();
86166             }
86167         }
86168         function directoryExistsForTypeRootWatch(nodeTypesDirectory) {
86169             var dir = ts.getDirectoryPath(ts.getDirectoryPath(nodeTypesDirectory));
86170             var dirPath = resolutionHost.toPath(dir);
86171             return dirPath === rootPath || canWatchDirectory(dirPath);
86172         }
86173     }
86174     ts.createResolutionCache = createResolutionCache;
86175 })(ts || (ts = {}));
86176 var ts;
86177 (function (ts) {
86178     var moduleSpecifiers;
86179     (function (moduleSpecifiers) {
86180         function getPreferences(_a, compilerOptions, importingSourceFile) {
86181             var importModuleSpecifierPreference = _a.importModuleSpecifierPreference, importModuleSpecifierEnding = _a.importModuleSpecifierEnding;
86182             return {
86183                 relativePreference: importModuleSpecifierPreference === "relative" ? 0 : importModuleSpecifierPreference === "non-relative" ? 1 : 2,
86184                 ending: getEnding(),
86185             };
86186             function getEnding() {
86187                 switch (importModuleSpecifierEnding) {
86188                     case "minimal": return 0;
86189                     case "index": return 1;
86190                     case "js": return 2;
86191                     default: return usesJsExtensionOnImports(importingSourceFile) ? 2
86192                         : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 : 0;
86193                 }
86194             }
86195         }
86196         function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) {
86197             return {
86198                 relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 : 1,
86199                 ending: ts.hasJSFileExtension(oldImportSpecifier) ?
86200                     2 :
86201                     ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 : 0,
86202             };
86203         }
86204         function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, oldImportSpecifier) {
86205             var res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier));
86206             if (res === oldImportSpecifier)
86207                 return undefined;
86208             return res;
86209         }
86210         moduleSpecifiers.updateModuleSpecifier = updateModuleSpecifier;
86211         function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences) {
86212             if (preferences === void 0) { preferences = {}; }
86213             return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences(preferences, compilerOptions, importingSourceFile));
86214         }
86215         moduleSpecifiers.getModuleSpecifier = getModuleSpecifier;
86216         function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host) {
86217             var info = getInfo(importingSourceFileName, host);
86218             var modulePaths = getAllModulePaths(importingSourceFileName, nodeModulesFileName, host);
86219             return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions, true); });
86220         }
86221         moduleSpecifiers.getNodeModulesPackageName = getNodeModulesPackageName;
86222         function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, preferences) {
86223             var info = getInfo(importingSourceFileName, host);
86224             var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host);
86225             return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }) ||
86226                 getLocalModuleSpecifier(toFileName, info, compilerOptions, preferences);
86227         }
86228         function getModuleSpecifiers(moduleSymbol, compilerOptions, importingSourceFile, host, userPreferences) {
86229             var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol);
86230             if (ambient)
86231                 return [ambient];
86232             var info = getInfo(importingSourceFile.path, host);
86233             var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol));
86234             var modulePaths = getAllModulePaths(importingSourceFile.path, moduleSourceFile.originalFileName, host);
86235             var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile);
86236             var global = ts.mapDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); });
86237             return global.length ? global : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifier(moduleFileName, info, compilerOptions, preferences); });
86238         }
86239         moduleSpecifiers.getModuleSpecifiers = getModuleSpecifiers;
86240         function getInfo(importingSourceFileName, host) {
86241             var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : true);
86242             var sourceDirectory = ts.getDirectoryPath(importingSourceFileName);
86243             return { getCanonicalFileName: getCanonicalFileName, sourceDirectory: sourceDirectory };
86244         }
86245         function getLocalModuleSpecifier(moduleFileName, _a, compilerOptions, _b) {
86246             var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory;
86247             var ending = _b.ending, relativePreference = _b.relativePreference;
86248             var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs;
86249             var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) ||
86250                 removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions);
86251             if (!baseUrl || relativePreference === 0) {
86252                 return relativePath;
86253             }
86254             var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseUrl, getCanonicalFileName);
86255             if (!relativeToBaseUrl) {
86256                 return relativePath;
86257             }
86258             var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions);
86259             var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths);
86260             var nonRelative = fromPaths === undefined ? importRelativeToBaseUrl : fromPaths;
86261             if (relativePreference === 1) {
86262                 return nonRelative;
86263             }
86264             if (relativePreference !== 2)
86265                 ts.Debug.assertNever(relativePreference);
86266             return isPathRelativeToParent(nonRelative) || countPathComponents(relativePath) < countPathComponents(nonRelative) ? relativePath : nonRelative;
86267         }
86268         function countPathComponents(path) {
86269             var count = 0;
86270             for (var i = ts.startsWith(path, "./") ? 2 : 0; i < path.length; i++) {
86271                 if (path.charCodeAt(i) === 47)
86272                     count++;
86273             }
86274             return count;
86275         }
86276         moduleSpecifiers.countPathComponents = countPathComponents;
86277         function usesJsExtensionOnImports(_a) {
86278             var imports = _a.imports;
86279             return ts.firstDefined(imports, function (_a) {
86280                 var text = _a.text;
86281                 return ts.pathIsRelative(text) ? ts.hasJSFileExtension(text) : undefined;
86282             }) || false;
86283         }
86284         function numberOfDirectorySeparators(str) {
86285             var match = str.match(/\//g);
86286             return match ? match.length : 0;
86287         }
86288         function comparePathsByNumberOfDirectorySeparators(a, b) {
86289             return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b));
86290         }
86291         function forEachFileNameOfModule(importingFileName, importedFileName, host, preferSymlinks, cb) {
86292             var getCanonicalFileName = ts.hostGetCanonicalFileName(host);
86293             var cwd = host.getCurrentDirectory();
86294             var referenceRedirect = host.isSourceOfProjectReferenceRedirect(importedFileName) ? host.getProjectReferenceRedirect(importedFileName) : undefined;
86295             var redirects = host.redirectTargetsMap.get(ts.toPath(importedFileName, cwd, getCanonicalFileName)) || ts.emptyArray;
86296             var importedFileNames = __spreadArrays((referenceRedirect ? [referenceRedirect] : ts.emptyArray), [importedFileName], redirects);
86297             var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); });
86298             if (!preferSymlinks) {
86299                 var result_12 = ts.forEach(targets, cb);
86300                 if (result_12)
86301                     return result_12;
86302             }
86303             var links = host.getProbableSymlinks
86304                 ? host.getProbableSymlinks(host.getSourceFiles())
86305                 : ts.discoverProbableSymlinks(host.getSourceFiles(), getCanonicalFileName, cwd);
86306             var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive;
86307             var result = ts.forEachEntry(links, function (resolved, path) {
86308                 if (ts.startsWithDirectory(importingFileName, resolved, getCanonicalFileName)) {
86309                     return undefined;
86310                 }
86311                 var target = ts.find(targets, function (t) { return compareStrings(t.slice(0, resolved.length + 1), resolved + "/") === 0; });
86312                 if (target === undefined)
86313                     return undefined;
86314                 var relative = ts.getRelativePathFromDirectory(resolved, target, getCanonicalFileName);
86315                 var option = ts.resolvePath(path, relative);
86316                 if (!host.fileExists || host.fileExists(option)) {
86317                     var result_13 = cb(option);
86318                     if (result_13)
86319                         return result_13;
86320                 }
86321             });
86322             return result ||
86323                 (preferSymlinks ? ts.forEach(targets, cb) : undefined);
86324         }
86325         moduleSpecifiers.forEachFileNameOfModule = forEachFileNameOfModule;
86326         function getAllModulePaths(importingFileName, importedFileName, host) {
86327             var cwd = host.getCurrentDirectory();
86328             var getCanonicalFileName = ts.hostGetCanonicalFileName(host);
86329             var allFileNames = ts.createMap();
86330             var importedFileFromNodeModules = false;
86331             forEachFileNameOfModule(importingFileName, importedFileName, host, true, function (path) {
86332                 allFileNames.set(path, getCanonicalFileName(path));
86333                 importedFileFromNodeModules = importedFileFromNodeModules || ts.pathContainsNodeModules(path);
86334             });
86335             var sortedPaths = [];
86336             var _loop_20 = function (directory) {
86337                 var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
86338                 var pathsInDirectory;
86339                 allFileNames.forEach(function (canonicalFileName, fileName) {
86340                     if (ts.startsWith(canonicalFileName, directoryStart)) {
86341                         if (!importedFileFromNodeModules || ts.pathContainsNodeModules(fileName)) {
86342                             (pathsInDirectory || (pathsInDirectory = [])).push(fileName);
86343                         }
86344                         allFileNames.delete(fileName);
86345                     }
86346                 });
86347                 if (pathsInDirectory) {
86348                     if (pathsInDirectory.length > 1) {
86349                         pathsInDirectory.sort(comparePathsByNumberOfDirectorySeparators);
86350                     }
86351                     sortedPaths.push.apply(sortedPaths, pathsInDirectory);
86352                 }
86353                 var newDirectory = ts.getDirectoryPath(directory);
86354                 if (newDirectory === directory)
86355                     return out_directory_1 = directory, "break";
86356                 directory = newDirectory;
86357                 out_directory_1 = directory;
86358             };
86359             var out_directory_1;
86360             for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) {
86361                 var state_8 = _loop_20(directory);
86362                 directory = out_directory_1;
86363                 if (state_8 === "break")
86364                     break;
86365             }
86366             if (allFileNames.size) {
86367                 var remainingPaths = ts.arrayFrom(allFileNames.values());
86368                 if (remainingPaths.length > 1)
86369                     remainingPaths.sort(comparePathsByNumberOfDirectorySeparators);
86370                 sortedPaths.push.apply(sortedPaths, remainingPaths);
86371             }
86372             return sortedPaths;
86373         }
86374         function tryGetModuleNameFromAmbientModule(moduleSymbol) {
86375             var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); });
86376             if (decl) {
86377                 return decl.name.text;
86378             }
86379         }
86380         function tryGetModuleNameFromPaths(relativeToBaseUrlWithIndex, relativeToBaseUrl, paths) {
86381             for (var key in paths) {
86382                 for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
86383                     var patternText_1 = _a[_i];
86384                     var pattern = ts.removeFileExtension(ts.normalizePath(patternText_1));
86385                     var indexOfStar = pattern.indexOf("*");
86386                     if (indexOfStar !== -1) {
86387                         var prefix = pattern.substr(0, indexOfStar);
86388                         var suffix = pattern.substr(indexOfStar + 1);
86389                         if (relativeToBaseUrl.length >= prefix.length + suffix.length &&
86390                             ts.startsWith(relativeToBaseUrl, prefix) &&
86391                             ts.endsWith(relativeToBaseUrl, suffix) ||
86392                             !suffix && relativeToBaseUrl === ts.removeTrailingDirectorySeparator(prefix)) {
86393                             var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length);
86394                             return key.replace("*", matchedStar);
86395                         }
86396                     }
86397                     else if (pattern === relativeToBaseUrl || pattern === relativeToBaseUrlWithIndex) {
86398                         return key;
86399                     }
86400                 }
86401             }
86402         }
86403         function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
86404             var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
86405             if (normalizedTargetPath === undefined) {
86406                 return undefined;
86407             }
86408             var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName);
86409             var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath;
86410             return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs
86411                 ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
86412                 : ts.removeFileExtension(relativePath);
86413         }
86414         function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options, packageNameOnly) {
86415             var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory;
86416             if (!host.fileExists || !host.readFile) {
86417                 return undefined;
86418             }
86419             var parts = getNodeModulePathParts(moduleFileName);
86420             if (!parts) {
86421                 return undefined;
86422             }
86423             var moduleSpecifier = moduleFileName;
86424             if (!packageNameOnly) {
86425                 var packageRootIndex = parts.packageRootIndex;
86426                 var moduleFileNameForExtensionless = void 0;
86427                 while (true) {
86428                     var _b = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _b.moduleFileToTry, packageRootPath = _b.packageRootPath;
86429                     if (packageRootPath) {
86430                         moduleSpecifier = packageRootPath;
86431                         break;
86432                     }
86433                     if (!moduleFileNameForExtensionless)
86434                         moduleFileNameForExtensionless = moduleFileToTry;
86435                     packageRootIndex = moduleFileName.indexOf(ts.directorySeparator, packageRootIndex + 1);
86436                     if (packageRootIndex === -1) {
86437                         moduleSpecifier = getExtensionlessFileName(moduleFileNameForExtensionless);
86438                         break;
86439                     }
86440                 }
86441             }
86442             var globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation();
86443             var pathToTopLevelNodeModules = getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex));
86444             if (!(ts.startsWith(sourceDirectory, pathToTopLevelNodeModules) || globalTypingsCacheLocation && ts.startsWith(getCanonicalFileName(globalTypingsCacheLocation), pathToTopLevelNodeModules))) {
86445                 return undefined;
86446             }
86447             var nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1);
86448             var packageName = ts.getPackageNameFromTypesPackageName(nodeModulesDirectoryName);
86449             return ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs && packageName === nodeModulesDirectoryName ? undefined : packageName;
86450             function tryDirectoryWithPackageJson(packageRootIndex) {
86451                 var packageRootPath = moduleFileName.substring(0, packageRootIndex);
86452                 var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
86453                 var moduleFileToTry = moduleFileName;
86454                 if (host.fileExists(packageJsonPath)) {
86455                     var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
86456                     var versionPaths = packageJsonContent.typesVersions
86457                         ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
86458                         : undefined;
86459                     if (versionPaths) {
86460                         var subModuleName = moduleFileName.slice(packageRootPath.length + 1);
86461                         var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0, options), versionPaths.paths);
86462                         if (fromPaths !== undefined) {
86463                             moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths);
86464                         }
86465                     }
86466                     var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main;
86467                     if (ts.isString(mainFileRelative)) {
86468                         var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
86469                         if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
86470                             return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry };
86471                         }
86472                     }
86473                 }
86474                 return { moduleFileToTry: moduleFileToTry };
86475             }
86476             function getExtensionlessFileName(path) {
86477                 var fullModulePathWithoutExtension = ts.removeFileExtension(path);
86478                 if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) {
86479                     return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex);
86480                 }
86481                 return fullModulePathWithoutExtension;
86482             }
86483         }
86484         function tryGetAnyFileFromPath(host, path) {
86485             if (!host.fileExists)
86486                 return;
86487             var extensions = ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 }]);
86488             for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) {
86489                 var e = extensions_3[_i];
86490                 var fullPath = path + e;
86491                 if (host.fileExists(fullPath)) {
86492                     return fullPath;
86493                 }
86494             }
86495         }
86496         function getNodeModulePathParts(fullPath) {
86497             var topLevelNodeModulesIndex = 0;
86498             var topLevelPackageNameIndex = 0;
86499             var packageRootIndex = 0;
86500             var fileNameIndex = 0;
86501             var partStart = 0;
86502             var partEnd = 0;
86503             var state = 0;
86504             while (partEnd >= 0) {
86505                 partStart = partEnd;
86506                 partEnd = fullPath.indexOf("/", partStart + 1);
86507                 switch (state) {
86508                     case 0:
86509                         if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
86510                             topLevelNodeModulesIndex = partStart;
86511                             topLevelPackageNameIndex = partEnd;
86512                             state = 1;
86513                         }
86514                         break;
86515                     case 1:
86516                     case 2:
86517                         if (state === 1 && fullPath.charAt(partStart + 1) === "@") {
86518                             state = 2;
86519                         }
86520                         else {
86521                             packageRootIndex = partEnd;
86522                             state = 3;
86523                         }
86524                         break;
86525                     case 3:
86526                         if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
86527                             state = 1;
86528                         }
86529                         else {
86530                             state = 3;
86531                         }
86532                         break;
86533                 }
86534             }
86535             fileNameIndex = partStart;
86536             return state > 1 ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
86537         }
86538         function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
86539             return ts.firstDefined(rootDirs, function (rootDir) {
86540                 var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
86541                 return isPathRelativeToParent(relativePath) ? undefined : relativePath;
86542             });
86543         }
86544         function removeExtensionAndIndexPostFix(fileName, ending, options) {
86545             if (ts.fileExtensionIs(fileName, ".json"))
86546                 return fileName;
86547             var noExtension = ts.removeFileExtension(fileName);
86548             switch (ending) {
86549                 case 0:
86550                     return ts.removeSuffix(noExtension, "/index");
86551                 case 1:
86552                     return noExtension;
86553                 case 2:
86554                     return noExtension + getJSExtensionForFile(fileName, options);
86555                 default:
86556                     return ts.Debug.assertNever(ending);
86557             }
86558         }
86559         function getJSExtensionForFile(fileName, options) {
86560             var ext = ts.extensionFromPath(fileName);
86561             switch (ext) {
86562                 case ".ts":
86563                 case ".d.ts":
86564                     return ".js";
86565                 case ".tsx":
86566                     return options.jsx === 1 ? ".jsx" : ".js";
86567                 case ".js":
86568                 case ".jsx":
86569                 case ".json":
86570                     return ext;
86571                 case ".tsbuildinfo":
86572                     return ts.Debug.fail("Extension " + ".tsbuildinfo" + " is unsupported:: FileName:: " + fileName);
86573                 default:
86574                     return ts.Debug.assertNever(ext);
86575             }
86576         }
86577         function getRelativePathIfInDirectory(path, directoryPath, getCanonicalFileName) {
86578             var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false);
86579             return ts.isRootedDiskPath(relativePath) ? undefined : relativePath;
86580         }
86581         function isPathRelativeToParent(path) {
86582             return ts.startsWith(path, "..");
86583         }
86584     })(moduleSpecifiers = ts.moduleSpecifiers || (ts.moduleSpecifiers = {}));
86585 })(ts || (ts = {}));
86586 var ts;
86587 (function (ts) {
86588     var sysFormatDiagnosticsHost = ts.sys ? {
86589         getCurrentDirectory: function () { return ts.sys.getCurrentDirectory(); },
86590         getNewLine: function () { return ts.sys.newLine; },
86591         getCanonicalFileName: ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)
86592     } : undefined;
86593     function createDiagnosticReporter(system, pretty) {
86594         var host = system === ts.sys ? sysFormatDiagnosticsHost : {
86595             getCurrentDirectory: function () { return system.getCurrentDirectory(); },
86596             getNewLine: function () { return system.newLine; },
86597             getCanonicalFileName: ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames),
86598         };
86599         if (!pretty) {
86600             return function (diagnostic) { return system.write(ts.formatDiagnostic(diagnostic, host)); };
86601         }
86602         var diagnostics = new Array(1);
86603         return function (diagnostic) {
86604             diagnostics[0] = diagnostic;
86605             system.write(ts.formatDiagnosticsWithColorAndContext(diagnostics, host) + host.getNewLine());
86606             diagnostics[0] = undefined;
86607         };
86608     }
86609     ts.createDiagnosticReporter = createDiagnosticReporter;
86610     function clearScreenIfNotWatchingForFileChanges(system, diagnostic, options) {
86611         if (system.clearScreen &&
86612             !options.preserveWatchOutput &&
86613             !options.extendedDiagnostics &&
86614             !options.diagnostics &&
86615             ts.contains(ts.screenStartingMessageCodes, diagnostic.code)) {
86616             system.clearScreen();
86617             return true;
86618         }
86619         return false;
86620     }
86621     ts.screenStartingMessageCodes = [
86622         ts.Diagnostics.Starting_compilation_in_watch_mode.code,
86623         ts.Diagnostics.File_change_detected_Starting_incremental_compilation.code,
86624     ];
86625     function getPlainDiagnosticFollowingNewLines(diagnostic, newLine) {
86626         return ts.contains(ts.screenStartingMessageCodes, diagnostic.code)
86627             ? newLine + newLine
86628             : newLine;
86629     }
86630     function getLocaleTimeString(system) {
86631         return !system.now ?
86632             new Date().toLocaleTimeString() :
86633             system.now().toLocaleTimeString("en-US", { timeZone: "UTC" });
86634     }
86635     ts.getLocaleTimeString = getLocaleTimeString;
86636     function createWatchStatusReporter(system, pretty) {
86637         return pretty ?
86638             function (diagnostic, newLine, options) {
86639                 clearScreenIfNotWatchingForFileChanges(system, diagnostic, options);
86640                 var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] ";
86641                 output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine);
86642                 system.write(output);
86643             } :
86644             function (diagnostic, newLine, options) {
86645                 var output = "";
86646                 if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) {
86647                     output += newLine;
86648                 }
86649                 output += getLocaleTimeString(system) + " - ";
86650                 output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine);
86651                 system.write(output);
86652             };
86653     }
86654     ts.createWatchStatusReporter = createWatchStatusReporter;
86655     function parseConfigFileWithSystem(configFileName, optionsToExtend, watchOptionsToExtend, system, reportDiagnostic) {
86656         var host = system;
86657         host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); };
86658         var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, undefined, watchOptionsToExtend);
86659         host.onUnRecoverableConfigFileDiagnostic = undefined;
86660         return result;
86661     }
86662     ts.parseConfigFileWithSystem = parseConfigFileWithSystem;
86663     function getErrorCountForSummary(diagnostics) {
86664         return ts.countWhere(diagnostics, function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; });
86665     }
86666     ts.getErrorCountForSummary = getErrorCountForSummary;
86667     function getWatchErrorSummaryDiagnosticMessage(errorCount) {
86668         return errorCount === 1 ?
86669             ts.Diagnostics.Found_1_error_Watching_for_file_changes :
86670             ts.Diagnostics.Found_0_errors_Watching_for_file_changes;
86671     }
86672     ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage;
86673     function getErrorSummaryText(errorCount, newLine) {
86674         if (errorCount === 0)
86675             return "";
86676         var d = ts.createCompilerDiagnostic(errorCount === 1 ? ts.Diagnostics.Found_1_error : ts.Diagnostics.Found_0_errors, errorCount);
86677         return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine;
86678     }
86679     ts.getErrorSummaryText = getErrorSummaryText;
86680     function listFiles(program, writeFileName) {
86681         if (program.getCompilerOptions().listFiles || program.getCompilerOptions().listFilesOnly) {
86682             ts.forEach(program.getSourceFiles(), function (file) {
86683                 writeFileName(file.fileName);
86684             });
86685         }
86686     }
86687     ts.listFiles = listFiles;
86688     function emitFilesAndReportErrors(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
86689         var isListFilesOnly = !!program.getCompilerOptions().listFilesOnly;
86690         var allDiagnostics = program.getConfigFileParsingDiagnostics().slice();
86691         var configFileParsingDiagnosticsLength = allDiagnostics.length;
86692         ts.addRange(allDiagnostics, program.getSyntacticDiagnostics(undefined, cancellationToken));
86693         if (allDiagnostics.length === configFileParsingDiagnosticsLength) {
86694             ts.addRange(allDiagnostics, program.getOptionsDiagnostics(cancellationToken));
86695             if (!isListFilesOnly) {
86696                 ts.addRange(allDiagnostics, program.getGlobalDiagnostics(cancellationToken));
86697                 if (allDiagnostics.length === configFileParsingDiagnosticsLength) {
86698                     ts.addRange(allDiagnostics, program.getSemanticDiagnostics(undefined, cancellationToken));
86699                 }
86700             }
86701         }
86702         var emitResult = isListFilesOnly
86703             ? { emitSkipped: true, diagnostics: ts.emptyArray }
86704             : program.emit(undefined, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers);
86705         var emittedFiles = emitResult.emittedFiles, emitDiagnostics = emitResult.diagnostics;
86706         ts.addRange(allDiagnostics, emitDiagnostics);
86707         var diagnostics = ts.sortAndDeduplicateDiagnostics(allDiagnostics);
86708         diagnostics.forEach(reportDiagnostic);
86709         if (writeFileName) {
86710             var currentDir_1 = program.getCurrentDirectory();
86711             ts.forEach(emittedFiles, function (file) {
86712                 var filepath = ts.getNormalizedAbsolutePath(file, currentDir_1);
86713                 writeFileName("TSFILE: " + filepath);
86714             });
86715             listFiles(program, writeFileName);
86716         }
86717         if (reportSummary) {
86718             reportSummary(getErrorCountForSummary(diagnostics));
86719         }
86720         return {
86721             emitResult: emitResult,
86722             diagnostics: diagnostics,
86723         };
86724     }
86725     ts.emitFilesAndReportErrors = emitFilesAndReportErrors;
86726     function emitFilesAndReportErrorsAndGetExitStatus(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
86727         var _a = emitFilesAndReportErrors(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers), emitResult = _a.emitResult, diagnostics = _a.diagnostics;
86728         if (emitResult.emitSkipped && diagnostics.length > 0) {
86729             return ts.ExitStatus.DiagnosticsPresent_OutputsSkipped;
86730         }
86731         else if (diagnostics.length > 0) {
86732             return ts.ExitStatus.DiagnosticsPresent_OutputsGenerated;
86733         }
86734         return ts.ExitStatus.Success;
86735     }
86736     ts.emitFilesAndReportErrorsAndGetExitStatus = emitFilesAndReportErrorsAndGetExitStatus;
86737     ts.noopFileWatcher = { close: ts.noop };
86738     function createWatchHost(system, reportWatchStatus) {
86739         if (system === void 0) { system = ts.sys; }
86740         var onWatchStatusChange = reportWatchStatus || createWatchStatusReporter(system);
86741         return {
86742             onWatchStatusChange: onWatchStatusChange,
86743             watchFile: ts.maybeBind(system, system.watchFile) || (function () { return ts.noopFileWatcher; }),
86744             watchDirectory: ts.maybeBind(system, system.watchDirectory) || (function () { return ts.noopFileWatcher; }),
86745             setTimeout: ts.maybeBind(system, system.setTimeout) || ts.noop,
86746             clearTimeout: ts.maybeBind(system, system.clearTimeout) || ts.noop
86747         };
86748     }
86749     ts.createWatchHost = createWatchHost;
86750     ts.WatchType = {
86751         ConfigFile: "Config file",
86752         SourceFile: "Source file",
86753         MissingFile: "Missing file",
86754         WildcardDirectory: "Wild card directory",
86755         FailedLookupLocations: "Failed Lookup Locations",
86756         TypeRoots: "Type roots"
86757     };
86758     function createWatchFactory(host, options) {
86759         var watchLogLevel = host.trace ? options.extendedDiagnostics ? ts.WatchLogLevel.Verbose : options.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None;
86760         var writeLog = watchLogLevel !== ts.WatchLogLevel.None ? (function (s) { return host.trace(s); }) : ts.noop;
86761         var result = ts.getWatchFactory(watchLogLevel, writeLog);
86762         result.writeLog = writeLog;
86763         return result;
86764     }
86765     ts.createWatchFactory = createWatchFactory;
86766     function createCompilerHostFromProgramHost(host, getCompilerOptions, directoryStructureHost) {
86767         if (directoryStructureHost === void 0) { directoryStructureHost = host; }
86768         var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames();
86769         var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); });
86770         return {
86771             getSourceFile: function (fileName, languageVersion, onError) {
86772                 var text;
86773                 try {
86774                     ts.performance.mark("beforeIORead");
86775                     text = host.readFile(fileName, getCompilerOptions().charset);
86776                     ts.performance.mark("afterIORead");
86777                     ts.performance.measure("I/O Read", "beforeIORead", "afterIORead");
86778                 }
86779                 catch (e) {
86780                     if (onError) {
86781                         onError(e.message);
86782                     }
86783                     text = "";
86784                 }
86785                 return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion) : undefined;
86786             },
86787             getDefaultLibLocation: ts.maybeBind(host, host.getDefaultLibLocation),
86788             getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); },
86789             writeFile: writeFile,
86790             getCurrentDirectory: ts.memoize(function () { return host.getCurrentDirectory(); }),
86791             useCaseSensitiveFileNames: function () { return useCaseSensitiveFileNames; },
86792             getCanonicalFileName: ts.createGetCanonicalFileName(useCaseSensitiveFileNames),
86793             getNewLine: function () { return ts.getNewLineCharacter(getCompilerOptions(), hostGetNewLine); },
86794             fileExists: function (f) { return host.fileExists(f); },
86795             readFile: function (f) { return host.readFile(f); },
86796             trace: ts.maybeBind(host, host.trace),
86797             directoryExists: ts.maybeBind(directoryStructureHost, directoryStructureHost.directoryExists),
86798             getDirectories: ts.maybeBind(directoryStructureHost, directoryStructureHost.getDirectories),
86799             realpath: ts.maybeBind(host, host.realpath),
86800             getEnvironmentVariable: ts.maybeBind(host, host.getEnvironmentVariable) || (function () { return ""; }),
86801             createHash: ts.maybeBind(host, host.createHash),
86802             readDirectory: ts.maybeBind(host, host.readDirectory),
86803         };
86804         function writeFile(fileName, text, writeByteOrderMark, onError) {
86805             try {
86806                 ts.performance.mark("beforeIOWrite");
86807                 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); });
86808                 ts.performance.mark("afterIOWrite");
86809                 ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
86810             }
86811             catch (e) {
86812                 if (onError) {
86813                     onError(e.message);
86814                 }
86815             }
86816         }
86817     }
86818     ts.createCompilerHostFromProgramHost = createCompilerHostFromProgramHost;
86819     function setGetSourceFileAsHashVersioned(compilerHost, host) {
86820         var originalGetSourceFile = compilerHost.getSourceFile;
86821         var computeHash = host.createHash || ts.generateDjb2Hash;
86822         compilerHost.getSourceFile = function () {
86823             var args = [];
86824             for (var _i = 0; _i < arguments.length; _i++) {
86825                 args[_i] = arguments[_i];
86826             }
86827             var result = originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args));
86828             if (result) {
86829                 result.version = computeHash.call(host, result.text);
86830             }
86831             return result;
86832         };
86833     }
86834     ts.setGetSourceFileAsHashVersioned = setGetSourceFileAsHashVersioned;
86835     function createProgramHost(system, createProgram) {
86836         var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); });
86837         return {
86838             useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; },
86839             getNewLine: function () { return system.newLine; },
86840             getCurrentDirectory: ts.memoize(function () { return system.getCurrentDirectory(); }),
86841             getDefaultLibLocation: getDefaultLibLocation,
86842             getDefaultLibFileName: function (options) { return ts.combinePaths(getDefaultLibLocation(), ts.getDefaultLibFileName(options)); },
86843             fileExists: function (path) { return system.fileExists(path); },
86844             readFile: function (path, encoding) { return system.readFile(path, encoding); },
86845             directoryExists: function (path) { return system.directoryExists(path); },
86846             getDirectories: function (path) { return system.getDirectories(path); },
86847             readDirectory: function (path, extensions, exclude, include, depth) { return system.readDirectory(path, extensions, exclude, include, depth); },
86848             realpath: ts.maybeBind(system, system.realpath),
86849             getEnvironmentVariable: ts.maybeBind(system, system.getEnvironmentVariable),
86850             trace: function (s) { return system.write(s + system.newLine); },
86851             createDirectory: function (path) { return system.createDirectory(path); },
86852             writeFile: function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); },
86853             createHash: ts.maybeBind(system, system.createHash),
86854             createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram
86855         };
86856     }
86857     ts.createProgramHost = createProgramHost;
86858     function createWatchCompilerHost(system, createProgram, reportDiagnostic, reportWatchStatus) {
86859         if (system === void 0) { system = ts.sys; }
86860         var writeFileName = function (s) { return system.write(s + system.newLine); };
86861         var result = createProgramHost(system, createProgram);
86862         ts.copyProperties(result, createWatchHost(system, reportWatchStatus));
86863         result.afterProgramCreate = function (builderProgram) {
86864             var compilerOptions = builderProgram.getCompilerOptions();
86865             var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; });
86866             emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); });
86867         };
86868         return result;
86869     }
86870     function reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic) {
86871         reportDiagnostic(diagnostic);
86872         system.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
86873     }
86874     function createWatchCompilerHostOfConfigFile(_a) {
86875         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;
86876         var diagnosticReporter = reportDiagnostic || createDiagnosticReporter(system);
86877         var host = createWatchCompilerHost(system, createProgram, diagnosticReporter, reportWatchStatus);
86878         host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, diagnosticReporter, diagnostic); };
86879         host.configFileName = configFileName;
86880         host.optionsToExtend = optionsToExtend;
86881         host.watchOptionsToExtend = watchOptionsToExtend;
86882         host.extraFileExtensions = extraFileExtensions;
86883         return host;
86884     }
86885     ts.createWatchCompilerHostOfConfigFile = createWatchCompilerHostOfConfigFile;
86886     function createWatchCompilerHostOfFilesAndCompilerOptions(_a) {
86887         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;
86888         var host = createWatchCompilerHost(system, createProgram, reportDiagnostic || createDiagnosticReporter(system), reportWatchStatus);
86889         host.rootFiles = rootFiles;
86890         host.options = options;
86891         host.watchOptions = watchOptions;
86892         host.projectReferences = projectReferences;
86893         return host;
86894     }
86895     ts.createWatchCompilerHostOfFilesAndCompilerOptions = createWatchCompilerHostOfFilesAndCompilerOptions;
86896     function performIncrementalCompilation(input) {
86897         var system = input.system || ts.sys;
86898         var host = input.host || (input.host = ts.createIncrementalCompilerHost(input.options, system));
86899         var builderProgram = ts.createIncrementalProgram(input);
86900         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);
86901         if (input.afterProgramEmitAndDiagnostics)
86902             input.afterProgramEmitAndDiagnostics(builderProgram);
86903         return exitStatus;
86904     }
86905     ts.performIncrementalCompilation = performIncrementalCompilation;
86906 })(ts || (ts = {}));
86907 var ts;
86908 (function (ts) {
86909     function readBuilderProgram(compilerOptions, host) {
86910         if (compilerOptions.out || compilerOptions.outFile)
86911             return undefined;
86912         var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
86913         if (!buildInfoPath)
86914             return undefined;
86915         var content = host.readFile(buildInfoPath);
86916         if (!content)
86917             return undefined;
86918         var buildInfo = ts.getBuildInfo(content);
86919         if (buildInfo.version !== ts.version)
86920             return undefined;
86921         if (!buildInfo.program)
86922             return undefined;
86923         return ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
86924     }
86925     ts.readBuilderProgram = readBuilderProgram;
86926     function createIncrementalCompilerHost(options, system) {
86927         if (system === void 0) { system = ts.sys; }
86928         var host = ts.createCompilerHostWorker(options, undefined, system);
86929         host.createHash = ts.maybeBind(system, system.createHash);
86930         ts.setGetSourceFileAsHashVersioned(host, system);
86931         ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
86932         return host;
86933     }
86934     ts.createIncrementalCompilerHost = createIncrementalCompilerHost;
86935     function createIncrementalProgram(_a) {
86936         var rootNames = _a.rootNames, options = _a.options, configFileParsingDiagnostics = _a.configFileParsingDiagnostics, projectReferences = _a.projectReferences, host = _a.host, createProgram = _a.createProgram;
86937         host = host || createIncrementalCompilerHost(options);
86938         createProgram = createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram;
86939         var oldProgram = readBuilderProgram(options, host);
86940         return createProgram(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences);
86941     }
86942     ts.createIncrementalProgram = createIncrementalProgram;
86943     function createWatchCompilerHost(rootFilesOrConfigFileName, options, system, createProgram, reportDiagnostic, reportWatchStatus, projectReferencesOrWatchOptionsToExtend, watchOptionsOrExtraFileExtensions) {
86944         if (ts.isArray(rootFilesOrConfigFileName)) {
86945             return ts.createWatchCompilerHostOfFilesAndCompilerOptions({
86946                 rootFiles: rootFilesOrConfigFileName,
86947                 options: options,
86948                 watchOptions: watchOptionsOrExtraFileExtensions,
86949                 projectReferences: projectReferencesOrWatchOptionsToExtend,
86950                 system: system,
86951                 createProgram: createProgram,
86952                 reportDiagnostic: reportDiagnostic,
86953                 reportWatchStatus: reportWatchStatus,
86954             });
86955         }
86956         else {
86957             return ts.createWatchCompilerHostOfConfigFile({
86958                 configFileName: rootFilesOrConfigFileName,
86959                 optionsToExtend: options,
86960                 watchOptionsToExtend: projectReferencesOrWatchOptionsToExtend,
86961                 extraFileExtensions: watchOptionsOrExtraFileExtensions,
86962                 system: system,
86963                 createProgram: createProgram,
86964                 reportDiagnostic: reportDiagnostic,
86965                 reportWatchStatus: reportWatchStatus,
86966             });
86967         }
86968     }
86969     ts.createWatchCompilerHost = createWatchCompilerHost;
86970     function createWatchProgram(host) {
86971         var builderProgram;
86972         var reloadLevel;
86973         var missingFilesMap;
86974         var watchedWildcardDirectories;
86975         var timerToUpdateProgram;
86976         var sourceFilesCache = ts.createMap();
86977         var missingFilePathsRequestedForRelease;
86978         var hasChangedCompilerOptions = false;
86979         var hasChangedAutomaticTypeDirectiveNames = false;
86980         var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames();
86981         var currentDirectory = host.getCurrentDirectory();
86982         var configFileName = host.configFileName, _a = host.optionsToExtend, optionsToExtendForConfigFile = _a === void 0 ? {} : _a, watchOptionsToExtend = host.watchOptionsToExtend, extraFileExtensions = host.extraFileExtensions, createProgram = host.createProgram;
86983         var rootFileNames = host.rootFiles, compilerOptions = host.options, watchOptions = host.watchOptions, projectReferences = host.projectReferences;
86984         var configFileSpecs;
86985         var configFileParsingDiagnostics;
86986         var canConfigFileJsonReportNoInputFiles = false;
86987         var hasChangedConfigFileParsingErrors = false;
86988         var cachedDirectoryStructureHost = configFileName === undefined ? undefined : ts.createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames);
86989         var directoryStructureHost = cachedDirectoryStructureHost || host;
86990         var parseConfigFileHost = ts.parseConfigHostFromCompilerHostLike(host, directoryStructureHost);
86991         var newLine = updateNewLine();
86992         if (configFileName && host.configFileParsingResult) {
86993             setConfigFileParsingResult(host.configFileParsingResult);
86994             newLine = updateNewLine();
86995         }
86996         reportWatchDiagnostic(ts.Diagnostics.Starting_compilation_in_watch_mode);
86997         if (configFileName && !host.configFileParsingResult) {
86998             newLine = ts.getNewLineCharacter(optionsToExtendForConfigFile, function () { return host.getNewLine(); });
86999             ts.Debug.assert(!rootFileNames);
87000             parseConfigFile();
87001             newLine = updateNewLine();
87002         }
87003         var _b = ts.createWatchFactory(host, compilerOptions), watchFile = _b.watchFile, watchFilePath = _b.watchFilePath, watchDirectory = _b.watchDirectory, writeLog = _b.writeLog;
87004         var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
87005         writeLog("Current directory: " + currentDirectory + " CaseSensitiveFileNames: " + useCaseSensitiveFileNames);
87006         var configFileWatcher;
87007         if (configFileName) {
87008             configFileWatcher = watchFile(host, configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile);
87009         }
87010         var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return compilerOptions; }, directoryStructureHost);
87011         ts.setGetSourceFileAsHashVersioned(compilerHost, host);
87012         var getNewSourceFile = compilerHost.getSourceFile;
87013         compilerHost.getSourceFile = function (fileName) {
87014             var args = [];
87015             for (var _i = 1; _i < arguments.length; _i++) {
87016                 args[_i - 1] = arguments[_i];
87017             }
87018             return getVersionedSourceFileByPath.apply(void 0, __spreadArrays([fileName, toPath(fileName)], args));
87019         };
87020         compilerHost.getSourceFileByPath = getVersionedSourceFileByPath;
87021         compilerHost.getNewLine = function () { return newLine; };
87022         compilerHost.fileExists = fileExists;
87023         compilerHost.onReleaseOldSourceFile = onReleaseOldSourceFile;
87024         compilerHost.toPath = toPath;
87025         compilerHost.getCompilationSettings = function () { return compilerOptions; };
87026         compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect);
87027         compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(host, dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); };
87028         compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(host, dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); };
87029         compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; };
87030         compilerHost.onInvalidatedResolution = scheduleProgramUpdate;
87031         compilerHost.onChangedAutomaticTypeDirectiveNames = function () {
87032             hasChangedAutomaticTypeDirectiveNames = true;
87033             scheduleProgramUpdate();
87034         };
87035         compilerHost.fileIsOpen = ts.returnFalse;
87036         compilerHost.getCurrentProgram = getCurrentProgram;
87037         compilerHost.writeLog = writeLog;
87038         var resolutionCache = ts.createResolutionCache(compilerHost, configFileName ?
87039             ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFileName, currentDirectory)) :
87040             currentDirectory, false);
87041         compilerHost.resolveModuleNames = host.resolveModuleNames ?
87042             (function () {
87043                 var args = [];
87044                 for (var _i = 0; _i < arguments.length; _i++) {
87045                     args[_i] = arguments[_i];
87046                 }
87047                 return host.resolveModuleNames.apply(host, args);
87048             }) :
87049             (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); });
87050         compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ?
87051             (function () {
87052                 var args = [];
87053                 for (var _i = 0; _i < arguments.length; _i++) {
87054                     args[_i] = arguments[_i];
87055                 }
87056                 return host.resolveTypeReferenceDirectives.apply(host, args);
87057             }) :
87058             (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); });
87059         var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
87060         builderProgram = readBuilderProgram(compilerOptions, compilerHost);
87061         synchronizeProgram();
87062         watchConfigFileWildCardDirectories();
87063         return configFileName ?
87064             { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, close: close } :
87065             { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, updateRootFileNames: updateRootFileNames, close: close };
87066         function close() {
87067             resolutionCache.clear();
87068             ts.clearMap(sourceFilesCache, function (value) {
87069                 if (value && value.fileWatcher) {
87070                     value.fileWatcher.close();
87071                     value.fileWatcher = undefined;
87072                 }
87073             });
87074             if (configFileWatcher) {
87075                 configFileWatcher.close();
87076                 configFileWatcher = undefined;
87077             }
87078             if (watchedWildcardDirectories) {
87079                 ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf);
87080                 watchedWildcardDirectories = undefined;
87081             }
87082             if (missingFilesMap) {
87083                 ts.clearMap(missingFilesMap, ts.closeFileWatcher);
87084                 missingFilesMap = undefined;
87085             }
87086         }
87087         function getCurrentBuilderProgram() {
87088             return builderProgram;
87089         }
87090         function getCurrentProgram() {
87091             return builderProgram && builderProgram.getProgramOrUndefined();
87092         }
87093         function synchronizeProgram() {
87094             writeLog("Synchronizing program");
87095             var program = getCurrentBuilderProgram();
87096             if (hasChangedCompilerOptions) {
87097                 newLine = updateNewLine();
87098                 if (program && ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) {
87099                     resolutionCache.clear();
87100                 }
87101             }
87102             var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
87103             if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences)) {
87104                 if (hasChangedConfigFileParsingErrors) {
87105                     builderProgram = createProgram(undefined, undefined, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
87106                     hasChangedConfigFileParsingErrors = false;
87107                 }
87108             }
87109             else {
87110                 createNewProgram(hasInvalidatedResolution);
87111             }
87112             if (host.afterProgramCreate && program !== builderProgram) {
87113                 host.afterProgramCreate(builderProgram);
87114             }
87115             return builderProgram;
87116         }
87117         function createNewProgram(hasInvalidatedResolution) {
87118             writeLog("CreatingProgramWith::");
87119             writeLog("  roots: " + JSON.stringify(rootFileNames));
87120             writeLog("  options: " + JSON.stringify(compilerOptions));
87121             var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram();
87122             hasChangedCompilerOptions = false;
87123             hasChangedConfigFileParsingErrors = false;
87124             resolutionCache.startCachingPerDirectoryResolution();
87125             compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
87126             compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
87127             hasChangedAutomaticTypeDirectiveNames = false;
87128             builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
87129             resolutionCache.finishCachingPerDirectoryResolution();
87130             ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = ts.createMap()), watchMissingFilePath);
87131             if (needsUpdateInTypeRootWatch) {
87132                 resolutionCache.updateTypeRootsWatch();
87133             }
87134             if (missingFilePathsRequestedForRelease) {
87135                 for (var _i = 0, missingFilePathsRequestedForRelease_1 = missingFilePathsRequestedForRelease; _i < missingFilePathsRequestedForRelease_1.length; _i++) {
87136                     var missingFilePath = missingFilePathsRequestedForRelease_1[_i];
87137                     if (!missingFilesMap.has(missingFilePath)) {
87138                         sourceFilesCache.delete(missingFilePath);
87139                     }
87140                 }
87141                 missingFilePathsRequestedForRelease = undefined;
87142             }
87143         }
87144         function updateRootFileNames(files) {
87145             ts.Debug.assert(!configFileName, "Cannot update root file names with config file watch mode");
87146             rootFileNames = files;
87147             scheduleProgramUpdate();
87148         }
87149         function updateNewLine() {
87150             return ts.getNewLineCharacter(compilerOptions || optionsToExtendForConfigFile, function () { return host.getNewLine(); });
87151         }
87152         function toPath(fileName) {
87153             return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
87154         }
87155         function isFileMissingOnHost(hostSourceFile) {
87156             return typeof hostSourceFile === "boolean";
87157         }
87158         function isFilePresenceUnknownOnHost(hostSourceFile) {
87159             return typeof hostSourceFile.version === "boolean";
87160         }
87161         function fileExists(fileName) {
87162             var path = toPath(fileName);
87163             if (isFileMissingOnHost(sourceFilesCache.get(path))) {
87164                 return false;
87165             }
87166             return directoryStructureHost.fileExists(fileName);
87167         }
87168         function getVersionedSourceFileByPath(fileName, path, languageVersion, onError, shouldCreateNewSourceFile) {
87169             var hostSourceFile = sourceFilesCache.get(path);
87170             if (isFileMissingOnHost(hostSourceFile)) {
87171                 return undefined;
87172             }
87173             if (hostSourceFile === undefined || shouldCreateNewSourceFile || isFilePresenceUnknownOnHost(hostSourceFile)) {
87174                 var sourceFile = getNewSourceFile(fileName, languageVersion, onError);
87175                 if (hostSourceFile) {
87176                     if (sourceFile) {
87177                         hostSourceFile.sourceFile = sourceFile;
87178                         hostSourceFile.version = sourceFile.version;
87179                         if (!hostSourceFile.fileWatcher) {
87180                             hostSourceFile.fileWatcher = watchFilePath(host, fileName, onSourceFileChange, ts.PollingInterval.Low, watchOptions, path, ts.WatchType.SourceFile);
87181                         }
87182                     }
87183                     else {
87184                         if (hostSourceFile.fileWatcher) {
87185                             hostSourceFile.fileWatcher.close();
87186                         }
87187                         sourceFilesCache.set(path, false);
87188                     }
87189                 }
87190                 else {
87191                     if (sourceFile) {
87192                         var fileWatcher = watchFilePath(host, fileName, onSourceFileChange, ts.PollingInterval.Low, watchOptions, path, ts.WatchType.SourceFile);
87193                         sourceFilesCache.set(path, { sourceFile: sourceFile, version: sourceFile.version, fileWatcher: fileWatcher });
87194                     }
87195                     else {
87196                         sourceFilesCache.set(path, false);
87197                     }
87198                 }
87199                 return sourceFile;
87200             }
87201             return hostSourceFile.sourceFile;
87202         }
87203         function nextSourceFileVersion(path) {
87204             var hostSourceFile = sourceFilesCache.get(path);
87205             if (hostSourceFile !== undefined) {
87206                 if (isFileMissingOnHost(hostSourceFile)) {
87207                     sourceFilesCache.set(path, { version: false });
87208                 }
87209                 else {
87210                     hostSourceFile.version = false;
87211                 }
87212             }
87213         }
87214         function getSourceVersion(path) {
87215             var hostSourceFile = sourceFilesCache.get(path);
87216             return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version;
87217         }
87218         function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) {
87219             var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath);
87220             if (hostSourceFileInfo !== undefined) {
87221                 if (isFileMissingOnHost(hostSourceFileInfo)) {
87222                     (missingFilePathsRequestedForRelease || (missingFilePathsRequestedForRelease = [])).push(oldSourceFile.path);
87223                 }
87224                 else if (hostSourceFileInfo.sourceFile === oldSourceFile) {
87225                     if (hostSourceFileInfo.fileWatcher) {
87226                         hostSourceFileInfo.fileWatcher.close();
87227                     }
87228                     sourceFilesCache.delete(oldSourceFile.resolvedPath);
87229                     if (!hasSourceFileByPath) {
87230                         resolutionCache.removeResolutionsOfFile(oldSourceFile.path);
87231                     }
87232                 }
87233             }
87234         }
87235         function reportWatchDiagnostic(message) {
87236             if (host.onWatchStatusChange) {
87237                 host.onWatchStatusChange(ts.createCompilerDiagnostic(message), newLine, compilerOptions || optionsToExtendForConfigFile);
87238             }
87239         }
87240         function scheduleProgramUpdate() {
87241             if (!host.setTimeout || !host.clearTimeout) {
87242                 return;
87243             }
87244             if (timerToUpdateProgram) {
87245                 host.clearTimeout(timerToUpdateProgram);
87246             }
87247             writeLog("Scheduling update");
87248             timerToUpdateProgram = host.setTimeout(updateProgramWithWatchStatus, 250);
87249         }
87250         function scheduleProgramReload() {
87251             ts.Debug.assert(!!configFileName);
87252             reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
87253             scheduleProgramUpdate();
87254         }
87255         function updateProgramWithWatchStatus() {
87256             timerToUpdateProgram = undefined;
87257             reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
87258             updateProgram();
87259         }
87260         function updateProgram() {
87261             switch (reloadLevel) {
87262                 case ts.ConfigFileProgramReloadLevel.Partial:
87263                     ts.perfLogger.logStartUpdateProgram("PartialConfigReload");
87264                     reloadFileNamesFromConfigFile();
87265                     break;
87266                 case ts.ConfigFileProgramReloadLevel.Full:
87267                     ts.perfLogger.logStartUpdateProgram("FullConfigReload");
87268                     reloadConfigFile();
87269                     break;
87270                 default:
87271                     ts.perfLogger.logStartUpdateProgram("SynchronizeProgram");
87272                     synchronizeProgram();
87273                     break;
87274             }
87275             ts.perfLogger.logStopUpdateProgram("Done");
87276             return getCurrentBuilderProgram();
87277         }
87278         function reloadFileNamesFromConfigFile() {
87279             writeLog("Reloading new file names and options");
87280             var result = ts.getFileNamesFromConfigSpecs(configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost);
87281             if (ts.updateErrorForNoInputFiles(result, ts.getNormalizedAbsolutePath(configFileName, currentDirectory), configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) {
87282                 hasChangedConfigFileParsingErrors = true;
87283             }
87284             rootFileNames = result.fileNames;
87285             synchronizeProgram();
87286         }
87287         function reloadConfigFile() {
87288             writeLog("Reloading config file: " + configFileName);
87289             reloadLevel = ts.ConfigFileProgramReloadLevel.None;
87290             if (cachedDirectoryStructureHost) {
87291                 cachedDirectoryStructureHost.clearCache();
87292             }
87293             parseConfigFile();
87294             hasChangedCompilerOptions = true;
87295             synchronizeProgram();
87296             watchConfigFileWildCardDirectories();
87297         }
87298         function parseConfigFile() {
87299             setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, undefined, watchOptionsToExtend, extraFileExtensions));
87300         }
87301         function setConfigFileParsingResult(configFileParseResult) {
87302             rootFileNames = configFileParseResult.fileNames;
87303             compilerOptions = configFileParseResult.options;
87304             watchOptions = configFileParseResult.watchOptions;
87305             configFileSpecs = configFileParseResult.configFileSpecs;
87306             projectReferences = configFileParseResult.projectReferences;
87307             configFileParsingDiagnostics = ts.getConfigFileParsingDiagnostics(configFileParseResult).slice();
87308             canConfigFileJsonReportNoInputFiles = ts.canJsonReportNoInutFiles(configFileParseResult.raw);
87309             hasChangedConfigFileParsingErrors = true;
87310         }
87311         function onSourceFileChange(fileName, eventKind, path) {
87312             updateCachedSystemWithFile(fileName, path, eventKind);
87313             if (eventKind === ts.FileWatcherEventKind.Deleted && sourceFilesCache.has(path)) {
87314                 resolutionCache.invalidateResolutionOfFile(path);
87315             }
87316             resolutionCache.removeResolutionsFromProjectReferenceRedirects(path);
87317             nextSourceFileVersion(path);
87318             scheduleProgramUpdate();
87319         }
87320         function updateCachedSystemWithFile(fileName, path, eventKind) {
87321             if (cachedDirectoryStructureHost) {
87322                 cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind);
87323             }
87324         }
87325         function watchMissingFilePath(missingFilePath) {
87326             return watchFilePath(host, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, missingFilePath, ts.WatchType.MissingFile);
87327         }
87328         function onMissingFileChange(fileName, eventKind, missingFilePath) {
87329             updateCachedSystemWithFile(fileName, missingFilePath, eventKind);
87330             if (eventKind === ts.FileWatcherEventKind.Created && missingFilesMap.has(missingFilePath)) {
87331                 missingFilesMap.get(missingFilePath).close();
87332                 missingFilesMap.delete(missingFilePath);
87333                 nextSourceFileVersion(missingFilePath);
87334                 scheduleProgramUpdate();
87335             }
87336         }
87337         function watchConfigFileWildCardDirectories() {
87338             if (configFileSpecs) {
87339                 ts.updateWatchingWildcardDirectories(watchedWildcardDirectories || (watchedWildcardDirectories = ts.createMap()), ts.createMapFromTemplate(configFileSpecs.wildcardDirectories), watchWildcardDirectory);
87340             }
87341             else if (watchedWildcardDirectories) {
87342                 ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf);
87343             }
87344         }
87345         function watchWildcardDirectory(directory, flags) {
87346             return watchDirectory(host, directory, function (fileOrDirectory) {
87347                 ts.Debug.assert(!!configFileName);
87348                 var fileOrDirectoryPath = toPath(fileOrDirectory);
87349                 if (cachedDirectoryStructureHost) {
87350                     cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
87351                 }
87352                 nextSourceFileVersion(fileOrDirectoryPath);
87353                 fileOrDirectoryPath = ts.removeIgnoredPath(fileOrDirectoryPath);
87354                 if (!fileOrDirectoryPath)
87355                     return;
87356                 if (fileOrDirectoryPath !== directory && ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, compilerOptions)) {
87357                     writeLog("Project: " + configFileName + " Detected file add/remove of non supported extension: " + fileOrDirectory);
87358                     return;
87359                 }
87360                 if (reloadLevel !== ts.ConfigFileProgramReloadLevel.Full) {
87361                     reloadLevel = ts.ConfigFileProgramReloadLevel.Partial;
87362                     scheduleProgramUpdate();
87363                 }
87364             }, flags, watchOptions, ts.WatchType.WildcardDirectory);
87365         }
87366     }
87367     ts.createWatchProgram = createWatchProgram;
87368 })(ts || (ts = {}));
87369 var ts;
87370 (function (ts) {
87371     var UpToDateStatusType;
87372     (function (UpToDateStatusType) {
87373         UpToDateStatusType[UpToDateStatusType["Unbuildable"] = 0] = "Unbuildable";
87374         UpToDateStatusType[UpToDateStatusType["UpToDate"] = 1] = "UpToDate";
87375         UpToDateStatusType[UpToDateStatusType["UpToDateWithUpstreamTypes"] = 2] = "UpToDateWithUpstreamTypes";
87376         UpToDateStatusType[UpToDateStatusType["OutOfDateWithPrepend"] = 3] = "OutOfDateWithPrepend";
87377         UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
87378         UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
87379         UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
87380         UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate";
87381         UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked";
87382         UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream";
87383         UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 10] = "TsVersionOutputOfDate";
87384         UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly";
87385     })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
87386     function resolveConfigFileProjectName(project) {
87387         if (ts.fileExtensionIs(project, ".json")) {
87388             return project;
87389         }
87390         return ts.combinePaths(project, "tsconfig.json");
87391     }
87392     ts.resolveConfigFileProjectName = resolveConfigFileProjectName;
87393 })(ts || (ts = {}));
87394 var ts;
87395 (function (ts) {
87396     var minimumDate = new Date(-8640000000000000);
87397     var maximumDate = new Date(8640000000000000);
87398     var BuildResultFlags;
87399     (function (BuildResultFlags) {
87400         BuildResultFlags[BuildResultFlags["None"] = 0] = "None";
87401         BuildResultFlags[BuildResultFlags["Success"] = 1] = "Success";
87402         BuildResultFlags[BuildResultFlags["DeclarationOutputUnchanged"] = 2] = "DeclarationOutputUnchanged";
87403         BuildResultFlags[BuildResultFlags["ConfigFileErrors"] = 4] = "ConfigFileErrors";
87404         BuildResultFlags[BuildResultFlags["SyntaxErrors"] = 8] = "SyntaxErrors";
87405         BuildResultFlags[BuildResultFlags["TypeErrors"] = 16] = "TypeErrors";
87406         BuildResultFlags[BuildResultFlags["DeclarationEmitErrors"] = 32] = "DeclarationEmitErrors";
87407         BuildResultFlags[BuildResultFlags["EmitErrors"] = 64] = "EmitErrors";
87408         BuildResultFlags[BuildResultFlags["AnyErrors"] = 124] = "AnyErrors";
87409     })(BuildResultFlags || (BuildResultFlags = {}));
87410     function createConfigFileMap() {
87411         return ts.createMap();
87412     }
87413     function getOrCreateValueFromConfigFileMap(configFileMap, resolved, createT) {
87414         var existingValue = configFileMap.get(resolved);
87415         var newValue;
87416         if (!existingValue) {
87417             newValue = createT();
87418             configFileMap.set(resolved, newValue);
87419         }
87420         return existingValue || newValue;
87421     }
87422     function getOrCreateValueMapFromConfigFileMap(configFileMap, resolved) {
87423         return getOrCreateValueFromConfigFileMap(configFileMap, resolved, ts.createMap);
87424     }
87425     function newer(date1, date2) {
87426         return date2 > date1 ? date2 : date1;
87427     }
87428     function isDeclarationFile(fileName) {
87429         return ts.fileExtensionIs(fileName, ".d.ts");
87430     }
87431     function isCircularBuildOrder(buildOrder) {
87432         return !!buildOrder && !!buildOrder.buildOrder;
87433     }
87434     ts.isCircularBuildOrder = isCircularBuildOrder;
87435     function getBuildOrderFromAnyBuildOrder(anyBuildOrder) {
87436         return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder;
87437     }
87438     ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder;
87439     function createBuilderStatusReporter(system, pretty) {
87440         return function (diagnostic) {
87441             var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - ";
87442             output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine);
87443             system.write(output);
87444         };
87445     }
87446     ts.createBuilderStatusReporter = createBuilderStatusReporter;
87447     function createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus) {
87448         var host = ts.createProgramHost(system, createProgram);
87449         host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : ts.returnUndefined;
87450         host.setModifiedTime = system.setModifiedTime ? function (path, date) { return system.setModifiedTime(path, date); } : ts.noop;
87451         host.deleteFile = system.deleteFile ? function (path) { return system.deleteFile(path); } : ts.noop;
87452         host.reportDiagnostic = reportDiagnostic || ts.createDiagnosticReporter(system);
87453         host.reportSolutionBuilderStatus = reportSolutionBuilderStatus || createBuilderStatusReporter(system);
87454         host.now = ts.maybeBind(system, system.now);
87455         return host;
87456     }
87457     function createSolutionBuilderHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportErrorSummary) {
87458         if (system === void 0) { system = ts.sys; }
87459         var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus);
87460         host.reportErrorSummary = reportErrorSummary;
87461         return host;
87462     }
87463     ts.createSolutionBuilderHost = createSolutionBuilderHost;
87464     function createSolutionBuilderWithWatchHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportWatchStatus) {
87465         if (system === void 0) { system = ts.sys; }
87466         var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus);
87467         var watchHost = ts.createWatchHost(system, reportWatchStatus);
87468         ts.copyProperties(host, watchHost);
87469         return host;
87470     }
87471     ts.createSolutionBuilderWithWatchHost = createSolutionBuilderWithWatchHost;
87472     function getCompilerOptionsOfBuildOptions(buildOptions) {
87473         var result = {};
87474         ts.commonOptionsWithBuild.forEach(function (option) {
87475             if (ts.hasProperty(buildOptions, option.name))
87476                 result[option.name] = buildOptions[option.name];
87477         });
87478         return result;
87479     }
87480     function createSolutionBuilder(host, rootNames, defaultOptions) {
87481         return createSolutionBuilderWorker(false, host, rootNames, defaultOptions);
87482     }
87483     ts.createSolutionBuilder = createSolutionBuilder;
87484     function createSolutionBuilderWithWatch(host, rootNames, defaultOptions, baseWatchOptions) {
87485         return createSolutionBuilderWorker(true, host, rootNames, defaultOptions, baseWatchOptions);
87486     }
87487     ts.createSolutionBuilderWithWatch = createSolutionBuilderWithWatch;
87488     function createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions) {
87489         var host = hostOrHostWithWatch;
87490         var hostWithWatch = hostOrHostWithWatch;
87491         var currentDirectory = host.getCurrentDirectory();
87492         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
87493         var baseCompilerOptions = getCompilerOptionsOfBuildOptions(options);
87494         var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return state.projectCompilerOptions; });
87495         ts.setGetSourceFileAsHashVersioned(compilerHost, host);
87496         compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); };
87497         compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames);
87498         compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives);
87499         var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
87500         if (!compilerHost.resolveModuleNames) {
87501             var loader_3 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule; };
87502             compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference) {
87503                 return ts.loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_3);
87504             };
87505         }
87506         var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchFilePath = _a.watchFilePath, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
87507         var state = {
87508             host: host,
87509             hostWithWatch: hostWithWatch,
87510             currentDirectory: currentDirectory,
87511             getCanonicalFileName: getCanonicalFileName,
87512             parseConfigFileHost: ts.parseConfigHostFromCompilerHostLike(host),
87513             writeFileName: host.trace ? function (s) { return host.trace(s); } : undefined,
87514             options: options,
87515             baseCompilerOptions: baseCompilerOptions,
87516             rootNames: rootNames,
87517             baseWatchOptions: baseWatchOptions,
87518             resolvedConfigFilePaths: ts.createMap(),
87519             configFileCache: createConfigFileMap(),
87520             projectStatus: createConfigFileMap(),
87521             buildInfoChecked: createConfigFileMap(),
87522             extendedConfigCache: ts.createMap(),
87523             builderPrograms: createConfigFileMap(),
87524             diagnostics: createConfigFileMap(),
87525             projectPendingBuild: createConfigFileMap(),
87526             projectErrorsReported: createConfigFileMap(),
87527             compilerHost: compilerHost,
87528             moduleResolutionCache: moduleResolutionCache,
87529             buildOrder: undefined,
87530             readFileWithCache: function (f) { return host.readFile(f); },
87531             projectCompilerOptions: baseCompilerOptions,
87532             cache: undefined,
87533             allProjectBuildPending: true,
87534             needsSummary: true,
87535             watchAllProjectsPending: watch,
87536             currentInvalidatedProject: undefined,
87537             watch: watch,
87538             allWatchedWildcardDirectories: createConfigFileMap(),
87539             allWatchedInputFiles: createConfigFileMap(),
87540             allWatchedConfigFiles: createConfigFileMap(),
87541             timerToBuildInvalidatedProject: undefined,
87542             reportFileChangeDetected: false,
87543             watchFile: watchFile,
87544             watchFilePath: watchFilePath,
87545             watchDirectory: watchDirectory,
87546             writeLog: writeLog,
87547         };
87548         return state;
87549     }
87550     function toPath(state, fileName) {
87551         return ts.toPath(fileName, state.currentDirectory, state.getCanonicalFileName);
87552     }
87553     function toResolvedConfigFilePath(state, fileName) {
87554         var resolvedConfigFilePaths = state.resolvedConfigFilePaths;
87555         var path = resolvedConfigFilePaths.get(fileName);
87556         if (path !== undefined)
87557             return path;
87558         var resolvedPath = toPath(state, fileName);
87559         resolvedConfigFilePaths.set(fileName, resolvedPath);
87560         return resolvedPath;
87561     }
87562     function isParsedCommandLine(entry) {
87563         return !!entry.options;
87564     }
87565     function parseConfigFile(state, configFileName, configFilePath) {
87566         var configFileCache = state.configFileCache;
87567         var value = configFileCache.get(configFilePath);
87568         if (value) {
87569             return isParsedCommandLine(value) ? value : undefined;
87570         }
87571         var diagnostic;
87572         var parseConfigFileHost = state.parseConfigFileHost, baseCompilerOptions = state.baseCompilerOptions, baseWatchOptions = state.baseWatchOptions, extendedConfigCache = state.extendedConfigCache, host = state.host;
87573         var parsed;
87574         if (host.getParsedCommandLine) {
87575             parsed = host.getParsedCommandLine(configFileName);
87576             if (!parsed)
87577                 diagnostic = ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, configFileName);
87578         }
87579         else {
87580             parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = function (d) { return diagnostic = d; };
87581             parsed = ts.getParsedCommandLineOfConfigFile(configFileName, baseCompilerOptions, parseConfigFileHost, extendedConfigCache, baseWatchOptions);
87582             parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = ts.noop;
87583         }
87584         configFileCache.set(configFilePath, parsed || diagnostic);
87585         return parsed;
87586     }
87587     function resolveProjectName(state, name) {
87588         return ts.resolveConfigFileProjectName(ts.resolvePath(state.currentDirectory, name));
87589     }
87590     function createBuildOrder(state, roots) {
87591         var temporaryMarks = ts.createMap();
87592         var permanentMarks = ts.createMap();
87593         var circularityReportStack = [];
87594         var buildOrder;
87595         var circularDiagnostics;
87596         for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) {
87597             var root = roots_1[_i];
87598             visit(root);
87599         }
87600         return circularDiagnostics ?
87601             { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } :
87602             buildOrder || ts.emptyArray;
87603         function visit(configFileName, inCircularContext) {
87604             var projPath = toResolvedConfigFilePath(state, configFileName);
87605             if (permanentMarks.has(projPath))
87606                 return;
87607             if (temporaryMarks.has(projPath)) {
87608                 if (!inCircularContext) {
87609                     (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")));
87610                 }
87611                 return;
87612             }
87613             temporaryMarks.set(projPath, true);
87614             circularityReportStack.push(configFileName);
87615             var parsed = parseConfigFile(state, configFileName, projPath);
87616             if (parsed && parsed.projectReferences) {
87617                 for (var _i = 0, _a = parsed.projectReferences; _i < _a.length; _i++) {
87618                     var ref = _a[_i];
87619                     var resolvedRefPath = resolveProjectName(state, ref.path);
87620                     visit(resolvedRefPath, inCircularContext || ref.circular);
87621                 }
87622             }
87623             circularityReportStack.pop();
87624             permanentMarks.set(projPath, true);
87625             (buildOrder || (buildOrder = [])).push(configFileName);
87626         }
87627     }
87628     function getBuildOrder(state) {
87629         return state.buildOrder || createStateBuildOrder(state);
87630     }
87631     function createStateBuildOrder(state) {
87632         var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }));
87633         state.resolvedConfigFilePaths.clear();
87634         var currentProjects = ts.arrayToSet(getBuildOrderFromAnyBuildOrder(buildOrder), function (resolved) { return toResolvedConfigFilePath(state, resolved); });
87635         var noopOnDelete = { onDeleteValue: ts.noop };
87636         ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete);
87637         ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete);
87638         ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete);
87639         ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete);
87640         ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete);
87641         ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete);
87642         ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete);
87643         if (state.watch) {
87644             ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher });
87645             ts.mutateMapSkippingNewValues(state.allWatchedWildcardDirectories, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcherOf); } });
87646             ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } });
87647         }
87648         return state.buildOrder = buildOrder;
87649     }
87650     function getBuildOrderFor(state, project, onlyReferences) {
87651         var resolvedProject = project && resolveProjectName(state, project);
87652         var buildOrderFromState = getBuildOrder(state);
87653         if (isCircularBuildOrder(buildOrderFromState))
87654             return buildOrderFromState;
87655         if (resolvedProject) {
87656             var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject);
87657             var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; });
87658             if (projectIndex === -1)
87659                 return undefined;
87660         }
87661         var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState;
87662         ts.Debug.assert(!isCircularBuildOrder(buildOrder));
87663         ts.Debug.assert(!onlyReferences || resolvedProject !== undefined);
87664         ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject);
87665         return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder;
87666     }
87667     function enableCache(state) {
87668         if (state.cache) {
87669             disableCache(state);
87670         }
87671         var compilerHost = state.compilerHost, host = state.host;
87672         var originalReadFileWithCache = state.readFileWithCache;
87673         var originalGetSourceFile = compilerHost.getSourceFile;
87674         var _a = ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return toPath(state, fileName); }, function () {
87675             var args = [];
87676             for (var _i = 0; _i < arguments.length; _i++) {
87677                 args[_i] = arguments[_i];
87678             }
87679             return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args));
87680         }), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, getSourceFileWithCache = _a.getSourceFileWithCache, readFileWithCache = _a.readFileWithCache;
87681         state.readFileWithCache = readFileWithCache;
87682         compilerHost.getSourceFile = getSourceFileWithCache;
87683         state.cache = {
87684             originalReadFile: originalReadFile,
87685             originalFileExists: originalFileExists,
87686             originalDirectoryExists: originalDirectoryExists,
87687             originalCreateDirectory: originalCreateDirectory,
87688             originalWriteFile: originalWriteFile,
87689             originalReadFileWithCache: originalReadFileWithCache,
87690             originalGetSourceFile: originalGetSourceFile,
87691         };
87692     }
87693     function disableCache(state) {
87694         if (!state.cache)
87695             return;
87696         var cache = state.cache, host = state.host, compilerHost = state.compilerHost, extendedConfigCache = state.extendedConfigCache, moduleResolutionCache = state.moduleResolutionCache;
87697         host.readFile = cache.originalReadFile;
87698         host.fileExists = cache.originalFileExists;
87699         host.directoryExists = cache.originalDirectoryExists;
87700         host.createDirectory = cache.originalCreateDirectory;
87701         host.writeFile = cache.originalWriteFile;
87702         compilerHost.getSourceFile = cache.originalGetSourceFile;
87703         state.readFileWithCache = cache.originalReadFileWithCache;
87704         extendedConfigCache.clear();
87705         if (moduleResolutionCache) {
87706             moduleResolutionCache.directoryToModuleNameMap.clear();
87707             moduleResolutionCache.moduleNameToDirectoryMap.clear();
87708         }
87709         state.cache = undefined;
87710     }
87711     function clearProjectStatus(state, resolved) {
87712         state.projectStatus.delete(resolved);
87713         state.diagnostics.delete(resolved);
87714     }
87715     function addProjToQueue(_a, proj, reloadLevel) {
87716         var projectPendingBuild = _a.projectPendingBuild;
87717         var value = projectPendingBuild.get(proj);
87718         if (value === undefined) {
87719             projectPendingBuild.set(proj, reloadLevel);
87720         }
87721         else if (value < reloadLevel) {
87722             projectPendingBuild.set(proj, reloadLevel);
87723         }
87724     }
87725     function setupInitialBuild(state, cancellationToken) {
87726         if (!state.allProjectBuildPending)
87727             return;
87728         state.allProjectBuildPending = false;
87729         if (state.options.watch) {
87730             reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode);
87731         }
87732         enableCache(state);
87733         var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state));
87734         buildOrder.forEach(function (configFileName) {
87735             return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None);
87736         });
87737         if (cancellationToken) {
87738             cancellationToken.throwIfCancellationRequested();
87739         }
87740     }
87741     var InvalidatedProjectKind;
87742     (function (InvalidatedProjectKind) {
87743         InvalidatedProjectKind[InvalidatedProjectKind["Build"] = 0] = "Build";
87744         InvalidatedProjectKind[InvalidatedProjectKind["UpdateBundle"] = 1] = "UpdateBundle";
87745         InvalidatedProjectKind[InvalidatedProjectKind["UpdateOutputFileStamps"] = 2] = "UpdateOutputFileStamps";
87746     })(InvalidatedProjectKind = ts.InvalidatedProjectKind || (ts.InvalidatedProjectKind = {}));
87747     function doneInvalidatedProject(state, projectPath) {
87748         state.projectPendingBuild.delete(projectPath);
87749         state.currentInvalidatedProject = undefined;
87750         return state.diagnostics.has(projectPath) ?
87751             ts.ExitStatus.DiagnosticsPresent_OutputsSkipped :
87752             ts.ExitStatus.Success;
87753     }
87754     function createUpdateOutputFileStampsProject(state, project, projectPath, config, buildOrder) {
87755         var updateOutputFileStampsPending = true;
87756         return {
87757             kind: InvalidatedProjectKind.UpdateOutputFileStamps,
87758             project: project,
87759             projectPath: projectPath,
87760             buildOrder: buildOrder,
87761             getCompilerOptions: function () { return config.options; },
87762             getCurrentDirectory: function () { return state.currentDirectory; },
87763             updateOutputFileStatmps: function () {
87764                 updateOutputTimestamps(state, config, projectPath);
87765                 updateOutputFileStampsPending = false;
87766             },
87767             done: function () {
87768                 if (updateOutputFileStampsPending) {
87769                     updateOutputTimestamps(state, config, projectPath);
87770                 }
87771                 return doneInvalidatedProject(state, projectPath);
87772             }
87773         };
87774     }
87775     function createBuildOrUpdateInvalidedProject(kind, state, project, projectPath, projectIndex, config, buildOrder) {
87776         var Step;
87777         (function (Step) {
87778             Step[Step["CreateProgram"] = 0] = "CreateProgram";
87779             Step[Step["SyntaxDiagnostics"] = 1] = "SyntaxDiagnostics";
87780             Step[Step["SemanticDiagnostics"] = 2] = "SemanticDiagnostics";
87781             Step[Step["Emit"] = 3] = "Emit";
87782             Step[Step["EmitBundle"] = 4] = "EmitBundle";
87783             Step[Step["BuildInvalidatedProjectOfBundle"] = 5] = "BuildInvalidatedProjectOfBundle";
87784             Step[Step["QueueReferencingProjects"] = 6] = "QueueReferencingProjects";
87785             Step[Step["Done"] = 7] = "Done";
87786         })(Step || (Step = {}));
87787         var step = kind === InvalidatedProjectKind.Build ? Step.CreateProgram : Step.EmitBundle;
87788         var program;
87789         var buildResult;
87790         var invalidatedProjectOfBundle;
87791         return kind === InvalidatedProjectKind.Build ?
87792             {
87793                 kind: kind,
87794                 project: project,
87795                 projectPath: projectPath,
87796                 buildOrder: buildOrder,
87797                 getCompilerOptions: function () { return config.options; },
87798                 getCurrentDirectory: function () { return state.currentDirectory; },
87799                 getBuilderProgram: function () { return withProgramOrUndefined(ts.identity); },
87800                 getProgram: function () {
87801                     return withProgramOrUndefined(function (program) { return program.getProgramOrUndefined(); });
87802                 },
87803                 getSourceFile: function (fileName) {
87804                     return withProgramOrUndefined(function (program) { return program.getSourceFile(fileName); });
87805                 },
87806                 getSourceFiles: function () {
87807                     return withProgramOrEmptyArray(function (program) { return program.getSourceFiles(); });
87808                 },
87809                 getOptionsDiagnostics: function (cancellationToken) {
87810                     return withProgramOrEmptyArray(function (program) { return program.getOptionsDiagnostics(cancellationToken); });
87811                 },
87812                 getGlobalDiagnostics: function (cancellationToken) {
87813                     return withProgramOrEmptyArray(function (program) { return program.getGlobalDiagnostics(cancellationToken); });
87814                 },
87815                 getConfigFileParsingDiagnostics: function () {
87816                     return withProgramOrEmptyArray(function (program) { return program.getConfigFileParsingDiagnostics(); });
87817                 },
87818                 getSyntacticDiagnostics: function (sourceFile, cancellationToken) {
87819                     return withProgramOrEmptyArray(function (program) { return program.getSyntacticDiagnostics(sourceFile, cancellationToken); });
87820                 },
87821                 getAllDependencies: function (sourceFile) {
87822                     return withProgramOrEmptyArray(function (program) { return program.getAllDependencies(sourceFile); });
87823                 },
87824                 getSemanticDiagnostics: function (sourceFile, cancellationToken) {
87825                     return withProgramOrEmptyArray(function (program) { return program.getSemanticDiagnostics(sourceFile, cancellationToken); });
87826                 },
87827                 getSemanticDiagnosticsOfNextAffectedFile: function (cancellationToken, ignoreSourceFile) {
87828                     return withProgramOrUndefined(function (program) {
87829                         return (program.getSemanticDiagnosticsOfNextAffectedFile) &&
87830                             program.getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile);
87831                     });
87832                 },
87833                 emit: function (targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
87834                     if (targetSourceFile || emitOnlyDtsFiles) {
87835                         return withProgramOrUndefined(function (program) { return program.emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); });
87836                     }
87837                     executeSteps(Step.SemanticDiagnostics, cancellationToken);
87838                     if (step !== Step.Emit)
87839                         return undefined;
87840                     return emit(writeFile, cancellationToken, customTransformers);
87841                 },
87842                 done: done
87843             } :
87844             {
87845                 kind: kind,
87846                 project: project,
87847                 projectPath: projectPath,
87848                 buildOrder: buildOrder,
87849                 getCompilerOptions: function () { return config.options; },
87850                 getCurrentDirectory: function () { return state.currentDirectory; },
87851                 emit: function (writeFile, customTransformers) {
87852                     if (step !== Step.EmitBundle)
87853                         return invalidatedProjectOfBundle;
87854                     return emitBundle(writeFile, customTransformers);
87855                 },
87856                 done: done,
87857             };
87858         function done(cancellationToken, writeFile, customTransformers) {
87859             executeSteps(Step.Done, cancellationToken, writeFile, customTransformers);
87860             return doneInvalidatedProject(state, projectPath);
87861         }
87862         function withProgramOrUndefined(action) {
87863             executeSteps(Step.CreateProgram);
87864             return program && action(program);
87865         }
87866         function withProgramOrEmptyArray(action) {
87867             return withProgramOrUndefined(action) || ts.emptyArray;
87868         }
87869         function createProgram() {
87870             ts.Debug.assert(program === undefined);
87871             if (state.options.dry) {
87872                 reportStatus(state, ts.Diagnostics.A_non_dry_build_would_build_project_0, project);
87873                 buildResult = BuildResultFlags.Success;
87874                 step = Step.QueueReferencingProjects;
87875                 return;
87876             }
87877             if (state.options.verbose)
87878                 reportStatus(state, ts.Diagnostics.Building_project_0, project);
87879             if (config.fileNames.length === 0) {
87880                 reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
87881                 buildResult = BuildResultFlags.None;
87882                 step = Step.QueueReferencingProjects;
87883                 return;
87884             }
87885             var host = state.host, compilerHost = state.compilerHost;
87886             state.projectCompilerOptions = config.options;
87887             updateModuleResolutionCache(state, project, config);
87888             program = host.createProgram(config.fileNames, config.options, compilerHost, getOldProgram(state, projectPath, config), ts.getConfigFileParsingDiagnostics(config), config.projectReferences);
87889             step++;
87890         }
87891         function handleDiagnostics(diagnostics, errorFlags, errorType) {
87892             if (diagnostics.length) {
87893                 buildResult = buildErrors(state, projectPath, program, config, diagnostics, errorFlags, errorType);
87894                 step = Step.QueueReferencingProjects;
87895             }
87896             else {
87897                 step++;
87898             }
87899         }
87900         function getSyntaxDiagnostics(cancellationToken) {
87901             ts.Debug.assertIsDefined(program);
87902             handleDiagnostics(__spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic");
87903         }
87904         function getSemanticDiagnostics(cancellationToken) {
87905             handleDiagnostics(ts.Debug.checkDefined(program).getSemanticDiagnostics(undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic");
87906         }
87907         function emit(writeFileCallback, cancellationToken, customTransformers) {
87908             ts.Debug.assertIsDefined(program);
87909             ts.Debug.assert(step === Step.Emit);
87910             program.backupState();
87911             var declDiagnostics;
87912             var reportDeclarationDiagnostics = function (d) { return (declDiagnostics || (declDiagnostics = [])).push(d); };
87913             var outputFiles = [];
87914             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;
87915             if (declDiagnostics) {
87916                 program.restoreState();
87917                 buildResult = buildErrors(state, projectPath, program, config, declDiagnostics, BuildResultFlags.DeclarationEmitErrors, "Declaration file");
87918                 step = Step.QueueReferencingProjects;
87919                 return {
87920                     emitSkipped: true,
87921                     diagnostics: emitResult.diagnostics
87922                 };
87923             }
87924             var host = state.host, compilerHost = state.compilerHost;
87925             var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
87926             var newestDeclarationFileContentChangedTime = minimumDate;
87927             var anyDtsChanged = false;
87928             var emitterDiagnostics = ts.createDiagnosticCollection();
87929             var emittedOutputs = ts.createMap();
87930             outputFiles.forEach(function (_a) {
87931                 var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
87932                 var priorChangeTime;
87933                 if (!anyDtsChanged && isDeclarationFile(name)) {
87934                     if (host.fileExists(name) && state.readFileWithCache(name) === text) {
87935                         priorChangeTime = host.getModifiedTime(name);
87936                     }
87937                     else {
87938                         resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
87939                         anyDtsChanged = true;
87940                     }
87941                 }
87942                 emittedOutputs.set(toPath(state, name), name);
87943                 ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
87944                 if (priorChangeTime !== undefined) {
87945                     newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime);
87946                 }
87947             });
87948             finishEmit(emitterDiagnostics, emittedOutputs, newestDeclarationFileContentChangedTime, anyDtsChanged, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
87949             return emitResult;
87950         }
87951         function finishEmit(emitterDiagnostics, emittedOutputs, priorNewestUpdateTime, newestDeclarationFileContentChangedTimeIsMaximumDate, oldestOutputFileName, resultFlags) {
87952             var emitDiagnostics = emitterDiagnostics.getDiagnostics();
87953             if (emitDiagnostics.length) {
87954                 buildResult = buildErrors(state, projectPath, program, config, emitDiagnostics, BuildResultFlags.EmitErrors, "Emit");
87955                 step = Step.QueueReferencingProjects;
87956                 return emitDiagnostics;
87957             }
87958             if (state.writeFileName) {
87959                 emittedOutputs.forEach(function (name) { return listEmittedFile(state, config, name); });
87960                 if (program)
87961                     ts.listFiles(program, state.writeFileName);
87962             }
87963             var newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(state, config, priorNewestUpdateTime, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
87964             state.diagnostics.delete(projectPath);
87965             state.projectStatus.set(projectPath, {
87966                 type: ts.UpToDateStatusType.UpToDate,
87967                 newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTimeIsMaximumDate ?
87968                     maximumDate :
87969                     newestDeclarationFileContentChangedTime,
87970                 oldestOutputFileName: oldestOutputFileName
87971             });
87972             afterProgramDone(state, projectPath, program, config);
87973             state.projectCompilerOptions = state.baseCompilerOptions;
87974             step = Step.QueueReferencingProjects;
87975             buildResult = resultFlags;
87976             return emitDiagnostics;
87977         }
87978         function emitBundle(writeFileCallback, customTransformers) {
87979             ts.Debug.assert(kind === InvalidatedProjectKind.UpdateBundle);
87980             if (state.options.dry) {
87981                 reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_output_of_project_0, project);
87982                 buildResult = BuildResultFlags.Success;
87983                 step = Step.QueueReferencingProjects;
87984                 return undefined;
87985             }
87986             if (state.options.verbose)
87987                 reportStatus(state, ts.Diagnostics.Updating_output_of_project_0, project);
87988             var compilerHost = state.compilerHost;
87989             state.projectCompilerOptions = config.options;
87990             var outputFiles = ts.emitUsingBuildInfo(config, compilerHost, function (ref) {
87991                 var refName = resolveProjectName(state, ref.path);
87992                 return parseConfigFile(state, refName, toResolvedConfigFilePath(state, refName));
87993             }, customTransformers);
87994             if (ts.isString(outputFiles)) {
87995                 reportStatus(state, ts.Diagnostics.Cannot_update_output_of_project_0_because_there_was_error_reading_file_1, project, relName(state, outputFiles));
87996                 step = Step.BuildInvalidatedProjectOfBundle;
87997                 return invalidatedProjectOfBundle = createBuildOrUpdateInvalidedProject(InvalidatedProjectKind.Build, state, project, projectPath, projectIndex, config, buildOrder);
87998             }
87999             ts.Debug.assert(!!outputFiles.length);
88000             var emitterDiagnostics = ts.createDiagnosticCollection();
88001             var emittedOutputs = ts.createMap();
88002             outputFiles.forEach(function (_a) {
88003                 var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
88004                 emittedOutputs.set(toPath(state, name), name);
88005                 ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
88006             });
88007             var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, minimumDate, false, outputFiles[0].name, BuildResultFlags.DeclarationOutputUnchanged);
88008             return { emitSkipped: false, diagnostics: emitDiagnostics };
88009         }
88010         function executeSteps(till, cancellationToken, writeFile, customTransformers) {
88011             while (step <= till && step < Step.Done) {
88012                 var currentStep = step;
88013                 switch (step) {
88014                     case Step.CreateProgram:
88015                         createProgram();
88016                         break;
88017                     case Step.SyntaxDiagnostics:
88018                         getSyntaxDiagnostics(cancellationToken);
88019                         break;
88020                     case Step.SemanticDiagnostics:
88021                         getSemanticDiagnostics(cancellationToken);
88022                         break;
88023                     case Step.Emit:
88024                         emit(writeFile, cancellationToken, customTransformers);
88025                         break;
88026                     case Step.EmitBundle:
88027                         emitBundle(writeFile, customTransformers);
88028                         break;
88029                     case Step.BuildInvalidatedProjectOfBundle:
88030                         ts.Debug.checkDefined(invalidatedProjectOfBundle).done(cancellationToken);
88031                         step = Step.Done;
88032                         break;
88033                     case Step.QueueReferencingProjects:
88034                         queueReferencingProjects(state, project, projectPath, projectIndex, config, buildOrder, ts.Debug.checkDefined(buildResult));
88035                         step++;
88036                         break;
88037                     case Step.Done:
88038                     default:
88039                         ts.assertType(step);
88040                 }
88041                 ts.Debug.assert(step > currentStep);
88042             }
88043         }
88044     }
88045     function needsBuild(_a, status, config) {
88046         var options = _a.options;
88047         if (status.type !== ts.UpToDateStatusType.OutOfDateWithPrepend || options.force)
88048             return true;
88049         return config.fileNames.length === 0 ||
88050             !!ts.getConfigFileParsingDiagnostics(config).length ||
88051             !ts.isIncrementalCompilation(config.options);
88052     }
88053     function getNextInvalidatedProject(state, buildOrder, reportQueue) {
88054         if (!state.projectPendingBuild.size)
88055             return undefined;
88056         if (isCircularBuildOrder(buildOrder))
88057             return undefined;
88058         if (state.currentInvalidatedProject) {
88059             return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ?
88060                 state.currentInvalidatedProject :
88061                 undefined;
88062         }
88063         var options = state.options, projectPendingBuild = state.projectPendingBuild;
88064         for (var projectIndex = 0; projectIndex < buildOrder.length; projectIndex++) {
88065             var project = buildOrder[projectIndex];
88066             var projectPath = toResolvedConfigFilePath(state, project);
88067             var reloadLevel = state.projectPendingBuild.get(projectPath);
88068             if (reloadLevel === undefined)
88069                 continue;
88070             if (reportQueue) {
88071                 reportQueue = false;
88072                 reportBuildQueue(state, buildOrder);
88073             }
88074             var config = parseConfigFile(state, project, projectPath);
88075             if (!config) {
88076                 reportParseConfigFileDiagnostic(state, projectPath);
88077                 projectPendingBuild.delete(projectPath);
88078                 continue;
88079             }
88080             if (reloadLevel === ts.ConfigFileProgramReloadLevel.Full) {
88081                 watchConfigFile(state, project, projectPath, config);
88082                 watchWildCardDirectories(state, project, projectPath, config);
88083                 watchInputFiles(state, project, projectPath, config);
88084             }
88085             else if (reloadLevel === ts.ConfigFileProgramReloadLevel.Partial) {
88086                 var result = ts.getFileNamesFromConfigSpecs(config.configFileSpecs, ts.getDirectoryPath(project), config.options, state.parseConfigFileHost);
88087                 ts.updateErrorForNoInputFiles(result, project, config.configFileSpecs, config.errors, ts.canJsonReportNoInutFiles(config.raw));
88088                 config.fileNames = result.fileNames;
88089                 watchInputFiles(state, project, projectPath, config);
88090             }
88091             var status = getUpToDateStatus(state, config, projectPath);
88092             verboseReportProjectStatus(state, project, status);
88093             if (!options.force) {
88094                 if (status.type === ts.UpToDateStatusType.UpToDate) {
88095                     reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
88096                     projectPendingBuild.delete(projectPath);
88097                     if (options.dry) {
88098                         reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date, project);
88099                     }
88100                     continue;
88101                 }
88102                 if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes) {
88103                     reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
88104                     return createUpdateOutputFileStampsProject(state, project, projectPath, config, buildOrder);
88105                 }
88106             }
88107             if (status.type === ts.UpToDateStatusType.UpstreamBlocked) {
88108                 reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
88109                 projectPendingBuild.delete(projectPath);
88110                 if (options.verbose) {
88111                     reportStatus(state, status.upstreamProjectBlocked ?
88112                         ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built :
88113                         ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName);
88114                 }
88115                 continue;
88116             }
88117             if (status.type === ts.UpToDateStatusType.ContainerOnly) {
88118                 reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
88119                 projectPendingBuild.delete(projectPath);
88120                 continue;
88121             }
88122             return createBuildOrUpdateInvalidedProject(needsBuild(state, status, config) ?
88123                 InvalidatedProjectKind.Build :
88124                 InvalidatedProjectKind.UpdateBundle, state, project, projectPath, projectIndex, config, buildOrder);
88125         }
88126         return undefined;
88127     }
88128     function listEmittedFile(_a, proj, file) {
88129         var writeFileName = _a.writeFileName;
88130         if (writeFileName && proj.options.listEmittedFiles) {
88131             writeFileName("TSFILE: " + file);
88132         }
88133     }
88134     function getOldProgram(_a, proj, parsed) {
88135         var options = _a.options, builderPrograms = _a.builderPrograms, compilerHost = _a.compilerHost;
88136         if (options.force)
88137             return undefined;
88138         var value = builderPrograms.get(proj);
88139         if (value)
88140             return value;
88141         return ts.readBuilderProgram(parsed.options, compilerHost);
88142     }
88143     function afterProgramDone(_a, proj, program, config) {
88144         var host = _a.host, watch = _a.watch, builderPrograms = _a.builderPrograms;
88145         if (program) {
88146             if (host.afterProgramEmitAndDiagnostics) {
88147                 host.afterProgramEmitAndDiagnostics(program);
88148             }
88149             if (watch) {
88150                 program.releaseProgram();
88151                 builderPrograms.set(proj, program);
88152             }
88153         }
88154         else if (host.afterEmitBundle) {
88155             host.afterEmitBundle(config);
88156         }
88157     }
88158     function buildErrors(state, resolvedPath, program, config, diagnostics, errorFlags, errorType) {
88159         reportAndStoreErrors(state, resolvedPath, diagnostics);
88160         if (program && state.writeFileName)
88161             ts.listFiles(program, state.writeFileName);
88162         state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" });
88163         afterProgramDone(state, resolvedPath, program, config);
88164         state.projectCompilerOptions = state.baseCompilerOptions;
88165         return errorFlags;
88166     }
88167     function updateModuleResolutionCache(state, proj, config) {
88168         if (!state.moduleResolutionCache)
88169             return;
88170         var moduleResolutionCache = state.moduleResolutionCache;
88171         var projPath = toPath(state, proj);
88172         if (moduleResolutionCache.directoryToModuleNameMap.redirectsMap.size === 0) {
88173             ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size === 0);
88174             moduleResolutionCache.directoryToModuleNameMap.redirectsMap.set(projPath, moduleResolutionCache.directoryToModuleNameMap.ownMap);
88175             moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.set(projPath, moduleResolutionCache.moduleNameToDirectoryMap.ownMap);
88176         }
88177         else {
88178             ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size > 0);
88179             var ref = {
88180                 sourceFile: config.options.configFile,
88181                 commandLine: config
88182             };
88183             moduleResolutionCache.directoryToModuleNameMap.setOwnMap(moduleResolutionCache.directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref));
88184             moduleResolutionCache.moduleNameToDirectoryMap.setOwnMap(moduleResolutionCache.moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref));
88185         }
88186         moduleResolutionCache.directoryToModuleNameMap.setOwnOptions(config.options);
88187         moduleResolutionCache.moduleNameToDirectoryMap.setOwnOptions(config.options);
88188     }
88189     function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) {
88190         var tsconfigTime = state.host.getModifiedTime(configFile) || ts.missingFileModifiedTime;
88191         if (oldestOutputFileTime < tsconfigTime) {
88192             return {
88193                 type: ts.UpToDateStatusType.OutOfDateWithSelf,
88194                 outOfDateOutputFileName: oldestOutputFileName,
88195                 newerInputFileName: configFile
88196             };
88197         }
88198     }
88199     function getUpToDateStatusWorker(state, project, resolvedPath) {
88200         var newestInputFileName = undefined;
88201         var newestInputFileTime = minimumDate;
88202         var host = state.host;
88203         for (var _i = 0, _a = project.fileNames; _i < _a.length; _i++) {
88204             var inputFile = _a[_i];
88205             if (!host.fileExists(inputFile)) {
88206                 return {
88207                     type: ts.UpToDateStatusType.Unbuildable,
88208                     reason: inputFile + " does not exist"
88209                 };
88210             }
88211             var inputTime = host.getModifiedTime(inputFile) || ts.missingFileModifiedTime;
88212             if (inputTime > newestInputFileTime) {
88213                 newestInputFileName = inputFile;
88214                 newestInputFileTime = inputTime;
88215             }
88216         }
88217         if (!project.fileNames.length && !ts.canJsonReportNoInutFiles(project.raw)) {
88218             return {
88219                 type: ts.UpToDateStatusType.ContainerOnly
88220             };
88221         }
88222         var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
88223         var oldestOutputFileName = "(none)";
88224         var oldestOutputFileTime = maximumDate;
88225         var newestOutputFileName = "(none)";
88226         var newestOutputFileTime = minimumDate;
88227         var missingOutputFileName;
88228         var newestDeclarationFileContentChangedTime = minimumDate;
88229         var isOutOfDateWithInputs = false;
88230         for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) {
88231             var output = outputs_1[_b];
88232             if (!host.fileExists(output)) {
88233                 missingOutputFileName = output;
88234                 break;
88235             }
88236             var outputTime = host.getModifiedTime(output) || ts.missingFileModifiedTime;
88237             if (outputTime < oldestOutputFileTime) {
88238                 oldestOutputFileTime = outputTime;
88239                 oldestOutputFileName = output;
88240             }
88241             if (outputTime < newestInputFileTime) {
88242                 isOutOfDateWithInputs = true;
88243                 break;
88244             }
88245             if (outputTime > newestOutputFileTime) {
88246                 newestOutputFileTime = outputTime;
88247                 newestOutputFileName = output;
88248             }
88249             if (isDeclarationFile(output)) {
88250                 var outputModifiedTime = host.getModifiedTime(output) || ts.missingFileModifiedTime;
88251                 newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
88252             }
88253         }
88254         var pseudoUpToDate = false;
88255         var usesPrepend = false;
88256         var upstreamChangedProject;
88257         if (project.projectReferences) {
88258             state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream });
88259             for (var _c = 0, _d = project.projectReferences; _c < _d.length; _c++) {
88260                 var ref = _d[_c];
88261                 usesPrepend = usesPrepend || !!(ref.prepend);
88262                 var resolvedRef = ts.resolveProjectReferencePath(ref);
88263                 var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef);
88264                 var refStatus = getUpToDateStatus(state, parseConfigFile(state, resolvedRef, resolvedRefPath), resolvedRefPath);
88265                 if (refStatus.type === ts.UpToDateStatusType.ComputingUpstream ||
88266                     refStatus.type === ts.UpToDateStatusType.ContainerOnly) {
88267                     continue;
88268                 }
88269                 if (refStatus.type === ts.UpToDateStatusType.Unbuildable ||
88270                     refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) {
88271                     return {
88272                         type: ts.UpToDateStatusType.UpstreamBlocked,
88273                         upstreamProjectName: ref.path,
88274                         upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked
88275                     };
88276                 }
88277                 if (refStatus.type !== ts.UpToDateStatusType.UpToDate) {
88278                     return {
88279                         type: ts.UpToDateStatusType.UpstreamOutOfDate,
88280                         upstreamProjectName: ref.path
88281                     };
88282                 }
88283                 if (!missingOutputFileName) {
88284                     if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
88285                         continue;
88286                     }
88287                     if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
88288                         pseudoUpToDate = true;
88289                         upstreamChangedProject = ref.path;
88290                         continue;
88291                     }
88292                     ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
88293                     return {
88294                         type: ts.UpToDateStatusType.OutOfDateWithUpstream,
88295                         outOfDateOutputFileName: oldestOutputFileName,
88296                         newerProjectName: ref.path
88297                     };
88298                 }
88299             }
88300         }
88301         if (missingOutputFileName !== undefined) {
88302             return {
88303                 type: ts.UpToDateStatusType.OutputMissing,
88304                 missingOutputFileName: missingOutputFileName
88305             };
88306         }
88307         if (isOutOfDateWithInputs) {
88308             return {
88309                 type: ts.UpToDateStatusType.OutOfDateWithSelf,
88310                 outOfDateOutputFileName: oldestOutputFileName,
88311                 newerInputFileName: newestInputFileName
88312             };
88313         }
88314         else {
88315             var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
88316             if (configStatus)
88317                 return configStatus;
88318             var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
88319             if (extendedConfigStatus)
88320                 return extendedConfigStatus;
88321         }
88322         if (!state.buildInfoChecked.has(resolvedPath)) {
88323             state.buildInfoChecked.set(resolvedPath, true);
88324             var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
88325             if (buildInfoPath) {
88326                 var value = state.readFileWithCache(buildInfoPath);
88327                 var buildInfo = value && ts.getBuildInfo(value);
88328                 if (buildInfo && (buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
88329                     return {
88330                         type: ts.UpToDateStatusType.TsVersionOutputOfDate,
88331                         version: buildInfo.version
88332                     };
88333                 }
88334             }
88335         }
88336         if (usesPrepend && pseudoUpToDate) {
88337             return {
88338                 type: ts.UpToDateStatusType.OutOfDateWithPrepend,
88339                 outOfDateOutputFileName: oldestOutputFileName,
88340                 newerProjectName: upstreamChangedProject
88341             };
88342         }
88343         return {
88344             type: pseudoUpToDate ? ts.UpToDateStatusType.UpToDateWithUpstreamTypes : ts.UpToDateStatusType.UpToDate,
88345             newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime,
88346             newestInputFileTime: newestInputFileTime,
88347             newestOutputFileTime: newestOutputFileTime,
88348             newestInputFileName: newestInputFileName,
88349             newestOutputFileName: newestOutputFileName,
88350             oldestOutputFileName: oldestOutputFileName
88351         };
88352     }
88353     function getUpToDateStatus(state, project, resolvedPath) {
88354         if (project === undefined) {
88355             return { type: ts.UpToDateStatusType.Unbuildable, reason: "File deleted mid-build" };
88356         }
88357         var prior = state.projectStatus.get(resolvedPath);
88358         if (prior !== undefined) {
88359             return prior;
88360         }
88361         var actual = getUpToDateStatusWorker(state, project, resolvedPath);
88362         state.projectStatus.set(resolvedPath, actual);
88363         return actual;
88364     }
88365     function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) {
88366         var host = state.host;
88367         var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
88368         if (!skipOutputs || outputs.length !== skipOutputs.size) {
88369             var reportVerbose = !!state.options.verbose;
88370             var now = host.now ? host.now() : new Date();
88371             for (var _i = 0, outputs_2 = outputs; _i < outputs_2.length; _i++) {
88372                 var file = outputs_2[_i];
88373                 if (skipOutputs && skipOutputs.has(toPath(state, file))) {
88374                     continue;
88375                 }
88376                 if (reportVerbose) {
88377                     reportVerbose = false;
88378                     reportStatus(state, verboseMessage, proj.options.configFilePath);
88379                 }
88380                 if (isDeclarationFile(file)) {
88381                     priorNewestUpdateTime = newer(priorNewestUpdateTime, host.getModifiedTime(file) || ts.missingFileModifiedTime);
88382                 }
88383                 host.setModifiedTime(file, now);
88384             }
88385         }
88386         return priorNewestUpdateTime;
88387     }
88388     function updateOutputTimestamps(state, proj, resolvedPath) {
88389         if (state.options.dry) {
88390             return reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath);
88391         }
88392         var priorNewestUpdateTime = updateOutputTimestampsWorker(state, proj, minimumDate, ts.Diagnostics.Updating_output_timestamps_of_project_0);
88393         state.projectStatus.set(resolvedPath, {
88394             type: ts.UpToDateStatusType.UpToDate,
88395             newestDeclarationFileContentChangedTime: priorNewestUpdateTime,
88396             oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames())
88397         });
88398     }
88399     function queueReferencingProjects(state, project, projectPath, projectIndex, config, buildOrder, buildResult) {
88400         if (buildResult & BuildResultFlags.AnyErrors)
88401             return;
88402         if (!config.options.composite)
88403             return;
88404         for (var index = projectIndex + 1; index < buildOrder.length; index++) {
88405             var nextProject = buildOrder[index];
88406             var nextProjectPath = toResolvedConfigFilePath(state, nextProject);
88407             if (state.projectPendingBuild.has(nextProjectPath))
88408                 continue;
88409             var nextProjectConfig = parseConfigFile(state, nextProject, nextProjectPath);
88410             if (!nextProjectConfig || !nextProjectConfig.projectReferences)
88411                 continue;
88412             for (var _i = 0, _a = nextProjectConfig.projectReferences; _i < _a.length; _i++) {
88413                 var ref = _a[_i];
88414                 var resolvedRefPath = resolveProjectName(state, ref.path);
88415                 if (toResolvedConfigFilePath(state, resolvedRefPath) !== projectPath)
88416                     continue;
88417                 var status = state.projectStatus.get(nextProjectPath);
88418                 if (status) {
88419                     switch (status.type) {
88420                         case ts.UpToDateStatusType.UpToDate:
88421                             if (buildResult & BuildResultFlags.DeclarationOutputUnchanged) {
88422                                 if (ref.prepend) {
88423                                     state.projectStatus.set(nextProjectPath, {
88424                                         type: ts.UpToDateStatusType.OutOfDateWithPrepend,
88425                                         outOfDateOutputFileName: status.oldestOutputFileName,
88426                                         newerProjectName: project
88427                                     });
88428                                 }
88429                                 else {
88430                                     status.type = ts.UpToDateStatusType.UpToDateWithUpstreamTypes;
88431                                 }
88432                                 break;
88433                             }
88434                         case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
88435                         case ts.UpToDateStatusType.OutOfDateWithPrepend:
88436                             if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) {
88437                                 state.projectStatus.set(nextProjectPath, {
88438                                     type: ts.UpToDateStatusType.OutOfDateWithUpstream,
88439                                     outOfDateOutputFileName: status.type === ts.UpToDateStatusType.OutOfDateWithPrepend ? status.outOfDateOutputFileName : status.oldestOutputFileName,
88440                                     newerProjectName: project
88441                                 });
88442                             }
88443                             break;
88444                         case ts.UpToDateStatusType.UpstreamBlocked:
88445                             if (toResolvedConfigFilePath(state, resolveProjectName(state, status.upstreamProjectName)) === projectPath) {
88446                                 clearProjectStatus(state, nextProjectPath);
88447                             }
88448                             break;
88449                     }
88450                 }
88451                 addProjToQueue(state, nextProjectPath, ts.ConfigFileProgramReloadLevel.None);
88452                 break;
88453             }
88454         }
88455     }
88456     function build(state, project, cancellationToken, onlyReferences) {
88457         var buildOrder = getBuildOrderFor(state, project, onlyReferences);
88458         if (!buildOrder)
88459             return ts.ExitStatus.InvalidProject_OutputsSkipped;
88460         setupInitialBuild(state, cancellationToken);
88461         var reportQueue = true;
88462         var successfulProjects = 0;
88463         while (true) {
88464             var invalidatedProject = getNextInvalidatedProject(state, buildOrder, reportQueue);
88465             if (!invalidatedProject)
88466                 break;
88467             reportQueue = false;
88468             invalidatedProject.done(cancellationToken);
88469             if (!state.diagnostics.has(invalidatedProject.projectPath))
88470                 successfulProjects++;
88471         }
88472         disableCache(state);
88473         reportErrorSummary(state, buildOrder);
88474         startWatching(state, buildOrder);
88475         return isCircularBuildOrder(buildOrder)
88476             ? ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped
88477             : !buildOrder.some(function (p) { return state.diagnostics.has(toResolvedConfigFilePath(state, p)); })
88478                 ? ts.ExitStatus.Success
88479                 : successfulProjects
88480                     ? ts.ExitStatus.DiagnosticsPresent_OutputsGenerated
88481                     : ts.ExitStatus.DiagnosticsPresent_OutputsSkipped;
88482     }
88483     function clean(state, project, onlyReferences) {
88484         var buildOrder = getBuildOrderFor(state, project, onlyReferences);
88485         if (!buildOrder)
88486             return ts.ExitStatus.InvalidProject_OutputsSkipped;
88487         if (isCircularBuildOrder(buildOrder)) {
88488             reportErrors(state, buildOrder.circularDiagnostics);
88489             return ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped;
88490         }
88491         var options = state.options, host = state.host;
88492         var filesToDelete = options.dry ? [] : undefined;
88493         for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) {
88494             var proj = buildOrder_1[_i];
88495             var resolvedPath = toResolvedConfigFilePath(state, proj);
88496             var parsed = parseConfigFile(state, proj, resolvedPath);
88497             if (parsed === undefined) {
88498                 reportParseConfigFileDiagnostic(state, resolvedPath);
88499                 continue;
88500             }
88501             var outputs = ts.getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames());
88502             for (var _a = 0, outputs_3 = outputs; _a < outputs_3.length; _a++) {
88503                 var output = outputs_3[_a];
88504                 if (host.fileExists(output)) {
88505                     if (filesToDelete) {
88506                         filesToDelete.push(output);
88507                     }
88508                     else {
88509                         host.deleteFile(output);
88510                         invalidateProject(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None);
88511                     }
88512                 }
88513             }
88514         }
88515         if (filesToDelete) {
88516             reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * " + f; }).join(""));
88517         }
88518         return ts.ExitStatus.Success;
88519     }
88520     function invalidateProject(state, resolved, reloadLevel) {
88521         if (state.host.getParsedCommandLine && reloadLevel === ts.ConfigFileProgramReloadLevel.Partial) {
88522             reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
88523         }
88524         if (reloadLevel === ts.ConfigFileProgramReloadLevel.Full) {
88525             state.configFileCache.delete(resolved);
88526             state.buildOrder = undefined;
88527         }
88528         state.needsSummary = true;
88529         clearProjectStatus(state, resolved);
88530         addProjToQueue(state, resolved, reloadLevel);
88531         enableCache(state);
88532     }
88533     function invalidateProjectAndScheduleBuilds(state, resolvedPath, reloadLevel) {
88534         state.reportFileChangeDetected = true;
88535         invalidateProject(state, resolvedPath, reloadLevel);
88536         scheduleBuildInvalidatedProject(state);
88537     }
88538     function scheduleBuildInvalidatedProject(state) {
88539         var hostWithWatch = state.hostWithWatch;
88540         if (!hostWithWatch.setTimeout || !hostWithWatch.clearTimeout) {
88541             return;
88542         }
88543         if (state.timerToBuildInvalidatedProject) {
88544             hostWithWatch.clearTimeout(state.timerToBuildInvalidatedProject);
88545         }
88546         state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, 250, state);
88547     }
88548     function buildNextInvalidatedProject(state) {
88549         state.timerToBuildInvalidatedProject = undefined;
88550         if (state.reportFileChangeDetected) {
88551             state.reportFileChangeDetected = false;
88552             state.projectErrorsReported.clear();
88553             reportWatchStatus(state, ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
88554         }
88555         var buildOrder = getBuildOrder(state);
88556         var invalidatedProject = getNextInvalidatedProject(state, buildOrder, false);
88557         if (invalidatedProject) {
88558             invalidatedProject.done();
88559             if (state.projectPendingBuild.size) {
88560                 if (state.watch && !state.timerToBuildInvalidatedProject) {
88561                     scheduleBuildInvalidatedProject(state);
88562                 }
88563                 return;
88564             }
88565         }
88566         disableCache(state);
88567         reportErrorSummary(state, buildOrder);
88568     }
88569     function watchConfigFile(state, resolved, resolvedPath, parsed) {
88570         if (!state.watch || state.allWatchedConfigFiles.has(resolvedPath))
88571             return;
88572         state.allWatchedConfigFiles.set(resolvedPath, state.watchFile(state.hostWithWatch, resolved, function () {
88573             invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full);
88574         }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved));
88575     }
88576     function isSameFile(state, file1, file2) {
88577         return ts.comparePaths(file1, file2, state.currentDirectory, !state.host.useCaseSensitiveFileNames()) === 0;
88578     }
88579     function isOutputFile(state, fileName, configFile) {
88580         if (configFile.options.noEmit)
88581             return false;
88582         if (!ts.fileExtensionIs(fileName, ".d.ts") &&
88583             (ts.fileExtensionIs(fileName, ".ts") || ts.fileExtensionIs(fileName, ".tsx"))) {
88584             return false;
88585         }
88586         var out = configFile.options.outFile || configFile.options.out;
88587         if (out && (isSameFile(state, fileName, out) || isSameFile(state, fileName, ts.removeFileExtension(out) + ".d.ts"))) {
88588             return true;
88589         }
88590         if (configFile.options.declarationDir && ts.containsPath(configFile.options.declarationDir, fileName, state.currentDirectory, !state.host.useCaseSensitiveFileNames())) {
88591             return true;
88592         }
88593         if (configFile.options.outDir && ts.containsPath(configFile.options.outDir, fileName, state.currentDirectory, !state.host.useCaseSensitiveFileNames())) {
88594             return true;
88595         }
88596         return !ts.forEach(configFile.fileNames, function (inputFile) { return isSameFile(state, fileName, inputFile); });
88597     }
88598     function watchWildCardDirectories(state, resolved, resolvedPath, parsed) {
88599         if (!state.watch)
88600             return;
88601         ts.updateWatchingWildcardDirectories(getOrCreateValueMapFromConfigFileMap(state.allWatchedWildcardDirectories, resolvedPath), ts.createMapFromTemplate(parsed.configFileSpecs.wildcardDirectories), function (dir, flags) { return state.watchDirectory(state.hostWithWatch, dir, function (fileOrDirectory) {
88602             var fileOrDirectoryPath = toPath(state, fileOrDirectory);
88603             if (fileOrDirectoryPath !== toPath(state, dir) && ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, parsed.options)) {
88604                 state.writeLog("Project: " + resolved + " Detected file add/remove of non supported extension: " + fileOrDirectory);
88605                 return;
88606             }
88607             if (isOutputFile(state, fileOrDirectory, parsed)) {
88608                 state.writeLog(fileOrDirectory + " is output file");
88609                 return;
88610             }
88611             invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Partial);
88612         }, flags, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.WildcardDirectory, resolved); });
88613     }
88614     function watchInputFiles(state, resolved, resolvedPath, parsed) {
88615         if (!state.watch)
88616             return;
88617         ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedInputFiles, resolvedPath), ts.arrayToMap(parsed.fileNames, function (fileName) { return toPath(state, fileName); }), {
88618             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); },
88619             onDeleteValue: ts.closeFileWatcher,
88620         });
88621     }
88622     function startWatching(state, buildOrder) {
88623         if (!state.watchAllProjectsPending)
88624             return;
88625         state.watchAllProjectsPending = false;
88626         for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) {
88627             var resolved = _a[_i];
88628             var resolvedPath = toResolvedConfigFilePath(state, resolved);
88629             var cfg = parseConfigFile(state, resolved, resolvedPath);
88630             watchConfigFile(state, resolved, resolvedPath, cfg);
88631             if (cfg) {
88632                 watchWildCardDirectories(state, resolved, resolvedPath, cfg);
88633                 watchInputFiles(state, resolved, resolvedPath, cfg);
88634             }
88635         }
88636     }
88637     function stopWatching(state) {
88638         ts.clearMap(state.allWatchedConfigFiles, ts.closeFileWatcher);
88639         ts.clearMap(state.allWatchedWildcardDirectories, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf); });
88640         ts.clearMap(state.allWatchedInputFiles, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcher); });
88641     }
88642     function createSolutionBuilderWorker(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions) {
88643         var state = createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions);
88644         return {
88645             build: function (project, cancellationToken) { return build(state, project, cancellationToken); },
88646             clean: function (project) { return clean(state, project); },
88647             buildReferences: function (project, cancellationToken) { return build(state, project, cancellationToken, true); },
88648             cleanReferences: function (project) { return clean(state, project, true); },
88649             getNextInvalidatedProject: function (cancellationToken) {
88650                 setupInitialBuild(state, cancellationToken);
88651                 return getNextInvalidatedProject(state, getBuildOrder(state), false);
88652             },
88653             getBuildOrder: function () { return getBuildOrder(state); },
88654             getUpToDateStatusOfProject: function (project) {
88655                 var configFileName = resolveProjectName(state, project);
88656                 var configFilePath = toResolvedConfigFilePath(state, configFileName);
88657                 return getUpToDateStatus(state, parseConfigFile(state, configFileName, configFilePath), configFilePath);
88658             },
88659             invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); },
88660             buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); },
88661             getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); },
88662             close: function () { return stopWatching(state); },
88663         };
88664     }
88665     function relName(state, path) {
88666         return ts.convertToRelativePath(path, state.currentDirectory, function (f) { return state.getCanonicalFileName(f); });
88667     }
88668     function reportStatus(state, message) {
88669         var args = [];
88670         for (var _i = 2; _i < arguments.length; _i++) {
88671             args[_i - 2] = arguments[_i];
88672         }
88673         state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)));
88674     }
88675     function reportWatchStatus(state, message) {
88676         var args = [];
88677         for (var _i = 2; _i < arguments.length; _i++) {
88678             args[_i - 2] = arguments[_i];
88679         }
88680         if (state.hostWithWatch.onWatchStatusChange) {
88681             state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)), state.host.getNewLine(), state.baseCompilerOptions);
88682         }
88683     }
88684     function reportErrors(_a, errors) {
88685         var host = _a.host;
88686         errors.forEach(function (err) { return host.reportDiagnostic(err); });
88687     }
88688     function reportAndStoreErrors(state, proj, errors) {
88689         reportErrors(state, errors);
88690         state.projectErrorsReported.set(proj, true);
88691         if (errors.length) {
88692             state.diagnostics.set(proj, errors);
88693         }
88694     }
88695     function reportParseConfigFileDiagnostic(state, proj) {
88696         reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]);
88697     }
88698     function reportErrorSummary(state, buildOrder) {
88699         if (!state.needsSummary)
88700             return;
88701         state.needsSummary = false;
88702         var canReportSummary = state.watch || !!state.host.reportErrorSummary;
88703         var diagnostics = state.diagnostics;
88704         var totalErrors = 0;
88705         if (isCircularBuildOrder(buildOrder)) {
88706             reportBuildQueue(state, buildOrder.buildOrder);
88707             reportErrors(state, buildOrder.circularDiagnostics);
88708             if (canReportSummary)
88709                 totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics);
88710         }
88711         else {
88712             buildOrder.forEach(function (project) {
88713                 var projectPath = toResolvedConfigFilePath(state, project);
88714                 if (!state.projectErrorsReported.has(projectPath)) {
88715                     reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray);
88716                 }
88717             });
88718             if (canReportSummary)
88719                 diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); });
88720         }
88721         if (state.watch) {
88722             reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors);
88723         }
88724         else if (state.host.reportErrorSummary) {
88725             state.host.reportErrorSummary(totalErrors);
88726         }
88727     }
88728     function reportBuildQueue(state, buildQueue) {
88729         if (state.options.verbose) {
88730             reportStatus(state, ts.Diagnostics.Projects_in_this_build_Colon_0, buildQueue.map(function (s) { return "\r\n    * " + relName(state, s); }).join(""));
88731         }
88732     }
88733     function reportUpToDateStatus(state, configFileName, status) {
88734         switch (status.type) {
88735             case ts.UpToDateStatusType.OutOfDateWithSelf:
88736                 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));
88737             case ts.UpToDateStatusType.OutOfDateWithUpstream:
88738                 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));
88739             case ts.UpToDateStatusType.OutputMissing:
88740                 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));
88741             case ts.UpToDateStatusType.UpToDate:
88742                 if (status.newestInputFileTime !== undefined) {
88743                     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 || ""));
88744                 }
88745                 break;
88746             case ts.UpToDateStatusType.OutOfDateWithPrepend:
88747                 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));
88748             case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
88749                 return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, relName(state, configFileName));
88750             case ts.UpToDateStatusType.UpstreamOutOfDate:
88751                 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));
88752             case ts.UpToDateStatusType.UpstreamBlocked:
88753                 return reportStatus(state, status.upstreamProjectBlocked ?
88754                     ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built :
88755                     ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName));
88756             case ts.UpToDateStatusType.Unbuildable:
88757                 return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason);
88758             case ts.UpToDateStatusType.TsVersionOutputOfDate:
88759                 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);
88760             case ts.UpToDateStatusType.ContainerOnly:
88761             case ts.UpToDateStatusType.ComputingUpstream:
88762                 break;
88763             default:
88764                 ts.assertType(status);
88765         }
88766     }
88767     function verboseReportProjectStatus(state, configFileName, status) {
88768         if (state.options.verbose) {
88769             reportUpToDateStatus(state, configFileName, status);
88770         }
88771     }
88772 })(ts || (ts = {}));
88773 var ts;
88774 (function (ts) {
88775     function countLines(program) {
88776         var count = 0;
88777         ts.forEach(program.getSourceFiles(), function (file) {
88778             count += ts.getLineStarts(file).length;
88779         });
88780         return count;
88781     }
88782     function updateReportDiagnostic(sys, existing, options) {
88783         return shouldBePretty(sys, options) ?
88784             ts.createDiagnosticReporter(sys, true) :
88785             existing;
88786     }
88787     function defaultIsPretty(sys) {
88788         return !!sys.writeOutputIsTTY && sys.writeOutputIsTTY();
88789     }
88790     function shouldBePretty(sys, options) {
88791         if (!options || typeof options.pretty === "undefined") {
88792             return defaultIsPretty(sys);
88793         }
88794         return options.pretty;
88795     }
88796     function getOptionsForHelp(commandLine) {
88797         return !!commandLine.options.all ?
88798             ts.sort(ts.optionDeclarations, function (a, b) { return ts.compareStringsCaseInsensitive(a.name, b.name); }) :
88799             ts.filter(ts.optionDeclarations.slice(), function (v) { return !!v.showInSimplifiedHelpView; });
88800     }
88801     function printVersion(sys) {
88802         sys.write(ts.getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + sys.newLine);
88803     }
88804     function printHelp(sys, optionsList, syntaxPrefix) {
88805         if (syntaxPrefix === void 0) { syntaxPrefix = ""; }
88806         var output = [];
88807         var syntaxLength = ts.getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, "").length;
88808         var examplesLength = ts.getDiagnosticText(ts.Diagnostics.Examples_Colon_0, "").length;
88809         var marginLength = Math.max(syntaxLength, examplesLength);
88810         var syntax = makePadding(marginLength - syntaxLength);
88811         syntax += "tsc " + syntaxPrefix + "[" + ts.getDiagnosticText(ts.Diagnostics.options) + "] [" + ts.getDiagnosticText(ts.Diagnostics.file) + "...]";
88812         output.push(ts.getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, syntax));
88813         output.push(sys.newLine + sys.newLine);
88814         var padding = makePadding(marginLength);
88815         output.push(ts.getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + sys.newLine);
88816         output.push(padding + "tsc --outFile file.js file.ts" + sys.newLine);
88817         output.push(padding + "tsc @args.txt" + sys.newLine);
88818         output.push(padding + "tsc --build tsconfig.json" + sys.newLine);
88819         output.push(sys.newLine);
88820         output.push(ts.getDiagnosticText(ts.Diagnostics.Options_Colon) + sys.newLine);
88821         marginLength = 0;
88822         var usageColumn = [];
88823         var descriptionColumn = [];
88824         var optionsDescriptionMap = ts.createMap();
88825         for (var _i = 0, optionsList_1 = optionsList; _i < optionsList_1.length; _i++) {
88826             var option = optionsList_1[_i];
88827             if (!option.description) {
88828                 continue;
88829             }
88830             var usageText_1 = " ";
88831             if (option.shortName) {
88832                 usageText_1 += "-" + option.shortName;
88833                 usageText_1 += getParamType(option);
88834                 usageText_1 += ", ";
88835             }
88836             usageText_1 += "--" + option.name;
88837             usageText_1 += getParamType(option);
88838             usageColumn.push(usageText_1);
88839             var description = void 0;
88840             if (option.name === "lib") {
88841                 description = ts.getDiagnosticText(option.description);
88842                 var element = option.element;
88843                 var typeMap = element.type;
88844                 optionsDescriptionMap.set(description, ts.arrayFrom(typeMap.keys()).map(function (key) { return "'" + key + "'"; }));
88845             }
88846             else {
88847                 description = ts.getDiagnosticText(option.description);
88848             }
88849             descriptionColumn.push(description);
88850             marginLength = Math.max(usageText_1.length, marginLength);
88851         }
88852         var usageText = " @<" + ts.getDiagnosticText(ts.Diagnostics.file) + ">";
88853         usageColumn.push(usageText);
88854         descriptionColumn.push(ts.getDiagnosticText(ts.Diagnostics.Insert_command_line_options_and_files_from_a_file));
88855         marginLength = Math.max(usageText.length, marginLength);
88856         for (var i = 0; i < usageColumn.length; i++) {
88857             var usage = usageColumn[i];
88858             var description = descriptionColumn[i];
88859             var kindsList = optionsDescriptionMap.get(description);
88860             output.push(usage + makePadding(marginLength - usage.length + 2) + description + sys.newLine);
88861             if (kindsList) {
88862                 output.push(makePadding(marginLength + 4));
88863                 for (var _a = 0, kindsList_1 = kindsList; _a < kindsList_1.length; _a++) {
88864                     var kind = kindsList_1[_a];
88865                     output.push(kind + " ");
88866                 }
88867                 output.push(sys.newLine);
88868             }
88869         }
88870         for (var _b = 0, output_1 = output; _b < output_1.length; _b++) {
88871             var line = output_1[_b];
88872             sys.write(line);
88873         }
88874         return;
88875         function getParamType(option) {
88876             if (option.paramType !== undefined) {
88877                 return " " + ts.getDiagnosticText(option.paramType);
88878             }
88879             return "";
88880         }
88881         function makePadding(paddingLength) {
88882             return Array(paddingLength + 1).join(" ");
88883         }
88884     }
88885     function executeCommandLineWorker(sys, cb, commandLine) {
88886         var reportDiagnostic = ts.createDiagnosticReporter(sys);
88887         if (commandLine.options.build) {
88888             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Option_build_must_be_the_first_command_line_argument));
88889             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88890         }
88891         var configFileName;
88892         if (commandLine.options.locale) {
88893             ts.validateLocaleAndSetLanguage(commandLine.options.locale, sys, commandLine.errors);
88894         }
88895         if (commandLine.errors.length > 0) {
88896             commandLine.errors.forEach(reportDiagnostic);
88897             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88898         }
88899         if (commandLine.options.init) {
88900             writeConfigFile(sys, reportDiagnostic, commandLine.options, commandLine.fileNames);
88901             return sys.exit(ts.ExitStatus.Success);
88902         }
88903         if (commandLine.options.version) {
88904             printVersion(sys);
88905             return sys.exit(ts.ExitStatus.Success);
88906         }
88907         if (commandLine.options.help || commandLine.options.all) {
88908             printVersion(sys);
88909             printHelp(sys, getOptionsForHelp(commandLine));
88910             return sys.exit(ts.ExitStatus.Success);
88911         }
88912         if (commandLine.options.watch && commandLine.options.listFilesOnly) {
88913             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "watch", "listFilesOnly"));
88914             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88915         }
88916         if (commandLine.options.project) {
88917             if (commandLine.fileNames.length !== 0) {
88918                 reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line));
88919                 return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88920             }
88921             var fileOrDirectory = ts.normalizePath(commandLine.options.project);
88922             if (!fileOrDirectory || sys.directoryExists(fileOrDirectory)) {
88923                 configFileName = ts.combinePaths(fileOrDirectory, "tsconfig.json");
88924                 if (!sys.fileExists(configFileName)) {
88925                     reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0, commandLine.options.project));
88926                     return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88927                 }
88928             }
88929             else {
88930                 configFileName = fileOrDirectory;
88931                 if (!sys.fileExists(configFileName)) {
88932                     reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_specified_path_does_not_exist_Colon_0, commandLine.options.project));
88933                     return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88934                 }
88935             }
88936         }
88937         else if (commandLine.fileNames.length === 0) {
88938             var searchPath = ts.normalizePath(sys.getCurrentDirectory());
88939             configFileName = ts.findConfigFile(searchPath, function (fileName) { return sys.fileExists(fileName); });
88940         }
88941         if (commandLine.fileNames.length === 0 && !configFileName) {
88942             if (commandLine.options.showConfig) {
88943                 reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0, ts.normalizePath(sys.getCurrentDirectory())));
88944             }
88945             else {
88946                 printVersion(sys);
88947                 printHelp(sys, getOptionsForHelp(commandLine));
88948             }
88949             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88950         }
88951         var currentDirectory = sys.getCurrentDirectory();
88952         var commandLineOptions = ts.convertToOptionsWithAbsolutePaths(commandLine.options, function (fileName) { return ts.getNormalizedAbsolutePath(fileName, currentDirectory); });
88953         if (configFileName) {
88954             var configParseResult = ts.parseConfigFileWithSystem(configFileName, commandLineOptions, commandLine.watchOptions, sys, reportDiagnostic);
88955             if (commandLineOptions.showConfig) {
88956                 if (configParseResult.errors.length !== 0) {
88957                     reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, configParseResult.options);
88958                     configParseResult.errors.forEach(reportDiagnostic);
88959                     return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88960                 }
88961                 sys.write(JSON.stringify(ts.convertToTSConfig(configParseResult, configFileName, sys), null, 4) + sys.newLine);
88962                 return sys.exit(ts.ExitStatus.Success);
88963             }
88964             reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, configParseResult.options);
88965             if (ts.isWatchSet(configParseResult.options)) {
88966                 if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic))
88967                     return;
88968                 return createWatchOfConfigFile(sys, cb, reportDiagnostic, configParseResult, commandLineOptions, commandLine.watchOptions);
88969             }
88970             else if (ts.isIncrementalCompilation(configParseResult.options)) {
88971                 performIncrementalCompilation(sys, cb, reportDiagnostic, configParseResult);
88972             }
88973             else {
88974                 performCompilation(sys, cb, reportDiagnostic, configParseResult);
88975             }
88976         }
88977         else {
88978             if (commandLineOptions.showConfig) {
88979                 sys.write(JSON.stringify(ts.convertToTSConfig(commandLine, ts.combinePaths(currentDirectory, "tsconfig.json"), sys), null, 4) + sys.newLine);
88980                 return sys.exit(ts.ExitStatus.Success);
88981             }
88982             reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, commandLineOptions);
88983             if (ts.isWatchSet(commandLineOptions)) {
88984                 if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic))
88985                     return;
88986                 return createWatchOfFilesAndCompilerOptions(sys, cb, reportDiagnostic, commandLine.fileNames, commandLineOptions, commandLine.watchOptions);
88987             }
88988             else if (ts.isIncrementalCompilation(commandLineOptions)) {
88989                 performIncrementalCompilation(sys, cb, reportDiagnostic, __assign(__assign({}, commandLine), { options: commandLineOptions }));
88990             }
88991             else {
88992                 performCompilation(sys, cb, reportDiagnostic, __assign(__assign({}, commandLine), { options: commandLineOptions }));
88993             }
88994         }
88995     }
88996     function isBuild(commandLineArgs) {
88997         if (commandLineArgs.length > 0 && commandLineArgs[0].charCodeAt(0) === 45) {
88998             var firstOption = commandLineArgs[0].slice(commandLineArgs[0].charCodeAt(1) === 45 ? 2 : 1).toLowerCase();
88999             return firstOption === "build" || firstOption === "b";
89000         }
89001         return false;
89002     }
89003     ts.isBuild = isBuild;
89004     function executeCommandLine(system, cb, commandLineArgs) {
89005         if (isBuild(commandLineArgs)) {
89006             var _a = ts.parseBuildCommand(commandLineArgs.slice(1)), buildOptions_1 = _a.buildOptions, watchOptions_1 = _a.watchOptions, projects_1 = _a.projects, errors_1 = _a.errors;
89007             if (buildOptions_1.generateCpuProfile && system.enableCPUProfiler) {
89008                 system.enableCPUProfiler(buildOptions_1.generateCpuProfile, function () { return performBuild(system, cb, buildOptions_1, watchOptions_1, projects_1, errors_1); });
89009             }
89010             else {
89011                 return performBuild(system, cb, buildOptions_1, watchOptions_1, projects_1, errors_1);
89012             }
89013         }
89014         var commandLine = ts.parseCommandLine(commandLineArgs, function (path) { return system.readFile(path); });
89015         if (commandLine.options.generateCpuProfile && system.enableCPUProfiler) {
89016             system.enableCPUProfiler(commandLine.options.generateCpuProfile, function () { return executeCommandLineWorker(system, cb, commandLine); });
89017         }
89018         else {
89019             return executeCommandLineWorker(system, cb, commandLine);
89020         }
89021     }
89022     ts.executeCommandLine = executeCommandLine;
89023     function reportWatchModeWithoutSysSupport(sys, reportDiagnostic) {
89024         if (!sys.watchFile || !sys.watchDirectory) {
89025             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"));
89026             sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
89027             return true;
89028         }
89029         return false;
89030     }
89031     function performBuild(sys, cb, buildOptions, watchOptions, projects, errors) {
89032         var reportDiagnostic = updateReportDiagnostic(sys, ts.createDiagnosticReporter(sys), buildOptions);
89033         if (buildOptions.locale) {
89034             ts.validateLocaleAndSetLanguage(buildOptions.locale, sys, errors);
89035         }
89036         if (errors.length > 0) {
89037             errors.forEach(reportDiagnostic);
89038             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
89039         }
89040         if (buildOptions.help) {
89041             printVersion(sys);
89042             printHelp(sys, ts.buildOpts, "--build ");
89043             return sys.exit(ts.ExitStatus.Success);
89044         }
89045         if (projects.length === 0) {
89046             printVersion(sys);
89047             printHelp(sys, ts.buildOpts, "--build ");
89048             return sys.exit(ts.ExitStatus.Success);
89049         }
89050         if (!sys.getModifiedTime || !sys.setModifiedTime || (buildOptions.clean && !sys.deleteFile)) {
89051             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--build"));
89052             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
89053         }
89054         if (buildOptions.watch) {
89055             if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic))
89056                 return;
89057             var buildHost_1 = ts.createSolutionBuilderWithWatchHost(sys, undefined, reportDiagnostic, ts.createBuilderStatusReporter(sys, shouldBePretty(sys, buildOptions)), createWatchStatusReporter(sys, buildOptions));
89058             updateSolutionBuilderHost(sys, cb, buildHost_1);
89059             var builder_1 = ts.createSolutionBuilderWithWatch(buildHost_1, projects, buildOptions, watchOptions);
89060             builder_1.build();
89061             return builder_1;
89062         }
89063         var buildHost = ts.createSolutionBuilderHost(sys, undefined, reportDiagnostic, ts.createBuilderStatusReporter(sys, shouldBePretty(sys, buildOptions)), createReportErrorSummary(sys, buildOptions));
89064         updateSolutionBuilderHost(sys, cb, buildHost);
89065         var builder = ts.createSolutionBuilder(buildHost, projects, buildOptions);
89066         var exitStatus = buildOptions.clean ? builder.clean() : builder.build();
89067         return sys.exit(exitStatus);
89068     }
89069     function createReportErrorSummary(sys, options) {
89070         return shouldBePretty(sys, options) ?
89071             function (errorCount) { return sys.write(ts.getErrorSummaryText(errorCount, sys.newLine)); } :
89072             undefined;
89073     }
89074     function performCompilation(sys, cb, reportDiagnostic, config) {
89075         var fileNames = config.fileNames, options = config.options, projectReferences = config.projectReferences;
89076         var host = ts.createCompilerHostWorker(options, undefined, sys);
89077         var currentDirectory = host.getCurrentDirectory();
89078         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
89079         ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); });
89080         enableStatistics(sys, options);
89081         var programOptions = {
89082             rootNames: fileNames,
89083             options: options,
89084             projectReferences: projectReferences,
89085             host: host,
89086             configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(config)
89087         };
89088         var program = ts.createProgram(programOptions);
89089         var exitStatus = ts.emitFilesAndReportErrorsAndGetExitStatus(program, reportDiagnostic, function (s) { return sys.write(s + sys.newLine); }, createReportErrorSummary(sys, options));
89090         reportStatistics(sys, program);
89091         cb(program);
89092         return sys.exit(exitStatus);
89093     }
89094     function performIncrementalCompilation(sys, cb, reportDiagnostic, config) {
89095         var options = config.options, fileNames = config.fileNames, projectReferences = config.projectReferences;
89096         enableStatistics(sys, options);
89097         var host = ts.createIncrementalCompilerHost(options, sys);
89098         var exitStatus = ts.performIncrementalCompilation({
89099             host: host,
89100             system: sys,
89101             rootNames: fileNames,
89102             options: options,
89103             configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(config),
89104             projectReferences: projectReferences,
89105             reportDiagnostic: reportDiagnostic,
89106             reportErrorSummary: createReportErrorSummary(sys, options),
89107             afterProgramEmitAndDiagnostics: function (builderProgram) {
89108                 reportStatistics(sys, builderProgram.getProgram());
89109                 cb(builderProgram);
89110             }
89111         });
89112         return sys.exit(exitStatus);
89113     }
89114     function updateSolutionBuilderHost(sys, cb, buildHost) {
89115         updateCreateProgram(sys, buildHost);
89116         buildHost.afterProgramEmitAndDiagnostics = function (program) {
89117             reportStatistics(sys, program.getProgram());
89118             cb(program);
89119         };
89120         buildHost.afterEmitBundle = cb;
89121     }
89122     function updateCreateProgram(sys, host) {
89123         var compileUsingBuilder = host.createProgram;
89124         host.createProgram = function (rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences) {
89125             ts.Debug.assert(rootNames !== undefined || (options === undefined && !!oldProgram));
89126             if (options !== undefined) {
89127                 enableStatistics(sys, options);
89128             }
89129             return compileUsingBuilder(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences);
89130         };
89131     }
89132     function updateWatchCompilationHost(sys, cb, watchCompilerHost) {
89133         updateCreateProgram(sys, watchCompilerHost);
89134         var emitFilesUsingBuilder = watchCompilerHost.afterProgramCreate;
89135         watchCompilerHost.afterProgramCreate = function (builderProgram) {
89136             emitFilesUsingBuilder(builderProgram);
89137             reportStatistics(sys, builderProgram.getProgram());
89138             cb(builderProgram);
89139         };
89140     }
89141     function createWatchStatusReporter(sys, options) {
89142         return ts.createWatchStatusReporter(sys, shouldBePretty(sys, options));
89143     }
89144     function createWatchOfConfigFile(system, cb, reportDiagnostic, configParseResult, optionsToExtend, watchOptionsToExtend) {
89145         var watchCompilerHost = ts.createWatchCompilerHostOfConfigFile({
89146             configFileName: configParseResult.options.configFilePath,
89147             optionsToExtend: optionsToExtend,
89148             watchOptionsToExtend: watchOptionsToExtend,
89149             system: system,
89150             reportDiagnostic: reportDiagnostic,
89151             reportWatchStatus: createWatchStatusReporter(system, configParseResult.options)
89152         });
89153         updateWatchCompilationHost(system, cb, watchCompilerHost);
89154         watchCompilerHost.configFileParsingResult = configParseResult;
89155         return ts.createWatchProgram(watchCompilerHost);
89156     }
89157     function createWatchOfFilesAndCompilerOptions(system, cb, reportDiagnostic, rootFiles, options, watchOptions) {
89158         var watchCompilerHost = ts.createWatchCompilerHostOfFilesAndCompilerOptions({
89159             rootFiles: rootFiles,
89160             options: options,
89161             watchOptions: watchOptions,
89162             system: system,
89163             reportDiagnostic: reportDiagnostic,
89164             reportWatchStatus: createWatchStatusReporter(system, options)
89165         });
89166         updateWatchCompilationHost(system, cb, watchCompilerHost);
89167         return ts.createWatchProgram(watchCompilerHost);
89168     }
89169     function canReportDiagnostics(system, compilerOptions) {
89170         return system === ts.sys && (compilerOptions.diagnostics || compilerOptions.extendedDiagnostics);
89171     }
89172     function enableStatistics(sys, compilerOptions) {
89173         if (canReportDiagnostics(sys, compilerOptions)) {
89174             ts.performance.enable();
89175         }
89176     }
89177     function reportStatistics(sys, program) {
89178         var statistics;
89179         var compilerOptions = program.getCompilerOptions();
89180         if (canReportDiagnostics(sys, compilerOptions)) {
89181             statistics = [];
89182             var memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1;
89183             reportCountStatistic("Files", program.getSourceFiles().length);
89184             reportCountStatistic("Lines", countLines(program));
89185             reportCountStatistic("Nodes", program.getNodeCount());
89186             reportCountStatistic("Identifiers", program.getIdentifierCount());
89187             reportCountStatistic("Symbols", program.getSymbolCount());
89188             reportCountStatistic("Types", program.getTypeCount());
89189             reportCountStatistic("Instantiations", program.getInstantiationCount());
89190             if (memoryUsed >= 0) {
89191                 reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K");
89192             }
89193             var programTime = ts.performance.getDuration("Program");
89194             var bindTime = ts.performance.getDuration("Bind");
89195             var checkTime = ts.performance.getDuration("Check");
89196             var emitTime = ts.performance.getDuration("Emit");
89197             if (compilerOptions.extendedDiagnostics) {
89198                 var caches = program.getRelationCacheSizes();
89199                 reportCountStatistic("Assignability cache size", caches.assignable);
89200                 reportCountStatistic("Identity cache size", caches.identity);
89201                 reportCountStatistic("Subtype cache size", caches.subtype);
89202                 reportCountStatistic("Strict subtype cache size", caches.strictSubtype);
89203                 ts.performance.forEachMeasure(function (name, duration) { return reportTimeStatistic(name + " time", duration); });
89204             }
89205             else {
89206                 reportTimeStatistic("I/O read", ts.performance.getDuration("I/O Read"));
89207                 reportTimeStatistic("I/O write", ts.performance.getDuration("I/O Write"));
89208                 reportTimeStatistic("Parse time", programTime);
89209                 reportTimeStatistic("Bind time", bindTime);
89210                 reportTimeStatistic("Check time", checkTime);
89211                 reportTimeStatistic("Emit time", emitTime);
89212             }
89213             reportTimeStatistic("Total time", programTime + bindTime + checkTime + emitTime);
89214             reportStatistics();
89215             ts.performance.disable();
89216         }
89217         function reportStatistics() {
89218             var nameSize = 0;
89219             var valueSize = 0;
89220             for (var _i = 0, statistics_1 = statistics; _i < statistics_1.length; _i++) {
89221                 var _a = statistics_1[_i], name = _a.name, value = _a.value;
89222                 if (name.length > nameSize) {
89223                     nameSize = name.length;
89224                 }
89225                 if (value.length > valueSize) {
89226                     valueSize = value.length;
89227                 }
89228             }
89229             for (var _b = 0, statistics_2 = statistics; _b < statistics_2.length; _b++) {
89230                 var _c = statistics_2[_b], name = _c.name, value = _c.value;
89231                 sys.write(ts.padRight(name + ":", nameSize + 2) + ts.padLeft(value.toString(), valueSize) + sys.newLine);
89232             }
89233         }
89234         function reportStatisticalValue(name, value) {
89235             statistics.push({ name: name, value: value });
89236         }
89237         function reportCountStatistic(name, count) {
89238             reportStatisticalValue(name, "" + count);
89239         }
89240         function reportTimeStatistic(name, time) {
89241             reportStatisticalValue(name, (time / 1000).toFixed(2) + "s");
89242         }
89243     }
89244     function writeConfigFile(sys, reportDiagnostic, options, fileNames) {
89245         var currentDirectory = sys.getCurrentDirectory();
89246         var file = ts.normalizePath(ts.combinePaths(currentDirectory, "tsconfig.json"));
89247         if (sys.fileExists(file)) {
89248             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file));
89249         }
89250         else {
89251             sys.writeFile(file, ts.generateTSConfig(options, fileNames, sys.newLine));
89252             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Successfully_created_a_tsconfig_json_file));
89253         }
89254         return;
89255     }
89256 })(ts || (ts = {}));
89257 // This file actually uses arguments passed on commandline and executes it
89258 if (ts.Debug.isDebugging) {
89259     ts.Debug.enableDebugInfo();
89260 }
89261 if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))) {
89262     ts.sys.tryEnableSourceMapsForHost();
89263 }
89264 if (ts.sys.setBlocking) {
89265     ts.sys.setBlocking();
89266 }
89267 ts.executeCommandLine(ts.sys, ts.noop, ts.sys.args);